src/render/opengl/SDL_render_gl.c
changeset 7198 2928be835dbd
parent 7197 126f8f345bfb
child 7239 04dda95ba22c
     1.1 --- a/src/render/opengl/SDL_render_gl.c	Sun May 19 22:57:01 2013 -0700
     1.2 +++ b/src/render/opengl/SDL_render_gl.c	Mon May 20 12:01:31 2013 -0700
     1.3 @@ -101,6 +101,7 @@
     1.4  {
     1.5      SDL_GLContext context;
     1.6  
     1.7 +    SDL_bool debug_enabled;
     1.8      SDL_bool GL_ARB_debug_output_supported;
     1.9      int errors;
    1.10      char **error_messages;
    1.11 @@ -182,6 +183,10 @@
    1.12  {
    1.13      GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
    1.14  
    1.15 +    if (!data->debug_enabled)
    1.16 +    {
    1.17 +        return;
    1.18 +    }
    1.19      if (data->GL_ARB_debug_output_supported) {
    1.20          if (data->errors) {
    1.21              int i;
    1.22 @@ -206,6 +211,10 @@
    1.23      GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
    1.24      int ret = 0;
    1.25  
    1.26 +    if (!data->debug_enabled)
    1.27 +    {
    1.28 +        return 0;
    1.29 +    }
    1.30      if (data->GL_ARB_debug_output_supported) {
    1.31          if (data->errors) {
    1.32              int i;
    1.33 @@ -444,13 +453,20 @@
    1.34      }
    1.35  
    1.36      /* Check for debug output support */
    1.37 -    if (SDL_GL_ExtensionSupported("GL_ARB_debug_output")) {
    1.38 +    if (SDL_GL_GetAttribute(SDL_GL_CONTEXT_FLAGS, &value) == 0 &&
    1.39 +        (value & SDL_GL_CONTEXT_DEBUG_FLAG)) {
    1.40 +        data->debug_enabled = SDL_TRUE;
    1.41 +    }
    1.42 +    if (data->debug_enabled && SDL_GL_ExtensionSupported("GL_ARB_debug_output")) {
    1.43          PFNGLDEBUGMESSAGECALLBACKARBPROC glDebugMessageCallbackARBFunc = (PFNGLDEBUGMESSAGECALLBACKARBPROC) SDL_GL_GetProcAddress("glDebugMessageCallbackARB");
    1.44  
    1.45          data->GL_ARB_debug_output_supported = SDL_TRUE;
    1.46          data->glGetPointerv(GL_DEBUG_CALLBACK_FUNCTION_ARB, (GLvoid **)&data->next_error_callback);
    1.47          data->glGetPointerv(GL_DEBUG_CALLBACK_USER_PARAM_ARB, &data->next_error_userparam);
    1.48          glDebugMessageCallbackARBFunc(GL_HandleDebugMessage, renderer);
    1.49 +
    1.50 +        /* Make sure our callback is called when errors actually happen */
    1.51 +        data->glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
    1.52      }
    1.53  
    1.54      if (SDL_GL_ExtensionSupported("GL_ARB_texture_rectangle")