|
|
@ -1797,6 +1797,54 @@ void rlSetBlendFactors(int glSrcFactor, int glDstFactor, int glEquation) |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------- |
|
|
|
// Module Functions Definition - OpenGL Debug |
|
|
|
//---------------------------------------------------------------------------------- |
|
|
|
|
|
|
|
#if defined(RLGL_ENABLE_OPENGL_DEBUG_CONTEXT) && defined(GRAPHICS_API_OPENGL_43) |
|
|
|
static void GLAPIENTRY rlDebugMessageCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const void *userParam) |
|
|
|
{ |
|
|
|
// ignore non-significant error/warning codes |
|
|
|
if (id == 131169 || id == 131185 || id == 131218 || id == 131204) return; |
|
|
|
|
|
|
|
const char *msgSource = NULL; |
|
|
|
switch (source) |
|
|
|
{ |
|
|
|
case GL_DEBUG_SOURCE_API: msgSource = "API"; break; |
|
|
|
case GL_DEBUG_SOURCE_WINDOW_SYSTEM: msgSource = "WINDOW_SYSTEM"; break; |
|
|
|
case GL_DEBUG_SOURCE_SHADER_COMPILER: msgSource = "SHADER_COMPILER"; break; |
|
|
|
case GL_DEBUG_SOURCE_THIRD_PARTY: msgSource = "THIRD_PARTY"; break; |
|
|
|
case GL_DEBUG_SOURCE_APPLICATION: msgSource = "APPLICATION"; break; |
|
|
|
case GL_DEBUG_SOURCE_OTHER: msgSource = "OTHER"; break; |
|
|
|
} |
|
|
|
|
|
|
|
const char *msgType = NULL; |
|
|
|
switch (type) |
|
|
|
{ |
|
|
|
case GL_DEBUG_TYPE_ERROR: msgType = "ERROR"; break; |
|
|
|
case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR: msgType = "DEPRECATED_BEHAVIOR"; break; |
|
|
|
case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR: msgType = "UNDEFINED_BEHAVIOR"; break; |
|
|
|
case GL_DEBUG_TYPE_PORTABILITY: msgType = "PORTABILITY"; break; |
|
|
|
case GL_DEBUG_TYPE_PERFORMANCE: msgType = "PERFORMANCE"; break; |
|
|
|
case GL_DEBUG_TYPE_MARKER: msgType = "MARKER"; break; |
|
|
|
case GL_DEBUG_TYPE_PUSH_GROUP: msgType = "PUSH_GROUP"; break; |
|
|
|
case GL_DEBUG_TYPE_POP_GROUP: msgType = "POP_GROUP"; break; |
|
|
|
case GL_DEBUG_TYPE_OTHER: msgType = "OTHER"; break; |
|
|
|
} |
|
|
|
|
|
|
|
const char *msgSeverity = "DEFAULT"; |
|
|
|
switch (severity) |
|
|
|
{ |
|
|
|
case GL_DEBUG_SEVERITY_LOW: msgSeverity = "LOW"; break; |
|
|
|
case GL_DEBUG_SEVERITY_MEDIUM: msgSeverity = "MEDIUM"; break; |
|
|
|
case GL_DEBUG_SEVERITY_HIGH: msgSeverity = "HIGH"; break; |
|
|
|
case GL_DEBUG_SEVERITY_NOTIFICATION: msgSeverity = "NOTIFICATION"; break; |
|
|
|
} |
|
|
|
|
|
|
|
TRACELOG(LOG_WARNING, "OpenGL Debug Message: %s, type = %s, source = %s, severity = %s", message, msgType, msgSource, msgSeverity); |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------- |
|
|
|
// Module Functions Definition - rlgl functionality |
|
|
|
//---------------------------------------------------------------------------------- |
|
|
@ -1804,6 +1852,20 @@ void rlSetBlendFactors(int glSrcFactor, int glDstFactor, int glEquation) |
|
|
|
// Initialize rlgl: OpenGL extensions, default buffers/shaders/textures, OpenGL states |
|
|
|
void rlglInit(int width, int height) |
|
|
|
{ |
|
|
|
// Enable OpenGL Debug Context |
|
|
|
#if defined(RLGL_ENABLE_OPENGL_DEBUG_CONTEXT) && defined(GRAPHICS_API_OPENGL_43) |
|
|
|
if (glDebugMessageCallback != NULL && glDebugMessageControl != NULL) |
|
|
|
{ |
|
|
|
glDebugMessageCallback(rlDebugMessageCallback, 0); |
|
|
|
// glDebugMessageControl(GL_DEBUG_SOURCE_API, GL_DEBUG_TYPE_ERROR, GL_DEBUG_SEVERITY_HIGH, 0, 0, GL_TRUE); // TODO: filter message |
|
|
|
|
|
|
|
// GL_DEBUG_OUTPUT - Faster version but not useful for breakpoints |
|
|
|
// GL_DEBUG_OUTPUT_SYNCHRONUS - Callback is in sync with errors, so a breakpoint can be placed on the callback in order to get a stacktrace for the GL error. |
|
|
|
glEnable(GL_DEBUG_OUTPUT); |
|
|
|
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS); |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
|
|
// Init default white texture |
|
|
|
unsigned char pixels[4] = { 255, 255, 255, 255 }; // 1 pixel RGBA (4 bytes) |
|
|
|