From ce18ee62ab347529a281e936e819377c10d51d26 Mon Sep 17 00:00:00 2001 From: Kenneth Russel Date: Sun, 19 Mar 2006 01:20:43 +0000 Subject: Added fallback path in GLContext optimization code to be able to disable behavior of leaving last context current on OpenGL worker thread. Currently can be manually disabled with -Djogl.GLContext.noopt. Added explicit test on X11 platforms of whether the onscreen context created is direct or not, and to disable context optimization if not, to automatically solve problems when running with indirect contexts typically from Mesa. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@668 232f8b59-042b-4e1e-8c03-345bb8c30851 --- .../sun/opengl/impl/x11/X11OnscreenGLContext.java | 23 +++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'src/classes/com/sun/opengl/impl/x11') diff --git a/src/classes/com/sun/opengl/impl/x11/X11OnscreenGLContext.java b/src/classes/com/sun/opengl/impl/x11/X11OnscreenGLContext.java index e666fc152..f4f4c7094 100644 --- a/src/classes/com/sun/opengl/impl/x11/X11OnscreenGLContext.java +++ b/src/classes/com/sun/opengl/impl/x11/X11OnscreenGLContext.java @@ -46,6 +46,10 @@ import com.sun.opengl.impl.*; public class X11OnscreenGLContext extends X11GLContext { protected X11OnscreenGLDrawable drawable; + // This indicates whether the context we have created is indirect + // and therefore requires the toolkit to be locked around all GL + // calls rather than just all GLX calls + protected boolean isIndirect; public X11OnscreenGLContext(X11OnscreenGLDrawable drawable, GLContext shareWith) { @@ -64,13 +68,30 @@ public class X11OnscreenGLContext extends X11GLContext { } return super.makeCurrentImpl(); } finally { - if (lockRes != X11OnscreenGLDrawable.LOCK_SURFACE_NOT_READY) { + if (optimizationEnabled) { + if (lockRes != X11OnscreenGLDrawable.LOCK_SURFACE_NOT_READY) { + drawable.unlockSurface(); + } + } + } + } + + protected void releaseImpl() throws GLException { + if (!optimizationEnabled) { + try { + super.releaseImpl(); + } finally { drawable.unlockSurface(); } } } + public boolean isOptimizable() { + return super.isOptimizable() && !isIndirect; + } + protected void create() { createContext(true); + isIndirect = !GLX.glXIsDirect(drawable.getDisplay(), context); } } -- cgit v1.2.3