Reviewed OpenGL Debug Context
This commit is contained in:
parent
44382cec4d
commit
e4c6cc66cf
|
|
@ -84,6 +84,10 @@
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
// Module: rlgl - Configuration values
|
// Module: rlgl - Configuration values
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Enable OpenGL Debug Context (only OpenGL 4.3)
|
||||||
|
//#define RLGL_ENABLE_OPENGL_DEBUG_CONTEXT 1
|
||||||
|
|
||||||
// Show OpenGL extensions and capabilities detailed logs on init
|
// Show OpenGL extensions and capabilities detailed logs on init
|
||||||
//#define RLGL_SHOW_GL_DETAILS_INFO 1
|
//#define RLGL_SHOW_GL_DETAILS_INFO 1
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -498,9 +498,7 @@ typedef enum {
|
||||||
FLAG_WINDOW_TRANSPARENT = 0x00000010, // Set to allow transparent framebuffer
|
FLAG_WINDOW_TRANSPARENT = 0x00000010, // Set to allow transparent framebuffer
|
||||||
FLAG_WINDOW_HIGHDPI = 0x00002000, // Set to support HighDPI
|
FLAG_WINDOW_HIGHDPI = 0x00002000, // Set to support HighDPI
|
||||||
FLAG_MSAA_4X_HINT = 0x00000020, // Set to try enabling MSAA 4X
|
FLAG_MSAA_4X_HINT = 0x00000020, // Set to try enabling MSAA 4X
|
||||||
FLAG_INTERLACED_HINT = 0x00010000, // Set to try enabling interlaced video format (for V3D)
|
FLAG_INTERLACED_HINT = 0x00010000 // Set to try enabling interlaced video format (for V3D)
|
||||||
FLAG_OPENGL_DEBUG = 0x00004000, // Set to support GL_DEBUG_OUTPUT - Faster version but not useful for breakpoints
|
|
||||||
FLAG_OPENGL_DEBUG_SYNC = 0x00008000 // Set to support GL_DEBUG_OUTPUT_SYNCHRONOUS - 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.
|
|
||||||
} ConfigFlags;
|
} ConfigFlags;
|
||||||
|
|
||||||
// Trace log level
|
// Trace log level
|
||||||
|
|
|
||||||
69
src/rcore.c
69
src/rcore.c
|
|
@ -3708,49 +3708,6 @@ int GetTouchPointCount(void)
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Module specific Functions Definition
|
// Module specific Functions Definition
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
#if defined(GRAPHICS_API_OPENGL_43) && defined(PLATFORM_DESKTOP)
|
|
||||||
static void GLAPIENTRY DebugMessageCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, const void* user_param)
|
|
||||||
{
|
|
||||||
// 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 // GRAPHICS_API_OPENGL_43 && PLATFORM_DESKTOP
|
|
||||||
|
|
||||||
// Initialize display device and framebuffer
|
// Initialize display device and framebuffer
|
||||||
// NOTE: width and height represent the screen (framebuffer) desired size, not actual display size
|
// NOTE: width and height represent the screen (framebuffer) desired size, not actual display size
|
||||||
|
|
@ -3902,13 +3859,9 @@ static bool InitGraphicsDevice(int width, int height)
|
||||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||||
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_FALSE);
|
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_FALSE);
|
||||||
|
|
||||||
#if defined(GRAPHICS_API_OPENGL_43) && defined(PLATFORM_DESKTOP)
|
#if defined(RLGL_ENABLE_OPENGL_DEBUG_CONTEXT)
|
||||||
// Enable OpenGl Debug Context
|
glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GLFW_TRUE); // Enable OpenGL Debug Context
|
||||||
if ((CORE.Window.flags & FLAG_OPENGL_DEBUG) || (CORE.Window.flags & FLAG_OPENGL_DEBUG_SYNC))
|
#endif
|
||||||
{
|
|
||||||
glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GLFW_TRUE);
|
|
||||||
}
|
|
||||||
#endif // GRAPHICS_API_OPENGL_43 && PLATFORM_DESKTOP
|
|
||||||
}
|
}
|
||||||
else if (rlGetVersion() == OPENGL_ES_20) // Request OpenGL ES 2.0 context
|
else if (rlGetVersion() == OPENGL_ES_20) // Request OpenGL ES 2.0 context
|
||||||
{
|
{
|
||||||
|
|
@ -4459,22 +4412,6 @@ static bool InitGraphicsDevice(int width, int height)
|
||||||
rlLoadExtensions(eglGetProcAddress);
|
rlLoadExtensions(eglGetProcAddress);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(GRAPHICS_API_OPENGL_43) && defined(PLATFORM_DESKTOP)
|
|
||||||
if (glDebugMessageCallback != NULL && glDebugMessageControl != NULL)
|
|
||||||
{
|
|
||||||
if ((CORE.Window.flags & FLAG_OPENGL_DEBUG) || (CORE.Window.flags & FLAG_OPENGL_DEBUG_SYNC))
|
|
||||||
{
|
|
||||||
glDebugMessageCallback(DebugMessageCallback, 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);
|
|
||||||
if (CORE.Window.flags & FLAG_OPENGL_DEBUG_SYNC) glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int fbWidth = CORE.Window.screen.width;
|
int fbWidth = CORE.Window.screen.width;
|
||||||
int fbHeight = CORE.Window.screen.height;
|
int fbHeight = CORE.Window.screen.height;
|
||||||
|
|
||||||
|
|
|
||||||
62
src/rlgl.h
62
src/rlgl.h
|
|
@ -1797,6 +1797,54 @@ void rlSetBlendFactors(int glSrcFactor, int glDstFactor, int glEquation)
|
||||||
#endif
|
#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
|
// 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
|
// Initialize rlgl: OpenGL extensions, default buffers/shaders/textures, OpenGL states
|
||||||
void rlglInit(int width, int height)
|
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)
|
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
|
||||||
// Init default white texture
|
// Init default white texture
|
||||||
unsigned char pixels[4] = { 255, 255, 255, 255 }; // 1 pixel RGBA (4 bytes)
|
unsigned char pixels[4] = { 255, 255, 255, 255 }; // 1 pixel RGBA (4 bytes)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user