Skip to content

[rlgl][rcore] Add runtime FLAG_GL_CONTEXT_DEBUG config flag - #6442

Closed
jestarray wants to merge 1 commit into
raysan5:masterfrom
jestarray:feat/gl-debug-context-flag
Closed

jestarray wants to merge 1 commit into
raysan5:masterfrom
jestarray:feat/gl-debug-context-flag

Conversation

@jestarray

Copy link
Copy Markdown
Contributor

Summary

Replaces the compile-time RLGL_ENABLE_OPENGL_DEBUG_CONTEXT option with a runtime
FLAG_GL_CONTEXT_DEBUG config flag, so applications can request an OpenGL debug
context at InitWindow() without rebuilding raylib.

Changes

  • Added FLAG_GL_CONTEXT_DEBUG (0x00020000) to ConfigFlags.
  • Requests a debug context on all platform backends: GLFW, SDL2/SDL3, RGFW,
    Win32 (WGL), Android, DRM and Web. The WebGL hint is ignored by browsers.
  • Added rlEnableDebugContext() to register the debug callback and enable
    synchronous debug output.
  • rlglInit() checks GL_CONTEXT_FLAGS for GL_CONTEXT_FLAG_DEBUG_BIT and
    enables debug output automatically when the created context is a debug context.
  • Uses core debug output (glDebugMessageCallback / GL_DEBUG_OUTPUT) on
    OpenGL 4.3+, and GL_ARB_debug_output on OpenGL 3.3.
  • Enables GL_DEBUG_OUTPUT only on the core 4.3 path. The token is not part of
    GL_ARB_debug_output and raised GL_INVALID_ENUM on ARB-only contexts.
  • Skips the GL_CONTEXT_FLAGS query on OpenGL 2.1 builds, where the token is
    not available.
  • Removed RLGL_ENABLE_OPENGL_DEBUG_CONTEXT from config.h.

Usage

SetConfigFlags(FLAG_GL_CONTEXT_DEBUG);
InitWindow(width, height, "title");

- Add FLAG_GL_CONTEXT_DEBUG to request an OpenGL debug context at InitWindow(), replacing the compile-time RLGL_ENABLE_OPENGL_DEBUG_CONTEXT option that was gated to OpenGL 4.3
- Request a debug context on all platform backends: GLFW, SDL, RGFW, Win32, Android, DRM and Web
- Add rlEnableDebugContext() and automatically register the debug callback when the created context exposes GL_CONTEXT_FLAG_DEBUG_BIT
- Use core debug output on OpenGL 4.3+ and GL_ARB_debug_output on OpenGL 3.3
- Enable GL_DEBUG_OUTPUT only on the core OpenGL 4.3 path; the token is not part of GL_ARB_debug_output
- Skip the GL_CONTEXT_FLAGS query on OpenGL 2.1 builds, where the token is not available
@raysan5

raysan5 commented Nov 23, 2026 •

Copy link
Copy Markdown
Owner

@jestarray Thanks but I prefer to keep it as a build flag for users with that very specific need. Also, raylib does not expose directly any graphics API specific flag.

@raysan5 raysan5 closed this Nov 23, 2026
@jestarray

jestarray commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor Author

There are a few problems keeping it behind RLGL_ENABLE_OPENGL_DEBUG_CONTEXT build flag.

  • It's unnecessarily gated to opengl4.3+, when <=opengl3.3 can support it with common arb extensions
  • Requires messing with the build system

I personally prefer it being a ConfigFlag because users who don't need this functionality can simply ignore the flag. Existing applications remain unaffected, and those who do need it no longer have to maintain a custom raylib build.

RLGL_ENABLE_OPENGL_DEBUG_CONTEXT should be upgraded to support <=opengl3.3 with extensions then 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants