How to use the Debug and Trace GL Pipeline and Debug GL Context
Jump to navigation
Jump to search
Debug and Trace GL Pipeline
class MyGLEvenListener extends GLEvenListener {
static final boolean glDebug = .. ; // enable at your leisure
static final boolean glTrace = .. ; // enable at your leisure
static boolean once = false;
public void init(GLAutoDrawable drawable) {
GL2ES2 gl2es2;
if( !once ) {
once = true;
GL gl = drawable.getGL();
if(glDebug) {
try {
// Debug ..
gl = gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Debug", null, gl, null) );
} catch (Exception e) {e.printStackTrace();}
}
if(glTrace) {
try {
// Trace ..
gl = gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Trace", null, gl, new Object[] { System.err } ) );
} catch (Exception e) {e.printStackTrace();}
}
gl2es2 = gl.getGL2ES2();
} else {
gl2es2 = drawable.getGL().getGL2ES2();
}
}
}
You also can enable 'JVM wide' DebugGL by simply setting property jogl.debug.DebugGL:
-Djogl.debug.DebugGL
This will also enable the native debug context, see below.
You also can enable 'JVM wide' TraceGL by simply setting property jogl.debug.TraceGL:
-Djogl.debug.TraceGL
Debug GL Context
If you like to use the native debug context you would need to configure the not yet natively created GLContext:
GLContext ctx = ...; // not yet natively created by 1st makeCurrent() ctx.setContextCreationFlags(GLContext.CTX_OPTION_DEBUG);
.. or using an GLAutoDrawable implementation:
GLWindow glWin = ... ; // newly create one, not yet visible glWin.setContextCreationFlags(GLContext.CTX_OPTION_DEBUG);