Here is the raw explanation:
Assuming there is no sharing of display lists between multiple contexts in your application, when your GLEventListener.init() method is called, you need to re-create them. That is the callback sent when a new OpenGL context is created. Depending on how the JDK implements full-screen support you may or may not have to reinitialize these objects. Fundamentally you should just structure your application to watch for calls to init() and perform your display list initialization there.
Note that if you have sharing of display lists in place then the rules change. OpenGL specifies a reference counting mechanism for these server-side objects. If you have a second persistent context sharing with the first, then the when the first is destroyed and re-created the lists will still be alive since the second one kept them alive.
As it happens the GL object is also supposed to be discarded when init() is called. Internally to the library a new one is created for the GLContext each time it is re-initialized. You can either pass the GL object down your call chain or call GLU.getCurrentGL() each time you need access to it. The GLContext object is persistent and is a container for the real OpenGL context which may or may not be created at the current time, depending on whether the window is visible.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.