From 900ac9dd13a732474642fa135b13350f8ddd01b0 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 30 Sep 2011 21:32:46 +0200 Subject: GLContext/GLDebugMessageHandler: Fix/clarify init and usage of dbg handler --- src/jogl/classes/jogamp/opengl/GLContextImpl.java | 12 +++++++++--- src/jogl/classes/jogamp/opengl/GLDebugMessageHandler.java | 14 +++++++++++++- 2 files changed, 22 insertions(+), 4 deletions(-) (limited to 'src/jogl/classes/jogamp/opengl') diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index 6f2786b03..99693aabe 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -380,7 +380,10 @@ public abstract class GLContextImpl extends GLContext { if (null == getGLDrawable().getChosenGLCapabilities()) { throw new GLException("drawable has no chosen GLCapabilities: "+getGLDrawable()); } - additionalCtxCreationFlags |= DEBUG_GL ? GLContext.CTX_OPTION_DEBUG : 0 ; + if(DEBUG_GL) { + // only impacts w/ createContextARB(..) + additionalCtxCreationFlags |= GLContext.CTX_OPTION_DEBUG ; + } } lockConsiderFailFast(); @@ -408,14 +411,17 @@ public abstract class GLContextImpl extends GLContext { // throws an GLException if not getGLDrawable().getGLProfile().verifyEquality(gl.getGLProfile()); + glDebugHandler.init( isGL2GL3() && isGLDebugEnabled() ); + if(DEBUG_GL) { gl = gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Debug", null, gl, null) ); - glDebugHandler.addListener(new GLDebugMessageHandler.StdErrGLDebugListener(true)); + if(glDebugHandler.isEnabled()) { + 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 } ) ); } - glDebugHandler.init(0 != (additionalCtxCreationFlags & GLContext.CTX_OPTION_DEBUG)); } /* FIXME: refactor dependence on Java 2D / JOGL bridge diff --git a/src/jogl/classes/jogamp/opengl/GLDebugMessageHandler.java b/src/jogl/classes/jogamp/opengl/GLDebugMessageHandler.java index 9ca573536..8ca0c016d 100644 --- a/src/jogl/classes/jogamp/opengl/GLDebugMessageHandler.java +++ b/src/jogl/classes/jogamp/opengl/GLDebugMessageHandler.java @@ -99,9 +99,14 @@ public class GLDebugMessageHandler { } public void init(boolean enable) { + if(DEBUG) { + System.err.println("GLDebugMessageHandler.init("+enable+")"); + } init(); if(isAvailable()) { enableImpl(enable); + } else if(DEBUG) { + System.err.println("GLDebugMessageHandler.init("+enable+") .. n/a"); } } @@ -111,6 +116,13 @@ public class GLDebugMessageHandler { return; } + if( !ctx.isGLDebugEnabled() ) { + if(DEBUG) { + System.err.println("GLDebugMessageHandler: GL DEBUG not set in ARB ctx options: "+ctx.getGLVersion()); + } + return; + } + if( ctx.isExtensionAvailable(GL_ARB_debug_output) ) { extName = GL_ARB_debug_output; extType = EXT_ARB; @@ -124,7 +136,7 @@ public class GLDebugMessageHandler { if(0 == extType) { if(DEBUG) { - System.err.println("GLDebugMessageHandler: No extension available!"); + System.err.println("GLDebugMessageHandler: No extension available! "+ctx.getGLVersion()); } return; } -- cgit v1.2.3