summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/jogl/classes/javax/media/opengl/GLContext.java23
-rw-r--r--src/jogl/classes/jogamp/opengl/GLContextImpl.java33
-rw-r--r--src/jogl/classes/jogamp/opengl/GLDebugMessageHandler.java42
-rw-r--r--src/jogl/native/GLDebugMessageHandler.c24
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLDebug00NEWT.java49
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLDebug01NEWT.java6
6 files changed, 128 insertions, 49 deletions
diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java
index 08bbcbb96..30cc9c2ea 100644
--- a/src/jogl/classes/javax/media/opengl/GLContext.java
+++ b/src/jogl/classes/javax/media/opengl/GLContext.java
@@ -539,6 +539,21 @@ public abstract class GLContext {
public abstract String getGLDebugMessageExtension();
/**
+ * @return the current synchronous debug behavior via
+ * @see #setSynchronous(boolean)
+ */
+ public abstract boolean isGLDebugSynchronous();
+
+ /**
+ * Enables or disables the synchronous debug behavior via
+ * {@link GL2GL3#GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB glEnable/glDisable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB)},
+ * if extension is {@link #GL_ARB_debug_output}.
+ * There is no equivalent for {@link #GL_AMD_debug_output}.
+ * <p> The default is <code>true</code>, ie {@link GL2GL3#GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB}.</p>
+ */
+ public abstract void setGLDebugSynchronous(boolean synchronous);
+
+ /**
* @return true if the GLDebugOutput feature is enabled or not.
*/
public abstract boolean isGLDebugMessageEnabled();
@@ -586,12 +601,6 @@ public abstract class GLContext {
public abstract void removeGLDebugListener(GLDebugListener listener);
/**
- * @return number of added {@link GLDebugListener}. If > 0, the GLDebugFeature is turned on, otherwise off.
- * @see #enableGLDebugMessage(boolean)
- */
- public abstract int getGLDebugListenerSize();
-
- /**
* Generic entry for {@link GL2GL3#glDebugMessageControlARB(int, int, int, int, IntBuffer, boolean)}
* and {@link GL2GL3#glDebugMessageEnableAMD(int, int, int, IntBuffer, boolean)} of the GLDebugOutput feature.
* @see #enableGLDebugMessage(boolean)
@@ -610,7 +619,7 @@ public abstract class GLContext {
* and {@link GL2GL3#glDebugMessageInsertAMD(int, int, int, int, String)} of the GLDebugOutput feature.
* @see #enableGLDebugMessage(boolean)
*/
- public abstract void glDebugMessageInsert(int source, int type, int id, int severity, int length, String buf);
+ public abstract void glDebugMessageInsert(int source, int type, int id, int severity, String buf);
public static final int GL_VERSIONS[][] = {
/* 0.*/ { -1 },
diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
index 6128b30b4..1d5c6911b 100644
--- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
@@ -407,7 +407,7 @@ public abstract class GLContextImpl extends GLContext {
if(DEBUG_GL) {
gl = gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Debug", null, gl, null) );
- glDebugHandler.addListener(new GLDebugMessageHandler.StdErrGLDebugListener());
+ glDebugHandler.addListener(new GLDebugMessageHandler.StdErrGLDebugListener(true));
}
if(TRACE_GL) {
gl = gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Trace", null, gl, new Object[] { System.err } ) );
@@ -1096,17 +1096,23 @@ public abstract class GLContextImpl extends GLContext {
return glDebugHandler.isEnabled();
}
- public int getContextCreationFlags() {
+ public final int getContextCreationFlags() {
return additionalCtxCreationFlags;
}
- public void setContextCreationFlags(int flags) {
+ public final void setContextCreationFlags(int flags) {
if(!isCreated()) {
additionalCtxCreationFlags = flags & GLContext.CTX_OPTION_DEBUG;
}
}
- public void enableGLDebugMessage(boolean enable) throws GLException {
+ public final boolean isGLDebugSynchronous() { return glDebugHandler.isSynchronous(); }
+
+ public final void setGLDebugSynchronous(boolean synchronous) {
+ glDebugHandler.setSynchronous(synchronous);
+ }
+
+ public final void enableGLDebugMessage(boolean enable) throws GLException {
if(!isCreated()) {
if(enable) {
additionalCtxCreationFlags |= GLContext.CTX_OPTION_DEBUG;
@@ -1119,19 +1125,15 @@ public abstract class GLContextImpl extends GLContext {
}
}
- public void addGLDebugListener(GLDebugListener listener) {
+ public final void addGLDebugListener(GLDebugListener listener) {
glDebugHandler.addListener(listener);
}
- public void removeGLDebugListener(GLDebugListener listener) {
+ public final void removeGLDebugListener(GLDebugListener listener) {
glDebugHandler.removeListener(listener);
}
- public int getGLDebugListenerSize() {
- return glDebugHandler.listenerSize();
- }
-
- public void glDebugMessageControl(int source, int type, int severity, int count, IntBuffer ids, boolean enabled) {
+ public final void glDebugMessageControl(int source, int type, int severity, int count, IntBuffer ids, boolean enabled) {
if(glDebugHandler.isExtensionARB()) {
gl.getGL2GL3().glDebugMessageControlARB(source, type, severity, count, ids, enabled);
} else if(glDebugHandler.isExtensionAMD()) {
@@ -1139,7 +1141,7 @@ public abstract class GLContextImpl extends GLContext {
}
}
- public void glDebugMessageControl(int source, int type, int severity, int count, int[] ids, int ids_offset, boolean enabled) {
+ public final void glDebugMessageControl(int source, int type, int severity, int count, int[] ids, int ids_offset, boolean enabled) {
if(glDebugHandler.isExtensionARB()) {
gl.getGL2GL3().glDebugMessageControlARB(source, type, severity, count, ids, ids_offset, enabled);
} else if(glDebugHandler.isExtensionAMD()) {
@@ -1147,12 +1149,11 @@ public abstract class GLContextImpl extends GLContext {
}
}
- public void glDebugMessageInsert(int source, int type, int id, int severity, int length, String buf) {
+ public final void glDebugMessageInsert(int source, int type, int id, int severity, String buf) {
if(glDebugHandler.isExtensionARB()) {
- gl.getGL2GL3().glDebugMessageInsertARB(source, type, id, severity, length, buf);
+ gl.getGL2GL3().glDebugMessageInsertARB(source, type, id, severity, -1, buf);
} else if(glDebugHandler.isExtensionAMD()) {
- if(0>length) { length = 0; }
- gl.getGL2GL3().glDebugMessageInsertAMD(GLDebugMessage.translateARB2AMDCategory(source, type), severity, id, length, buf);
+ gl.getGL2GL3().glDebugMessageInsertAMD(GLDebugMessage.translateARB2AMDCategory(source, type), severity, id, 0, buf);
}
}
}
diff --git a/src/jogl/classes/jogamp/opengl/GLDebugMessageHandler.java b/src/jogl/classes/jogamp/opengl/GLDebugMessageHandler.java
index f67c916ea..09be202dd 100644
--- a/src/jogl/classes/jogamp/opengl/GLDebugMessageHandler.java
+++ b/src/jogl/classes/jogamp/opengl/GLDebugMessageHandler.java
@@ -78,6 +78,7 @@ public class GLDebugMessageHandler {
private int extType;
private long glDebugMessageCallbackProcAddress;
private boolean extAvailable;
+ private boolean synchronous;
// licefycle: enable - disable/EOL
private long handle;
@@ -94,6 +95,7 @@ public class GLDebugMessageHandler {
this.extType = 0;
this.extAvailable = false;
this.handle = 0;
+ this.synchronous = true;
}
public void init(boolean enable) {
@@ -176,7 +178,32 @@ public class GLDebugMessageHandler {
}
/**
- * @throws GLException if context not current or callback registration failed (enable)
+ * @see javax.media.opengl.GLContext#isGLDebugSynchronous()
+ */
+ public final boolean isSynchronous() { return synchronous; }
+
+ /**
+ * @see javax.media.opengl.GLContext#setGLDebugSynchronous(boolean)
+ */
+ public final void setSynchronous(boolean synchronous) {
+ this.synchronous = synchronous;
+ if(isEnabled() && isExtensionARB()) {
+ setSynchronousImpl();
+ }
+ }
+ private final void setSynchronousImpl() {
+ if(synchronous) {
+ ctx.getGL().glEnable(GL2GL3.GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
+ } else {
+ ctx.getGL().glDisable(GL2GL3.GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
+ }
+ if(DEBUG) {
+ System.err.println("GLDebugMessageHandler: synchronous "+synchronous);
+ }
+ }
+
+ /**
+ * @see javax.media.opengl.GLContext#enableGLDebugMessage(boolean)
*/
public final void enable(boolean enable) throws GLException {
ctx.validateCurrent();
@@ -186,6 +213,7 @@ public class GLDebugMessageHandler {
enableImpl(enable);
}
final void enableImpl(boolean enable) throws GLException {
+ setSynchronousImpl();
if(enable) {
if(0 == handle) {
handle = register0(glDebugMessageCallbackProcAddress, extType);
@@ -234,9 +262,17 @@ public class GLDebugMessageHandler {
}
}
- public static class StdErrGLDebugListener implements GLDebugListener {
+ public static class StdErrGLDebugListener implements GLDebugListener {
+ boolean threadDump;
+
+ public StdErrGLDebugListener(boolean threadDump) {
+ this.threadDump = threadDump;
+ }
public void messageSent(GLDebugMessage event) {
- System.err.println(event);
+ System.err.println(event);
+ if(threadDump) {
+ Thread.dumpStack();
+ }
}
}
diff --git a/src/jogl/native/GLDebugMessageHandler.c b/src/jogl/native/GLDebugMessageHandler.c
index 22a7433f9..790871111 100644
--- a/src/jogl/native/GLDebugMessageHandler.c
+++ b/src/jogl/native/GLDebugMessageHandler.c
@@ -1,10 +1,22 @@
+#include <stdlib.h>
+#include <stdarg.h>
+
#include "jogamp_opengl_GLDebugMessageHandler.h"
#include "JoglCommon.h"
#include <GL/gl.h>
#include <GL/glext.h>
+// #define VERBOSE_ON 1
+
+#ifdef VERBOSE_ON
+ #define DBG_PRINT(...) fprintf(stderr, __VA_ARGS__); fflush(stderr)
+#else
+ #define DBG_PRINT(...)
+#endif
+
+
static jmethodID glDebugMessageARB = NULL; // int source, int type, int id, int severity, String msg
static jmethodID glDebugMessageAMD = NULL; // int id, int category, int severity, String msg
@@ -52,6 +64,7 @@ static void GLDebugMessageARBCallback(GLenum source, GLenum type, GLuint id, GLe
JNIEnv *curEnv = NULL;
JNIEnv *newEnv = NULL;
int envRes ;
+ DBG_PRINT("GLDebugMessageARBCallback: 01 - %s\n", message);
// retrieve this thread's JNIEnv curEnv - or detect it's detached
envRes = (*vm)->GetEnv(vm, (void **) &curEnv, version) ;
@@ -62,6 +75,7 @@ static void GLDebugMessageARBCallback(GLenum source, GLenum type, GLuint id, GLe
return;
}
curEnv = newEnv;
+ DBG_PRINT("GLDebugMessageARBCallback: 02 - attached .. \n");
} else if( JNI_OK != envRes ) {
// oops ..
fprintf(stderr, "GLDebugMessageARBCallback: can't GetEnv: %d\n", envRes);
@@ -73,7 +87,13 @@ static void GLDebugMessageARBCallback(GLenum source, GLenum type, GLuint id, GLe
if( NULL != newEnv ) {
// detached attached thread
(*vm)->DetachCurrentThread(vm);
+ DBG_PRINT("GLDebugMessageARBCallback: 04 - detached .. \n");
}
+ DBG_PRINT("GLDebugMessageARBCallback: 0X\n");
+ /**
+ * On Java 32bit on 64bit Windows and w/ GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB disables,
+ * the unit test com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug00NEWT crashes after this point.
+ */
}
// GLDEBUGAMD(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam);
@@ -108,6 +128,10 @@ static void GLDebugMessageAMDCallback(GLuint id, GLenum category, GLenum severit
// detached attached thread
(*vm)->DetachCurrentThread(vm);
}
+ /**
+ * On Java 32bit on 64bit Windows,
+ * the unit test com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug00NEWT crashes after this point.
+ */
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLDebug00NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLDebug00NEWT.java
index c6e78b219..1f8eebbc7 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLDebug00NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLDebug00NEWT.java
@@ -111,46 +111,33 @@ public class TestGLDebug00NEWT extends UITestCase {
}
- void test01GLDebug01EnableDisable(boolean enable, String dbgTstMsg, int dbgTstId) throws InterruptedException {
+ void test01GLDebug01EnableDisable(boolean enable) throws InterruptedException {
GLProfile glp = GLProfile.getDefault();
WindowContext winctx = createWindow(glp, enable);
- MyGLDebugListener myGLDebugListener = new MyGLDebugListener(dbgTstMsg, dbgTstId);
- if(enable) {
- winctx.context.addGLDebugListener(myGLDebugListener);
- }
String glDebugExt = winctx.context.getGLDebugMessageExtension();
System.err.println("glDebug extension: "+glDebugExt);
System.err.println("glDebug enabled: "+winctx.context.isGLDebugMessageEnabled());
- System.err.println("glDebug listener: "+winctx.context.getGLDebugListenerSize());
+ System.err.println("glDebug sync: "+winctx.context.isGLDebugSynchronous());
System.err.println("context version: "+winctx.context.getGLVersion());
Assert.assertEquals((null == glDebugExt) ? false : enable, winctx.context.isGLDebugMessageEnabled());
- Assert.assertEquals(enable?1:0, winctx.context.getGLDebugListenerSize());
-
- if(winctx.context.isGLDebugMessageEnabled() && null != dbgTstMsg && 0 <= dbgTstId) {
- winctx.context.glDebugMessageInsert(GL2GL3.GL_DEBUG_SOURCE_APPLICATION_ARB,
- GL2GL3.GL_DEBUG_TYPE_OTHER_ARB,
- dbgTstId,
- GL2GL3.GL_DEBUG_SEVERITY_MEDIUM_ARB, -1, dbgTstMsg);
- Assert.assertEquals(true, myGLDebugListener.received());
- }
destroyWindow(winctx);
}
@Test
- public void test01GLDebug01Disabled() throws InterruptedException {
- test01GLDebug01EnableDisable(false, null, -1);
+ public void test01GLDebugDisabled() throws InterruptedException {
+ test01GLDebug01EnableDisable(false);
}
@Test
- public void test01GLDebug01Enabled() throws InterruptedException {
- test01GLDebug01EnableDisable(true, dbgTstMsg0, dbgTstId0);
+ public void test01GLDebugEnabled() throws InterruptedException {
+ test01GLDebug01EnableDisable(true);
}
@Test
- public void test02GLDebug01Error() throws InterruptedException {
+ public void test02GLDebugError() throws InterruptedException {
GLProfile glp = GLProfile.getDefault();
WindowContext winctx = createWindow(glp, true);
@@ -172,6 +159,27 @@ public class TestGLDebug00NEWT extends UITestCase {
destroyWindow(winctx);
}
+ @Test
+ public void test03GLDebugInsert() throws InterruptedException {
+ GLProfile glp = GLProfile.getDefault();
+ WindowContext winctx = createWindow(glp, true);
+ MyGLDebugListener myGLDebugListener = new MyGLDebugListener(dbgTstMsg0, dbgTstId0);
+ winctx.context.addGLDebugListener(myGLDebugListener);
+
+ String glDebugExt = winctx.context.getGLDebugMessageExtension();
+ Assert.assertEquals((null == glDebugExt) ? false : true, winctx.context.isGLDebugMessageEnabled());
+
+ if( winctx.context.isGLDebugMessageEnabled() ) {
+ winctx.context.glDebugMessageInsert(GL2GL3.GL_DEBUG_SOURCE_APPLICATION_ARB,
+ GL2GL3.GL_DEBUG_TYPE_OTHER_ARB,
+ dbgTstId0,
+ GL2GL3.GL_DEBUG_SEVERITY_MEDIUM_ARB, dbgTstMsg0);
+ Assert.assertEquals(true, myGLDebugListener.received());
+ }
+
+ destroyWindow(winctx);
+ }
+
public static void main(String args[]) throws IOException {
String tstname = TestGLDebug00NEWT.class.getName();
@@ -214,6 +222,7 @@ public class TestGLDebug00NEWT extends UITestCase {
recSeverity== event.getDbgSeverity() ) {
received = true;
}
+ Thread.dumpStack();
}
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLDebug01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLDebug01NEWT.java
index 05870ee0d..9a6548dd4 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLDebug01NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLDebug01NEWT.java
@@ -86,18 +86,17 @@ public class TestGLDebug01NEWT extends UITestCase {
String glDebugExt = ctx.getGLDebugMessageExtension();
System.err.println("glDebug extension: "+glDebugExt);
System.err.println("glDebug enabled: "+ctx.isGLDebugMessageEnabled());
- System.err.println("glDebug listener: "+ctx.getGLDebugListenerSize());
+ System.err.println("glDebug sync: "+ ctx.isGLDebugSynchronous());
System.err.println("context version: "+ctx.getGLVersion());
Assert.assertEquals((null == glDebugExt) ? false : enable, ctx.isGLDebugMessageEnabled());
- Assert.assertEquals(enable?1:0, ctx.getGLDebugListenerSize());
if(ctx.isGLDebugMessageEnabled() && null != dbgTstMsg && 0 <= dbgTstId) {
window.invoke(true, new GLRunnable() {
public void run(GLAutoDrawable drawable) {
drawable.getContext().glDebugMessageInsert(GL2GL3.GL_DEBUG_SOURCE_APPLICATION_ARB,
GL2GL3.GL_DEBUG_TYPE_OTHER_ARB,
dbgTstId,
- GL2GL3.GL_DEBUG_SEVERITY_MEDIUM_ARB, -1, dbgTstMsg);
+ GL2GL3.GL_DEBUG_SEVERITY_MEDIUM_ARB, dbgTstMsg);
}
});
Assert.assertEquals(true, myGLDebugListener.received());
@@ -183,6 +182,7 @@ public class TestGLDebug01NEWT extends UITestCase {
recSeverity== event.getDbgSeverity() ) {
received = true;
}
+ Thread.dumpStack();
}
}
}