Add GLX_X_VISUAL_TYPE_EXT so created window will use DirectColor if available (instead of TrueColor).
authorMichael Sartain <mikesart@valvesoftware.com>
Thu, 11 Oct 2012 09:41:43 -0700
changeset 657045855398762c
parent 6569 1f4e69a8e5e6
child 6571 bbf4d53d9e37
Add GLX_X_VISUAL_TYPE_EXT so created window will use DirectColor if available (instead of TrueColor).
Our new X11 window was being created with the TrueColor attribute, and trying to set the gamma
on that would fail. This change checks for the visual_info extension, and uses that to ask for
DirectColor if available.
src/video/x11/SDL_x11opengl.c
src/video/x11/SDL_x11opengl.h
     1.1 --- a/src/video/x11/SDL_x11opengl.c	Thu Oct 11 09:37:38 2012 -0700
     1.2 +++ b/src/video/x11/SDL_x11opengl.c	Thu Oct 11 09:41:43 2012 -0700
     1.3 @@ -60,6 +60,12 @@
     1.4  #define GLX_NON_CONFORMANT_VISUAL_EXT      0x800D
     1.5  #endif
     1.6  
     1.7 +#ifndef GLX_EXT_visual_info
     1.8 +#define GLX_EXT_visual_info
     1.9 +#define GLX_X_VISUAL_TYPE_EXT              0x22
    1.10 +#define GLX_DIRECT_COLOR_EXT               0x8003
    1.11 +#endif
    1.12 +
    1.13  #ifndef GLX_ARB_create_context
    1.14  #define GLX_ARB_create_context
    1.15  #define GLX_CONTEXT_MAJOR_VERSION_ARB      0x2091
    1.16 @@ -353,6 +359,11 @@
    1.17          _this->gl_data->HAS_GLX_EXT_visual_rating = SDL_TRUE;
    1.18      }
    1.19  
    1.20 +    /* Check for GLX_EXT_visual_info */
    1.21 +    if (HasExtension("GLX_EXT_visual_info", extensions)) {
    1.22 +        _this->gl_data->HAS_GLX_EXT_visual_info = SDL_TRUE;
    1.23 +    }
    1.24 +
    1.25      if (context) {
    1.26          _this->gl_data->glXMakeCurrent(display, None, NULL);
    1.27          _this->gl_data->glXDestroyContext(display, context);
    1.28 @@ -368,9 +379,10 @@
    1.29  X11_GL_GetAttributes(_THIS, Display * display, int screen, int * attribs, int size, Bool for_FBConfig)
    1.30  {
    1.31      int i = 0;
    1.32 +	const int MAX_ATTRIBUTES = 64;
    1.33  
    1.34      /* assert buffer is large enough to hold all SDL attributes. */ 
    1.35 -    SDL_assert(size >= 32);
    1.36 +    SDL_assert(size >= MAX_ATTRIBUTES);
    1.37  
    1.38      /* Setup our GLX attributes according to the gl_config. */
    1.39      if( for_FBConfig ) {
    1.40 @@ -448,7 +460,17 @@
    1.41                                                        GLX_SLOW_VISUAL_EXT;
    1.42      }
    1.43  
    1.44 +    // If we're supposed to use DirectColor visuals, and we've got the EXT_visual_info
    1.45 +    //  extension, then add GLX_X_VISUAL_TYPE_EXT.
    1.46 +    if (X11_UseDirectColorVisuals() &&
    1.47 +        _this->gl_data->HAS_GLX_EXT_visual_info) {
    1.48 +        attribs[i++] = GLX_X_VISUAL_TYPE_EXT;
    1.49 +        attribs[i++] = GLX_DIRECT_COLOR_EXT;
    1.50 +    }
    1.51 +
    1.52      attribs[i++] = None;
    1.53 +
    1.54 +    SDL_assert(i <= MAX_ATTRIBUTES);
    1.55   
    1.56      return i;
    1.57  }
     2.1 --- a/src/video/x11/SDL_x11opengl.h	Thu Oct 11 09:37:38 2012 -0700
     2.2 +++ b/src/video/x11/SDL_x11opengl.h	Thu Oct 11 09:41:43 2012 -0700
     2.3 @@ -30,6 +30,7 @@
     2.4  struct SDL_GLDriverData
     2.5  {
     2.6      SDL_bool HAS_GLX_EXT_visual_rating;
     2.7 +    SDL_bool HAS_GLX_EXT_visual_info;
     2.8      SDL_bool HAS_GLX_EXT_swap_control_tear;
     2.9  
    2.10      void *(*glXGetProcAddress) (const GLubyte*);