GL Debug Output

From JogampWiki
Jump to: navigation, search

Debug Output is an OpenGL feature that makes Error Checking from functions easier.

In order to get more information about Debug Output, you can read the main opengl wiki page. You should read that first before continuing.

The difference with plain OpenGL is that in Jogl, if you want to enable Debug Output, you have to do it at the begin, before the context gets created.

There are two tests in jogl-demos, that show how you can achieve this:

There is also a sample, gl-420-debug-output from the jogl-samples that it is interesting to take a look at. Indeed, once enabled from the startup, there are different way you can turn it on/off. First of all, you should be aware that there are now two ways of affecting the debut, one is acting directly on jogl, the other is setting directly OpenGL through opengl calls. You can now enable/disable Debug Output using either:

 glWindow.getContext().enableGLDebugMessage(true/false);
 gl4.glEnable/Disable(GL_DEBUG_OUTPUT);

Same for setting the synchronous option:

glWindow.getContext().setGLDebugSynchronous(true/false);
gl4.glEnable/Disable(GL_DEBUG_OUTPUT_SYNCHRONOUS);

Control the messages:

glWindow.getContext().glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, null, 0, true);
gl4.glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, null, 0, true);

Or insert them:

 glWindow.getContext().glDebugMessageInsert(
                   GL_DEBUG_SOURCE_APPLICATION,
                   GL_DEBUG_TYPE_OTHER, 1,
                   GL_DEBUG_SEVERITY_MEDIUM,
                   "Message");
 gl4.glDebugMessageInsert(
                   GL_DEBUG_SOURCE_APPLICATION,
                   GL_DEBUG_TYPE_OTHER, 1,
                   GL_DEBUG_SEVERITY_MEDIUM,
                   message1.length(), message1);

Anyway it is also important to mention that, of course, OpenGL settings have the priority over the Jogl's one. You should always be coherent with the way you took.