GLEventListener: dispose or displayChanged?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

GLEventListener: dispose or displayChanged?

Evan Parker
Hi Everyone,
I'm a newbie trying to understand the lifetime of GLContexts in my application.


I've noticed some JavaDocs say GLEventListener has functions { init / reshape / display / *dispose* } while other JavaDocs show { init / reshape / display / *displayChanged* }.   It appears that "dispose" changed to "displayChanged" at some point in Jogl's history?    (Why?)

The documentation for "dispose" says it's called to notify "the listener to perform the release of all OpenGL resources per GLContext, such as memory buffers and GLSL program".   This makes sense to me: I create Vertex Buffer Objects when "init" is called, so I'd destroy them in "dispose".

But on my system, GLEventListener has "displayChanged", and not "dispose".

JavaDocs for "displayChanged" don't mention anything about releasing Vertex Buffer Objects.   Am I still supposed to delete in "displayChanged" any Vertex Buffer Objects that I create in "init"?   Does a call to "displayChanged" mean the GLContext is being destroyed?  (If not, how can I tell if I'm supposed to recreate my Vertex Buffer Objects the next time "init" is called?)


Thank you for any understanding you can offer!
Evan
Reply | Threaded
Open this post in threaded view
|

Re: GLEventListener: dispose or displayChanged?

gouessej
Administrator
Hey

displayChanged was called when the program uses another screen/monitor, it has nothing to do with dispose. As far as I know, you can use the same VBOs when you move to another monitor.

Moreover, I find you should read this. You should delete VBOs when you don't need them anymore. You don't have to delete your VBOs at the end of the program as they will be deleted during the JVM shutdown. Releasing the resource is useful mostly when you don't want to lack of native memory at runtime.
Julien Gouesse | Personal blog | Website