From: John Tsiombikas Date: Mon, 22 Jan 2018 12:45:15 +0000 (-0800) Subject: Merge branch 'master' of goat:git/laserbrain_demo X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=laserbrain_demo;a=commitdiff_plain;h=794a378d5c8e07c815814324da8142be137406d0 Merge branch 'master' of goat:git/laserbrain_demo --- 794a378d5c8e07c815814324da8142be137406d0 diff --cc src/opengl.c index 0000000,9fe7ea3..796144c mode 000000,100644..100644 --- a/src/opengl.c +++ b/src/opengl.c @@@ -1,0 -1,104 +1,106 @@@ + #include "opengl.h" + #include "logger.h" + -static void gldebug_logger(unsigned int src, unsigned int type, unsigned int id, - unsigned int severity, int len, const char *msg, const void *cls); ++ ++static void GLAPIENTRY gldebug_logger(GLenum src, GLenum type, GLuint id, GLenum severity, ++ GLsizei len, const char *msg, const void *cls); ++ + static const char *gldebug_srcstr(unsigned int src); + static const char *gldebug_typestr(unsigned int type); + static const char *gldebug_sevstr(unsigned int sev); + + struct GLCaps glcaps; + + int init_opengl(void) + { + glewInit(); + + glcaps.debug = GLEW_ARB_debug_output; + + #ifndef NDEBUG + if(glcaps.debug) { + info_log("Installing OpenGL debug callback\n"); + glDebugMessageCallback(gldebug_logger, 0); + } + #endif + + return 0; + } + + -static void gldebug_logger(unsigned int src, unsigned int type, unsigned int id, - unsigned int severity, int len, const char *msg, const void *cls) ++static void GLAPIENTRY gldebug_logger(GLenum src, GLenum type, GLuint id, GLenum severity, ++ GLsizei len, const char *msg, const void *cls) + { + static const char *fmt = "[GLDEBUG] (%s) %s: %s\n"; + switch(type) { + case GL_DEBUG_TYPE_ERROR: + error_log(fmt, gldebug_srcstr(src), gldebug_typestr(type), msg); + break; + + case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR: + case GL_DEBUG_TYPE_PORTABILITY: + case GL_DEBUG_TYPE_PERFORMANCE: + warning_log(fmt, gldebug_srcstr(src), gldebug_typestr(type), msg); + break; + + default: + debug_log(fmt, gldebug_srcstr(src), gldebug_typestr(type), msg); + } + } + + static const char *gldebug_srcstr(unsigned int src) + { + switch(src) { + case GL_DEBUG_SOURCE_API: + return "api"; + case GL_DEBUG_SOURCE_WINDOW_SYSTEM: + return "wsys"; + case GL_DEBUG_SOURCE_SHADER_COMPILER: + return "sdrc"; + case GL_DEBUG_SOURCE_THIRD_PARTY: + return "3rdparty"; + case GL_DEBUG_SOURCE_APPLICATION: + return "app"; + case GL_DEBUG_SOURCE_OTHER: + return "other"; + default: + break; + } + return "unknown"; + } + + static const char *gldebug_typestr(unsigned int type) + { + switch(type) { + case GL_DEBUG_TYPE_ERROR: + return "error"; + case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR: + return "deprecated"; + case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR: + return "undefined behavior"; + case GL_DEBUG_TYPE_PORTABILITY: + return "portability warning"; + case GL_DEBUG_TYPE_PERFORMANCE: + return "performance warning"; + case GL_DEBUG_TYPE_OTHER: + return "other"; + default: + break; + } + return "unknown"; + } + + static const char *gldebug_sevstr(unsigned int sev) + { + switch(sev) { + case GL_DEBUG_SEVERITY_HIGH: + return "high"; + case GL_DEBUG_SEVERITY_MEDIUM: + return "medium"; + case GL_DEBUG_SEVERITY_LOW: + return "low"; + default: + break; + } + return "unknown"; + }