Does JSR231 notify EventListeners about the context being destroyed ?

hi

I’ve always wondered how to get a notification about my textures getting lost, when the GLPanel is moved to another frame or the frame is made fullscreen.
(A solution might be paying attention to how often init is/was called for certain GLAutoDrawable Instance?)

I’d really like JSR231 to provide a way to notify a EventListener about a upcoming ContextDestory, so you might perform some operations. Usually you don’t have to free textures or other resources because they will also be destroyed by OpenGL right ? But what if you have to read back some state or buffer ?

Hope this has a easy answer :slight_smile:

Keep up the good work :wink:

Sorry, no, we don’t provide a callback on context destruction. There is really no good time to do this as by the time JOGL knows the context is going away it’s generally too late to make it current one last time and do any last OpenGL work, for example.

We do provide the init() callback and recommend that you write your GLEventListeners in a way which supports multiple calls to init(). It is called each time a new OpenGL context is created for your particular GLAutoDrawable.

You can for example subclass GLCanvas and override removeNotify() which is the appropriate callback; you would need to make sure to call super.removeNotify(). However at this point, again, it’s too late to do any OpenGL-related work, though you could do non-OpenGL work in your overridden method.