Bug 665 - Allow re-association of GLContext/GLEventListener to a GLDrawable, allowing GLContext/GLEventListener survival of GLDrawable/Surface Destruction
Summary: Allow re-association of GLContext/GLEventListener to a GLDrawable, allowing G...
Alias: None
Product: Jogl
Classification: JogAmp
Component: core (show other bugs)
Version: 2
Hardware: All all
: --- enhancement
Assignee: Sven Gothel
Depends on:
Reported: 2013-01-08 16:48 CET by Brice Figureau
Modified: 2013-03-22 14:01 CET (History)
2 users (show)

See Also:
Type: ---
SCM Refs:
jogl b738983638703bb721ee4c9820c8ef43e2252e73 jogl 7fd5f76e1eb4bbf93fe9b1171744bd755d8f96e4 jogl 2fe180fbee15b82e2ae14fe3c95887db246c874d jogl c225285e09f0a29fca418601bf1aa07cafb54339 jogl e2506d7663b752f00f0a98f793ebad52e65bd1e3
Workaround: ---


Note You need to log in before you can comment on or make changes to this bug.
Description Brice Figureau 2013-01-08 16:48:38 CET
when an android app is stopped by being put on the background when tapping the "home" button, the WindowDriver.surfaceDestroyed method is called and ultimately the GLContext is destroyed.
When the app comes back to life (and the activity.onResume is called), the GLWindow becomes visible again, but with a blank gl context that lost all VBO and textures.

It would be great to save the GL context when the surface is destroyed and restored when a new surface gets attached to the gl window.
Comment 1 Sven Gothel 2013-01-21 14:32:26 CET
Will refine the whole GLContext.setDrawable(..), i.e. GLContext<->GLDrawable
association to allow an unbound GLContext. The latter is ofc to be treated very carefully,
i.e. no method shall be called until re-associated w/ GLDrawable.

Then .. when passing unit tests etc., we can have an option in e.g. NewtBaseActivity to flag
GLContext survival ..
Comment 2 Sven Gothel 2013-01-24 17:29:06 CET
part 1 - see commit message ..

Achieved: New test case w/ GLContext surviving GLAutoDrawable destruction 
and re-association (X11, Windows and OSX w/ NEWT).
Comment 3 Sven Gothel 2013-01-26 06:01:59 CET
Tackling EGL derived surface case w/ 
commit 7fd5f76e1eb4bbf93fe9b1171744bd755d8f96e4,
not complete yet.
Comment 4 Sven Gothel 2013-01-27 14:08:50 CET
    Bug 665 (part 3) - Add EGL/ES2 tests, attempt to fix wrapped EGL case
    - Add EGL/ES2 tests in
      - TestGLContextDrawableSwitch01NEWT
      - TestGLContextDrawableSwitch11NEWT
    - Attempt to fix wrapped EGL case (incomplete)
      - Using EGL/ES w/ non native EGL device/surface, but natively wrapped instances (most of the cases),
        a 'complicated' delegation of
           Native-Upstream -> EGL-Proxy -> EGL-Instance
        is being used heavily relying on the objects lifecycle.
        GLEventListenerState tries to roll back the realized state
        and even sets the upstream device handle,
        but this doesn't seem to be sufficient on X11.
    It might turn out that we only can implement the survival of GLContext
    and it's display device reliable w/ EGL within the GLAutoDrawable implementation,
    which can hold the previous not destructed instances.
Comment 6 Sven Gothel 2013-03-22 14:01:56 CET
Part 6

Part 7 (Android Specific)

Tested manually on Android devices, i.e. when pressing HOME
and returning to application, the state has been preserved (no dispose/init on GLEventListeners
and same GLContext is being used .. etc). This is visible when the 'gears' for example
return in the same [rotational] state when left ..

GLEventListenerState handling is described w/ interface GLStateKeeper
to be used and queried by any platform if desired.