Reviewed latest PR formatting and details
This commit is contained in:
parent
9f2ff3e4d6
commit
719c1551cc
3 changed files with 45 additions and 31 deletions
|
@ -85,7 +85,7 @@
|
|||
// Module: rlgl - Configuration values
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
// Enable OpenGL Debug Context (only OpenGL 4.3)
|
||||
// Enable OpenGL Debug Context (only available on OpenGL 4.3)
|
||||
//#define RLGL_ENABLE_OPENGL_DEBUG_CONTEXT 1
|
||||
|
||||
// Show OpenGL extensions and capabilities detailed logs on init
|
||||
|
|
|
@ -3858,7 +3858,6 @@ static bool InitGraphicsDevice(int width, int height)
|
|||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); // Choose OpenGL minor version (just hint)
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_FALSE);
|
||||
|
||||
#if defined(RLGL_ENABLE_OPENGL_DEBUG_CONTEXT)
|
||||
glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GLFW_TRUE); // Enable OpenGL Debug Context
|
||||
#endif
|
||||
|
|
33
src/rlgl.h
33
src/rlgl.h
|
@ -42,6 +42,8 @@
|
|||
* #define RLGL_SHOW_GL_DETAILS_INFO
|
||||
* Show OpenGL extensions and capabilities detailed logs on init
|
||||
*
|
||||
* #define RLGL_ENABLE_OPENGL_DEBUG_CONTEXT
|
||||
* Enable debug context (only available on OpenGL 4.3)
|
||||
*
|
||||
* rlgl capabilities could be customized just defining some internal
|
||||
* values before library inclusion (default values listed):
|
||||
|
@ -1800,12 +1802,18 @@ void rlSetBlendFactors(int glSrcFactor, int glDstFactor, int glEquation)
|
|||
//----------------------------------------------------------------------------------
|
||||
// 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;
|
||||
// Ignore non-significant error/warning codes (NVidia drivers)
|
||||
// NOTE: Here there are the details with a sample output:
|
||||
// - #131169 - Framebuffer detailed info: The driver allocated storage for renderbuffer 2. (severity: low)
|
||||
// - #131185 - Buffer detailed info: Buffer object 1 (bound to GL_ELEMENT_ARRAY_BUFFER_ARB, usage hint is GL_ENUM_88e4)
|
||||
// will use VIDEO memory as the source for buffer object operations. (severity: low)
|
||||
// - #131218 - Program/shader state performance warning: Vertex shader in program 7 is being recompiled based on GL state. (severity: medium)
|
||||
// - #131204 - Texture state usage warning: The texture object (0) bound to texture image unit 0 does not have
|
||||
// a defined base level and cannot be used for texture mapping. (severity: low)
|
||||
if ((id == 131169) || (id == 131185) || (id == 131218) || (id == 131204)) return;
|
||||
|
||||
const char *msgSource = NULL;
|
||||
switch (source)
|
||||
|
@ -1816,6 +1824,7 @@ static void GLAPIENTRY rlDebugMessageCallback(GLenum source, GLenum type, GLuint
|
|||
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;
|
||||
default: break;
|
||||
}
|
||||
|
||||
const char *msgType = NULL;
|
||||
|
@ -1830,6 +1839,7 @@ static void GLAPIENTRY rlDebugMessageCallback(GLenum source, GLenum type, GLuint
|
|||
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;
|
||||
default: break;
|
||||
}
|
||||
|
||||
const char *msgSeverity = "DEFAULT";
|
||||
|
@ -1839,9 +1849,13 @@ static void GLAPIENTRY rlDebugMessageCallback(GLenum source, GLenum type, GLuint
|
|||
case GL_DEBUG_SEVERITY_MEDIUM: msgSeverity = "MEDIUM"; break;
|
||||
case GL_DEBUG_SEVERITY_HIGH: msgSeverity = "HIGH"; break;
|
||||
case GL_DEBUG_SEVERITY_NOTIFICATION: msgSeverity = "NOTIFICATION"; break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
TRACELOG(LOG_WARNING, "OpenGL Debug Message: %s, type = %s, source = %s, severity = %s", message, msgType, msgSource, msgSeverity);
|
||||
TRACELOG(LOG_WARNING, "GL: OpenGL debug message: %s", message);
|
||||
TRACELOG(LOG_WARNING, " > Type: %s", msgType);
|
||||
TRACELOG(LOG_WARNING, " > Source = %s", msgSource);
|
||||
TRACELOG(LOG_WARNING, " > Severity = %s", msgSeverity);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1852,15 +1866,16 @@ static void GLAPIENTRY rlDebugMessageCallback(GLenum source, GLenum type, GLuint
|
|||
// Initialize rlgl: OpenGL extensions, default buffers/shaders/textures, OpenGL states
|
||||
void rlglInit(int width, int height)
|
||||
{
|
||||
// Enable OpenGL Debug Context
|
||||
// Enable OpenGL debug context if required
|
||||
#if defined(RLGL_ENABLE_OPENGL_DEBUG_CONTEXT) && defined(GRAPHICS_API_OPENGL_43)
|
||||
if (glDebugMessageCallback != NULL && glDebugMessageControl != NULL)
|
||||
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
|
||||
// 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.
|
||||
// Debug context options:
|
||||
// - 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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue