From dc4a31054dc83073ccd5093dfb947dbade13789b Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 4 Nov 2010 02:37:52 +0100 Subject: JOGL/X11: Decorate glxMakeContextCurrent calls from makeCurrentImpl/releaseImpl with X11 Error Handle --- .../jogamp/opengl/impl/x11/glx/X11GLXContext.java | 30 ++++++++++++++-------- 1 file changed, 20 insertions(+), 10 deletions(-) (limited to 'src/jogl/classes') diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java index 494972e7a..d80da1dd4 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java @@ -351,24 +351,34 @@ public abstract class X11GLXContext extends GLContextImpl { protected void makeCurrentImpl(boolean newCreated) throws GLException { long dpy = drawable.getNativeSurface().getDisplayHandle(); - if (GLX.glXGetCurrentContext() != contextHandle) { - if (!glXMakeContextCurrent(dpy, drawable.getHandle(), drawableRead.getHandle(), contextHandle)) { - throw new GLException("Error making context current: "+this); + if (GLX.glXGetCurrentContext() != contextHandle) { + X11Util.setX11ErrorHandler(true); + try { + if (!glXMakeContextCurrent(dpy, drawable.getHandle(), drawableRead.getHandle(), contextHandle)) { + throw new GLException("Error making context current: "+this); + } + } finally { + X11Util.setX11ErrorHandler(false); } if (DEBUG && (VERBOSE || newCreated)) { - System.err.println(getThreadName() + ": glXMakeCurrent(display " + - toHexString(dpy)+ - ", drawable " + toHexString(drawable.getHandle()) + - ", drawableRead " + toHexString(drawableRead.getHandle()) + - ", context " + toHexString(contextHandle) + ") succeeded"); + System.err.println(getThreadName() + ": glXMakeCurrent(display " + + toHexString(dpy)+ + ", drawable " + toHexString(drawable.getHandle()) + + ", drawableRead " + toHexString(drawableRead.getHandle()) + + ", context " + toHexString(contextHandle) + ") succeeded"); } } } protected void releaseImpl() throws GLException { long display = drawable.getNativeSurface().getDisplayHandle(); - if (!glXMakeContextCurrent(display, 0, 0, 0)) { - throw new GLException("Error freeing OpenGL context"); + X11Util.setX11ErrorHandler(true); + try { + if (!glXMakeContextCurrent(display, 0, 0, 0)) { + throw new GLException("Error freeing OpenGL context"); + } + } finally { + X11Util.setX11ErrorHandler(false); } } -- cgit v1.2.3