Add some skeleton code for using GL_ARB_debug_output (disabled by default).
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 23 Mar 2014 11:17:42 +0000 (12:17 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 23 Mar 2014 11:17:42 +0000 (12:17 +0100)
demo.cpp
gtest_sdl_main.cpp
init.cpp

index c9b46ea..ba96291 100644 (file)
--- a/demo.cpp
+++ b/demo.cpp
@@ -191,6 +191,7 @@ int main(int argc, char **argv)
        SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
 
 #ifdef HAVE_SDL2
+       // SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG);
        SDL_Window *window = SDL_CreateWindow("OpenGL window",
                SDL_WINDOWPOS_UNDEFINED,
                SDL_WINDOWPOS_UNDEFINED,
index cd68777..90a929e 100644 (file)
@@ -34,6 +34,10 @@ int main(int argc, char **argv) {
 //     SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
 //     SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
 //     SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
+
+       // See also init.cpp for how to enable debugging.
+//     SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG);
+
        SDL_Window *window = SDL_CreateWindow("OpenGL window for unit test",
                SDL_WINDOWPOS_UNDEFINED,
                SDL_WINDOWPOS_UNDEFINED,
index 4802c68..b4e69b0 100644 (file)
--- a/init.cpp
+++ b/init.cpp
@@ -362,6 +362,17 @@ double get_glsl_version()
        return glsl_version;
 }
 
+void APIENTRY debug_callback(GLenum source,
+                             GLenum type,
+                             GLuint id,
+                             GLenum severity,
+                             GLsizei length,
+                             const char *message,
+                             const void *userParam)
+{
+       printf("Debug: %s\n", message);
+}
+
 }  // namespace
 
 bool init_movit(const string& data_directory, MovitDebugLevel debug_level)
@@ -378,6 +389,12 @@ bool init_movit(const string& data_directory, MovitDebugLevel debug_level)
        glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
        glDisable(GL_DITHER);
 
+       // You can turn this on if you want detailed debug messages from the driver.
+       // You should probably also ask for a debug context (see gtest_sdl_main.cpp),
+       // or you might not get much data back.
+       // glDebugMessageCallbackARB(callback, NULL);
+       // glDebugMessageControlARB(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, 0, GL_TRUE);
+
        if (!check_extensions()) {
                return false;
        }