Enable OpenGL debug messages if supported. */
| 427 | |
| 428 | /** Enable OpenGL debug messages if supported. */ |
| 429 | void SetupDebugOutput() |
| 430 | { |
| 431 | #ifndef NO_DEBUG_MESSAGES |
| 432 | if (_debug_driver_level < 6) return; |
| 433 | |
| 434 | if (IsOpenGLVersionAtLeast(4, 3)) { |
| 435 | BindGLProc(_glDebugMessageControl, "glDebugMessageControl"); |
| 436 | BindGLProc(_glDebugMessageCallback, "glDebugMessageCallback"); |
| 437 | } else if (IsOpenGLExtensionSupported("GL_ARB_debug_output")) { |
| 438 | BindGLProc(_glDebugMessageControl, "glDebugMessageControlARB"); |
| 439 | BindGLProc(_glDebugMessageCallback, "glDebugMessageCallbackARB"); |
| 440 | } |
| 441 | |
| 442 | if (_glDebugMessageControl != nullptr && _glDebugMessageCallback != nullptr) { |
| 443 | /* Enable debug output. As synchronous debug output costs performance, we only enable it with a high debug level. */ |
| 444 | _glEnable(GL_DEBUG_OUTPUT); |
| 445 | if (_debug_driver_level >= 8) _glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS); |
| 446 | |
| 447 | _glDebugMessageCallback(&DebugOutputCallback, nullptr); |
| 448 | /* Enable all messages on highest debug level.*/ |
| 449 | _glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, nullptr, _debug_driver_level >= 9 ? GL_TRUE : GL_FALSE); |
| 450 | /* Get debug messages for errors and undefined/deprecated behaviour. */ |
| 451 | _glDebugMessageControl(GL_DONT_CARE, GL_DEBUG_TYPE_ERROR, GL_DONT_CARE, 0, nullptr, GL_TRUE); |
| 452 | _glDebugMessageControl(GL_DONT_CARE, GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR, GL_DONT_CARE, 0, nullptr, GL_TRUE); |
| 453 | _glDebugMessageControl(GL_DONT_CARE, GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR, GL_DONT_CARE, 0, nullptr, GL_TRUE); |
| 454 | } |
| 455 | #endif |
| 456 | } |
| 457 | |
| 458 | /** |
| 459 | * Create and initialize the singleton back-end class. |
no test coverage detected