18#define STDCALL __stdcall
30 static const char *type_to_string(GLenum type)
33 case GL_DEBUG_TYPE_ERROR:
35 case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR:
36 return (
"Deprecated Behaviour");
37 case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR:
38 return (
"Undefined Behaviour");
39 case GL_DEBUG_TYPE_PORTABILITY:
40 return (
"Portability");
41 case GL_DEBUG_TYPE_PERFORMANCE:
42 return (
"Performance");
43 case GL_DEBUG_TYPE_OTHER:
50 static const char *source_to_string(GLenum source)
53 case GL_DEBUG_SOURCE_API:
55 case GL_DEBUG_SOURCE_WINDOW_SYSTEM:
56 return (
"Window System");
57 case GL_DEBUG_SOURCE_SHADER_COMPILER:
58 return (
"Shader Compiler");
59 case GL_DEBUG_SOURCE_THIRD_PARTY:
60 return (
"Third Party");
61 case GL_DEBUG_SOURCE_APPLICATION:
62 return (
"Application");
63 case GL_DEBUG_SOURCE_OTHER:
70 static const char *severity_to_string(GLenum severity)
73 case GL_DEBUG_SEVERITY_HIGH:
75 case GL_DEBUG_SEVERITY_MEDIUM:
77 case GL_DEBUG_SEVERITY_LOW:
85 static void STDCALL PrintMessage(GLenum source, GLenum type,
86 GLuint
id, GLenum severity, GLsizei length,
87 const GLchar *message,
const void *userParam)
90 if (type > GL_DEBUG_TYPE_PERFORMANCE)
92 Output(
"Type: %s, Source: %s, ID: %u, Severity: %s, Message: %s\n",
93 type_to_string(type), source_to_string(source),
id,
94 severity_to_string(severity), message);
101 if (!glewIsSupported(
"GL_KHR_debug")) {
102 Output(
"GL_KHR_debug is not supported; GLDebug will not work\n");
106 glEnable(GL_DEBUG_OUTPUT);
107 glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
108 glDebugMessageCallback(PrintMessage, 0);
117 if (glewIsSupported(
"GL_KHR_debug")) {
118 glDisable(GL_DEBUG_OUTPUT);
133 Output(
"GL Debug support was excluded from this build because the glLoadGen headers did not include support for it.\n");
#define STDCALL
Definition GLDebug.h:20
static void Enable()
Definition GLDebug.h:99
static void Disable()
Definition GLDebug.h:115
Definition Background.h:14
void Output(const char *message, Args... args)
Definition utils.h:41