0

I am trying to use the ARB_debug_output extension but I cannot get any output from it (intentionally incorrect shaders will not cause debug output). I'm guessing I have made a mistake using the extension.

I have set up my context with debug enabled using;

        ContextAttribs contextAtrributes = new ContextAttribs(3, 2) // Core OpenGL version 3.2
        .withForwardCompatible(true)
        .withProfileCore(true)
        .withDebug(true);

I check for the debug output extension using;

            ContextCapabilities caps = GLContext.getCapabilities();
        if ( caps.OpenGL32 )
            System.out.println("OpenGL version 3.2 supported");
        if ( caps.GL_ARB_debug_output )
            System.out.println("ARB_debug_output extension supported");

Which gives the following output;

OpenGL version 3.2 supported
ARB_debug_output extension supported

I setup a callback function to print the debug output using;

new ARBDebugOutputCallback();

After this I run my program using incorrect/wrong shaders etc that produce compiler/linker errors using glGetShaderInfoLog and glGetError but I do not receive debug information from the callback function.

2 Answers 2

3

You need to pass the ARBDebugOutputCallback instance to the glDebugMessageCallbackARB method, like so:

glDebugMessageCallbackARB(new ARBDebugOutputCallback());

This is equivalent to passing a function pointer in the C API.

Note that there is no userParam argument; it is used internally by LWJGL to implement ARB_debug_output properly when there are multiple OpenGL contexts present. It's not necessary in Java anyway, you can pass per-instance data using the ARBDebugOutputCallback(Handler) constructor.

0
2

I am unfamiliar with LWJGL, but I am very familiar with this extension... setting the callback is insufficient to have it produce any output. You also need to specify which types of events you are interested in, the severities, and sources.

From the C bindings for OpenGL, a call like this would be necessary to enable generation of output messages:

glDebugMessageControlARB (GL_DONT_CARE,GL_DONT_CARE,GL_DONT_CARE,0,NULL,GL_TRUE);

In short, this enables messages for all sources, severities and types. This will make your debug output as verbose as your implementation can possibly give you.

Another thing you might consider is:

glEnable (GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);

This may increase overhead, but will output debug information immediately instead of buffering it and flushing periodically. This is very useful for diagnosing application terminating events.


I have an example of all of these things in action in an answer I wrote a while back, you may find some of the code (even though it is for C) useful.

5
  • Thanks for the answer, I looked for the glDebugMessageControlARB method and found it as a static method of a class called ARBDebugOutput, so I gave it a call with the parameters you specified however, still no output. Is there usually output without having an actual error (just so I know I don't have to break my shaders every time I want to test)? I can't find much documentation for extensions and lwjgl. Nov 3, 2013 at 9:36
  • @KierenAnderson: It is highly implementation (driver) specific. Many will generate performance warnings if you do something like call glDrawElements (...) using GL_UNSIGNED_BYTE for the index type (which is not technically an error). If you want to test it, one thing that is almost sure to generate an error is if you call glEnd (...), since you are using a core profile context - it should give you a deprecation error. Nov 3, 2013 at 9:42
  • I have to wonder if simply constructing a ARBDebugOutputCallback object is sufficient to use this as well. Because there is another API call: glDebugMessageCallbackARB (...) in the C-based OpenGL API that is necessary. Nov 3, 2013 at 9:45
  • 1
    From reading the documentation for the ARBDebugOutputCallback class I got the impression that it was handling all of this. lwjgl.org/javadoc/org/lwjgl/opengl/ARBDebugOutputCallback.html Nov 3, 2013 at 9:52
  • +1 given to the answer you provided "a while back", @AndonM.Coleman. Thanks.
    – bvj
    Aug 25, 2014 at 19:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.