From c5640e88c4aade6fed25dfef302ca29968e02573 Mon Sep 17 00:00:00 2001 From: Kenneth Russel Date: Sat, 7 May 2005 00:45:19 +0000 Subject: Fixed Issue 151: starting up the Animator before the GLJPanel has been shown result in an error The root cause of this error was the fact that WindowsPbufferGLContext.destroyImpl() uses WGL extensions to clean up resources associated with the pbuffer. Because these extensions are in the public WGL interface, they are wrapped by the DebugGL. However, an OpenGL context is not current at the time these routines are called, and it is illegal to call glGetError() at those points. The DebugGL pipeline was implicitly calling glGetError() after each of those calls, leading to the failure. This bug unmasked a couple of others. The code in the DebugGL needed a recursion count to make sure that glGetError() didn't get called in an infinite loop. Also, as a side effect of the fix for Issue 160, calling getGL() on the GLJPanel outside of GLEventListener.init() was causing a NullPointerException to be thrown. The GLJPanel has been fixed to return null in this case, and the specification of GLDrawable.getGL() has been improved. In order to make the behavior between the GLCanvas and GLJPanel similar, the GL object is now reset in the GLDrawable each time the underlying OpenGL context is recreated. This allows end users to set up e.g. the DebugGL unconditionally in their GLEventListener.init() method. The JOGL demos have been changed to reflect this. The test case in the bug report will be updated with code similar to the originally submitted test case (i.e., the Animator is started early) but which now works. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@264 232f8b59-042b-4e1e-8c03-345bb8c30851 --- src/net/java/games/jogl/GLJPanel.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/net/java/games/jogl/GLJPanel.java') diff --git a/src/net/java/games/jogl/GLJPanel.java b/src/net/java/games/jogl/GLJPanel.java index d21081dfe..bf102710b 100644 --- a/src/net/java/games/jogl/GLJPanel.java +++ b/src/net/java/games/jogl/GLJPanel.java @@ -291,17 +291,27 @@ public final class GLJPanel extends JPanel implements GLDrawable { public GL getGL() { if (!hardwareAccelerationDisabled) { + if (pbuffer == null) { + return null; + } return pbuffer.getGL(); } else { + if (offscreenContext == null) { + return null; + } return offscreenContext.getGL(); } } public void setGL(GL gl) { if (!hardwareAccelerationDisabled) { - pbuffer.setGL(gl); + if (pbuffer != null) { + pbuffer.setGL(gl); + } } else { - offscreenContext.setGL(gl); + if (offscreenContext != null) { + offscreenContext.setGL(gl); + } } } @@ -473,6 +483,9 @@ public final class GLJPanel extends JPanel implements GLDrawable { public void init(GLDrawable drawable) { if (!hardwareAccelerationDisabled) { + if (DEBUG) { + System.err.println("GLJPanel$Updater.init(): pbufferInitializationCompleted = true"); + } pbufferInitializationCompleted = true; EventQueue.invokeLater(new Runnable() { public void run() { -- cgit v1.2.3