How to use the Debug and Trace GL Pipeline and Debug GL Context: Difference between revisions
Jump to navigation
Jump to search
(Created page with '== Debug GL Pipeline == <pre> class MyGLEvenListener extends GLEvenListener { static boolean once = false; public void init(GLAutoDrawable drawable) { GL2ES2 gl2es2; …') |
No edit summary |
||
Line 1: | Line 1: | ||
== Debug GL Pipeline == | == Debug and Trace GL Pipeline == | ||
<pre> | <pre> | ||
class MyGLEvenListener extends GLEvenListener { | class MyGLEvenListener extends GLEvenListener { | ||
static final boolean glDebug = .. ; // enable at your leisure | |||
static final boolean glTrace = .. ; // enable at your leisure | |||
static boolean once = false; | static boolean once = false; | ||
Line 11: | Line 14: | ||
once = true; | once = true; | ||
GL gl = drawable.getGL(); | GL gl = drawable.getGL(); | ||
gl = gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Debug", null, gl, null) ); | |||
if(glDebug) { | |||
try { | |||
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(); | gl2es2 = gl.getGL2ES2(); | ||
} else { | } else { | ||
Line 27: | Line 43: | ||
This will also enable the native debug context, see below. | This will also enable the native debug context, see below. | ||
You also can enable 'JVM wide' TraceGL by simply setting property <code>jogl.debug.TraceGL</code>: | |||
<pre> | |||
-Djogl.debug.TraceGL | |||
</pre> | |||
== Debug GL Context == | == Debug GL Context == |
Revision as of 10:58, 20 December 2013
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 { 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);