aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2010-11-16 10:30:04 +0100
committerSven Gothel <[email protected]>2010-11-16 10:30:04 +0100
commitb3420aeb07f9bef1e4fe5f436524d0b3d66cfaa2 (patch)
tree9769dddcb7112cb7af352ceca7622829986f6f3d
parentc7e1451f3effc4580347e65b0d6a288c493d60df (diff)
X11: Make X11 error handler quiet where we expect an X11 error, ie OpenGL 4 not available ..
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java12
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/impl/x11/X11Util.java8
-rw-r--r--src/nativewindow/native/x11/Xmisc.c12
3 files changed, 18 insertions, 14 deletions
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 75e523cbc..63b758da3 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
@@ -240,11 +240,11 @@ public abstract class X11GLXContext extends GLContextImpl {
protected boolean createImpl() {
// covers the whole context creation loop incl createContextARBImpl and destroyContextARBImpl
- X11Util.setX11ErrorHandler(true);
+ X11Util.setX11ErrorHandler(true, true);
try {
return createImplRaw();
} finally {
- X11Util.setX11ErrorHandler(false);
+ X11Util.setX11ErrorHandler(false, false);
}
}
@@ -380,13 +380,13 @@ public abstract class X11GLXContext extends GLContextImpl {
long dpy = drawable.getNativeSurface().getDisplayHandle();
if (GLX.glXGetCurrentContext() != contextHandle) {
- X11Util.setX11ErrorHandler(true);
+ X11Util.setX11ErrorHandler(true, true);
try {
if (!glXMakeContextCurrent(dpy, drawable.getHandle(), drawableRead.getHandle(), contextHandle)) {
throw new GLException("Error making context current: "+this);
}
} finally {
- X11Util.setX11ErrorHandler(false);
+ X11Util.setX11ErrorHandler(false, false);
}
if (DEBUG && (VERBOSE || newCreated)) {
System.err.println(getThreadName() + ": glXMakeCurrent(display " +
@@ -400,13 +400,13 @@ public abstract class X11GLXContext extends GLContextImpl {
protected void releaseImpl() throws GLException {
long display = drawable.getNativeSurface().getDisplayHandle();
- X11Util.setX11ErrorHandler(true);
+ X11Util.setX11ErrorHandler(true, true);
try {
if (!glXMakeContextCurrent(display, 0, 0, 0)) {
throw new GLException("Error freeing OpenGL context");
}
} finally {
- X11Util.setX11ErrorHandler(false);
+ X11Util.setX11ErrorHandler(false, false);
}
}
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/impl/x11/X11Util.java b/src/nativewindow/classes/com/jogamp/nativewindow/impl/x11/X11Util.java
index c449d8f86..f7f4828ca 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/impl/x11/X11Util.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/impl/x11/X11Util.java
@@ -77,11 +77,11 @@ public class X11Util {
}
}
- public static void setX11ErrorHandler(boolean onoff) {
+ public static void setX11ErrorHandler(boolean onoff, boolean quiet) {
synchronized(setX11ErrorHandlerLock) {
if(onoff) {
if(0==setX11ErrorHandlerRecCount) {
- setX11ErrorHandler0(true);
+ setX11ErrorHandler0(true, quiet);
}
setX11ErrorHandlerRecCount++;
} else {
@@ -90,7 +90,7 @@ public class X11Util {
}
setX11ErrorHandlerRecCount--;
if(0==setX11ErrorHandlerRecCount) {
- setX11ErrorHandler0(false);
+ setX11ErrorHandler0(false, false);
}
}
}
@@ -595,5 +595,5 @@ public class X11Util {
}
private static native void initialize0(boolean firstUIActionOnProcess);
- private static native void setX11ErrorHandler0(boolean onoff);
+ private static native void setX11ErrorHandler0(boolean onoff, boolean quiet);
}
diff --git a/src/nativewindow/native/x11/Xmisc.c b/src/nativewindow/native/x11/Xmisc.c
index 290ec14cf..0e91ae831 100644
--- a/src/nativewindow/native/x11/Xmisc.c
+++ b/src/nativewindow/native/x11/Xmisc.c
@@ -182,10 +182,13 @@ static void _throwNewRuntimeException(Display * unlockDisplay, JNIEnv *env, cons
static JNIEnv * x11ErrorHandlerJNIEnv = NULL;
static XErrorHandler origErrorHandler = NULL ;
static int errorHandlerBlocked = 0 ;
+static int errorHandlerQuiet = 0 ;
static int x11ErrorHandler(Display *dpy, XErrorEvent *e)
{
- fprintf(stderr, "Info: Nativewindow X11 Error: Display %p, Code 0x%X, errno %s", dpy, e->error_code, strerror(errno));
+ if(!errorHandlerQuiet) {
+ fprintf(stderr, "Info: Nativewindow X11 Error: Display %p, Code 0x%X, errno %s\n", dpy, e->error_code, strerror(errno));
+ }
#if 0
// Since the X11 Error may happen anytime, a exception could mess up the JVM completely.
// Experienced this for remote displays issuing non supported commands, eg. glXCreateContextAttribsARB(..)
@@ -225,10 +228,11 @@ static void x11ErrorHandlerEnable(Display *dpy, int onoff, JNIEnv * env) {
}
}
-static void x11ErrorHandlerEnableBlocking(int onoff, JNIEnv * env) {
+static void x11ErrorHandlerEnableBlocking(JNIEnv * env, int onoff, int quiet) {
errorHandlerBlocked = 0 ;
x11ErrorHandlerEnable(NULL, onoff, env);
errorHandlerBlocked = onoff ;
+ errorHandlerQuiet = quiet;
}
@@ -278,8 +282,8 @@ Java_com_jogamp_nativewindow_impl_x11_X11Util_initialize0(JNIEnv *env, jclass _u
}
JNIEXPORT void JNICALL
-Java_com_jogamp_nativewindow_impl_x11_X11Util_setX11ErrorHandler0(JNIEnv *env, jclass _unused, jboolean onoff) {
- x11ErrorHandlerEnableBlocking(( JNI_TRUE == onoff ) ? 1 : 0, env);
+Java_com_jogamp_nativewindow_impl_x11_X11Util_setX11ErrorHandler0(JNIEnv *env, jclass _unused, jboolean onoff, jboolean quiet) {
+ x11ErrorHandlerEnableBlocking(env, ( JNI_TRUE == onoff ) ? 1 : 0, ( JNI_TRUE == quiet ) ? 1 : 0);
}
/* Java->C glue code: