Skip to content

Commit

Permalink
Add preprocessor switch to enable GL logging generated by GL_KHR_Debug
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Nov 22, 2020
1 parent d7eaed4 commit dfdb8dd
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
18 changes: 18 additions & 0 deletions radiant/render/OpenGLModule.cpp
Expand Up @@ -11,10 +11,28 @@ OpenGLModule::OpenGLModule() :
_unknownError("Unknown error.")
{}

#ifdef ENABLE_KHR_DEBUG_EXTENSION
void OpenGLModule::onGLDebugMessage(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length,
const GLchar* message, const void* userParam)
{
rError() << "OpenGL says: " << message << std::endl;
}
#endif

void OpenGLModule::sharedContextCreated()
{
// Initialise the font before firing the extension initialised signal
_font.reset(new wxutil::GLFont(wxutil::GLFont::FONT_SANS, 14));

#ifdef ENABLE_KHR_DEBUG_EXTENSION
// Debugging
if (glewGetExtension("GL_KHR_debug"))
{
glDebugMessageCallback(onGLDebugMessage, this);
glEnable(GL_DEBUG_OUTPUT);
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
}
#endif
}

void OpenGLModule::sharedContextDestroyed()
Expand Down
9 changes: 9 additions & 0 deletions radiant/render/OpenGLModule.h
Expand Up @@ -8,6 +8,10 @@
#include "wxutil/GLFont.h"
#include "wxutil/GLWidget.h"

#ifndef NDEBUG
//#define ENABLE_KHR_DEBUG_EXTENSION
#endif

/// Implementation of OpenGLBinding module
class OpenGLModule :
public OpenGLBinding
Expand Down Expand Up @@ -36,4 +40,9 @@ class OpenGLModule :
private:
void sharedContextCreated();
void sharedContextDestroyed();

#ifdef ENABLE_KHR_DEBUG_EXTENSION
static void onGLDebugMessage(GLenum source, GLenum type, GLuint id, GLenum severity,
GLsizei length, const GLchar* message, const void* userParam);
#endif
};

0 comments on commit dfdb8dd

Please sign in to comment.