src/video/x11/SDL_x11opengl.c
changeset 6570 45855398762c
parent 6522 edacce9402fb
child 6794 a0d42781fa92
     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  }