I've been through multiple articles on enabling glDebugMessageCallback and I don't get any compile errors. However, when I run the program, I get a runtime System.AccessViolationException right on the glDebugMessageCallback call. I'm using GLEW and GLFW in my setup.
When I run GlewInfo, I can see that the debug is available:
GL_ARB_debug_output: OK
--------------------
- glDebugMessageCallbackARB: OK
- glDebugMessageControlARB: OK
- glDebugMessageInsertARB: OK
- glGetDebugMessageLogARB: OK
GL_KHR_debug: OK
-------------
- glDebugMessageCallback: OK
- glDebugMessageControl: OK
- glDebugMessageInsert: OK
- glGetDebugMessageLog: OK
- GL_KHR_no_error: MISSING
In my code, I set the glfw windows hint before creating the window:
if (get_debug_gl())
{
glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE);
}
I attempt to enable the debugging with this:
if (get_debug_gl())
{
glEnable(GL_DEBUG_OUTPUT);
if (GLEW_KHR_debug)
{
gl_log_debug("KHR_debug extension found\n");
GLDEBUGPROC p = &(debug_gl_callback);
///glDebugMessageCallback(p, NULL); /// @todo GRRRRR : this throws runtime System.AccessViolationException
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
gl_log_debug("debug callback enabled\n");
}
else if(GL_ARB_debug_output)
{
gl_log_debug("GL_ARB_debug_output extension found\n");
GLDEBUGPROC p = &(debug_gl_callback);
glDebugMessageCallbackARB(p, NULL); /// @todo GRRRRR : this throws runtime System.AccessViolationException
gl_log_debug("debug callback enabled\n");
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
}
else
{
gl_log_debug("KHR_debug extension NOT found\n");
}
}
Observations:
- GLEW_KHR_debug is false, despite the glewinfo reporting that it should be true. If I bypass it, I get the runtime error
- If I run the code through the glDebugMessageCallbackARB call, I get the same runtime error.
Can anyone out there give me a tip as to what I am missing? Writing OpenGl without messages is like driving a car with a blindfold.