From 36887db6c983244917802f3ec761a0d28171887a Mon Sep 17 00:00:00 2001 From: Kenneth Russel Date: Tue, 21 Feb 2006 09:43:43 +0000 Subject: Added optimized path to GLDrawableHelper for situation where GLWorkerThread is being used; last context made current on that thread is left current on that thread. In the case where only a single OpenGL context is in use this eliminates the repeated calls to makeCurrent. Ran into same NVidia driver bug causing crashes upon exit with Java2D/OpenGL pipeline. Added workaround to GLDrawableHelper which can be enabled with -Djogl.nvidia.crash.workaround, which just disables this optimization. Fixed GLCanvas and GLPbufferImpl's destruction paths to behave correctly in the face of the context being left current on the GLWorkerThread. Updated code in Threading related to GLWorkerThread to interoperate better with Java2D/OpenGL pipeline. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@629 232f8b59-042b-4e1e-8c03-345bb8c30851 --- src/classes/com/sun/opengl/impl/GLPbufferImpl.java | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'src/classes/com/sun/opengl/impl/GLPbufferImpl.java') diff --git a/src/classes/com/sun/opengl/impl/GLPbufferImpl.java b/src/classes/com/sun/opengl/impl/GLPbufferImpl.java index 196ea7223..feb9d3512 100644 --- a/src/classes/com/sun/opengl/impl/GLPbufferImpl.java +++ b/src/classes/com/sun/opengl/impl/GLPbufferImpl.java @@ -172,8 +172,12 @@ public class GLPbufferImpl implements GLPbuffer { PropertyChangeListener listener) {} public void destroy() { - context.destroy(); - pbufferDrawable.destroy(); + if (Threading.isSingleThreaded() && + !Threading.isOpenGLThread()) { + Threading.invokeOnOpenGLThread(destroyAction); + } else { + destroyAction.run(); + } } public int getFloatingPointMode() { @@ -238,4 +242,16 @@ public class GLPbufferImpl implements GLPbuffer { } private SwapBuffersOnEventDispatchThreadAction swapBuffersOnEventDispatchThreadAction = new SwapBuffersOnEventDispatchThreadAction(); + + class DestroyAction implements Runnable { + public void run() { + GLContext current = GLContext.getCurrent(); + if (current == context) { + context.release(); + } + context.destroy(); + pbufferDrawable.destroy(); + } + } + private DestroyAction destroyAction = new DestroyAction(); } -- cgit v1.2.3