4 static void gldebug_logger(unsigned int src, unsigned int type, unsigned int id,
5 unsigned int severity, int len, const char *msg, const void *cls);
6 static const char *gldebug_srcstr(unsigned int src);
7 static const char *gldebug_typestr(unsigned int type);
8 static const char *gldebug_sevstr(unsigned int sev);
16 glcaps.debug = GLEW_ARB_debug_output;
20 info_log("Installing OpenGL debug callback\n");
21 glDebugMessageCallback(gldebug_logger, 0);
29 static void gldebug_logger(unsigned int src, unsigned int type, unsigned int id,
30 unsigned int severity, int len, const char *msg, const void *cls)
32 static const char *fmt = "[GLDEBUG] (%s) %s: %s\n";
34 case GL_DEBUG_TYPE_ERROR:
35 error_log(fmt, gldebug_srcstr(src), gldebug_typestr(type), msg);
38 case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR:
39 case GL_DEBUG_TYPE_PORTABILITY:
40 case GL_DEBUG_TYPE_PERFORMANCE:
41 warning_log(fmt, gldebug_srcstr(src), gldebug_typestr(type), msg);
45 debug_log(fmt, gldebug_srcstr(src), gldebug_typestr(type), msg);
49 static const char *gldebug_srcstr(unsigned int src)
52 case GL_DEBUG_SOURCE_API:
54 case GL_DEBUG_SOURCE_WINDOW_SYSTEM:
56 case GL_DEBUG_SOURCE_SHADER_COMPILER:
58 case GL_DEBUG_SOURCE_THIRD_PARTY:
60 case GL_DEBUG_SOURCE_APPLICATION:
62 case GL_DEBUG_SOURCE_OTHER:
70 static const char *gldebug_typestr(unsigned int type)
73 case GL_DEBUG_TYPE_ERROR:
75 case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR:
77 case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR:
78 return "undefined behavior";
79 case GL_DEBUG_TYPE_PORTABILITY:
80 return "portability warning";
81 case GL_DEBUG_TYPE_PERFORMANCE:
82 return "performance warning";
83 case GL_DEBUG_TYPE_OTHER:
91 static const char *gldebug_sevstr(unsigned int sev)
94 case GL_DEBUG_SEVERITY_HIGH:
96 case GL_DEBUG_SEVERITY_MEDIUM:
98 case GL_DEBUG_SEVERITY_LOW: