LWJGL3 4.3 debugging. How do I get the message?

Started by asyx, March 11, 2015, 15:36:19

Previous topic - Next topic

asyx

Hello!

With LWJGL 2.x, you'd get a string as a parameter in the invoke method. But now, the invoke method looks like this

public void invoke(int source, int type, int id, int severity, int length, long message, long userParam)


So, how do I get the message, as a string, from the pointer I've got here?

spasi

Hey asyx,

You can get a Java String like this:

import static org.lwjgl.system.MemoryUtil.*;
// ...
String msg = memDecodeUTF8(memByteBuffer(message, length));


If you would simply like to print the error message, see the setupDebugMessageCallback method on GLContext, e.g.:

debugProc = GLContext.createFromCurrent().setupDebugMessageCallback();

It will also choose the best debug output implementation available (from GL43, KHR_debug, ARB_debug_output, AMD_debug_output).

asyx


doev

Quote from: spasi on March 11, 2015, 17:11:17
If you would simply like to print the error message, see the setupDebugMessageCallback method on GLContext, e.g.:

debugProc = GLContext.createFromCurrent().setupDebugMessageCallback();

It will also choose the best debug output implementation available (from GL43, KHR_debug, ARB_debug_output, AMD_debug_output).

This is not working anymore (3.0.0b_build35), cause "GLContext" is not available. What is the recommend way to switch on opengl error/debug messages?

spasi

The setupDebugMessageCallback methods have moved to the GLUtil class:

GL.createCapabilities();
debugProc = GLUtil.setupDebugMessageCallback();

FortressBuilder

With the latest nightly builds you can also use the getMessage utility method inside GLDebugMessageCallback.

String msg = getMessage(length, message);