src/video/x11/SDL_x11opengl.c
changeset 6570 45855398762c
parent 6522 edacce9402fb
child 6794 a0d42781fa92
equal deleted inserted replaced
6569:1f4e69a8e5e6 6570:45855398762c
    56 #define GLX_EXT_visual_rating
    56 #define GLX_EXT_visual_rating
    57 #define GLX_VISUAL_CAVEAT_EXT              0x20
    57 #define GLX_VISUAL_CAVEAT_EXT              0x20
    58 #define GLX_NONE_EXT                       0x8000
    58 #define GLX_NONE_EXT                       0x8000
    59 #define GLX_SLOW_VISUAL_EXT                0x8001
    59 #define GLX_SLOW_VISUAL_EXT                0x8001
    60 #define GLX_NON_CONFORMANT_VISUAL_EXT      0x800D
    60 #define GLX_NON_CONFORMANT_VISUAL_EXT      0x800D
       
    61 #endif
       
    62 
       
    63 #ifndef GLX_EXT_visual_info
       
    64 #define GLX_EXT_visual_info
       
    65 #define GLX_X_VISUAL_TYPE_EXT              0x22
       
    66 #define GLX_DIRECT_COLOR_EXT               0x8003
    61 #endif
    67 #endif
    62 
    68 
    63 #ifndef GLX_ARB_create_context
    69 #ifndef GLX_ARB_create_context
    64 #define GLX_ARB_create_context
    70 #define GLX_ARB_create_context
    65 #define GLX_CONTEXT_MAJOR_VERSION_ARB      0x2091
    71 #define GLX_CONTEXT_MAJOR_VERSION_ARB      0x2091
   351     /* Check for GLX_EXT_visual_rating */
   357     /* Check for GLX_EXT_visual_rating */
   352     if (HasExtension("GLX_EXT_visual_rating", extensions)) {
   358     if (HasExtension("GLX_EXT_visual_rating", extensions)) {
   353         _this->gl_data->HAS_GLX_EXT_visual_rating = SDL_TRUE;
   359         _this->gl_data->HAS_GLX_EXT_visual_rating = SDL_TRUE;
   354     }
   360     }
   355 
   361 
       
   362     /* Check for GLX_EXT_visual_info */
       
   363     if (HasExtension("GLX_EXT_visual_info", extensions)) {
       
   364         _this->gl_data->HAS_GLX_EXT_visual_info = SDL_TRUE;
       
   365     }
       
   366 
   356     if (context) {
   367     if (context) {
   357         _this->gl_data->glXMakeCurrent(display, None, NULL);
   368         _this->gl_data->glXMakeCurrent(display, None, NULL);
   358         _this->gl_data->glXDestroyContext(display, context);
   369         _this->gl_data->glXDestroyContext(display, context);
   359     }
   370     }
   360     XDestroyWindow(display, w);
   371     XDestroyWindow(display, w);
   366  */
   377  */
   367 int 
   378 int 
   368 X11_GL_GetAttributes(_THIS, Display * display, int screen, int * attribs, int size, Bool for_FBConfig)
   379 X11_GL_GetAttributes(_THIS, Display * display, int screen, int * attribs, int size, Bool for_FBConfig)
   369 {
   380 {
   370     int i = 0;
   381     int i = 0;
       
   382 	const int MAX_ATTRIBUTES = 64;
   371 
   383 
   372     /* assert buffer is large enough to hold all SDL attributes. */ 
   384     /* assert buffer is large enough to hold all SDL attributes. */ 
   373     SDL_assert(size >= 32);
   385     SDL_assert(size >= MAX_ATTRIBUTES);
   374 
   386 
   375     /* Setup our GLX attributes according to the gl_config. */
   387     /* Setup our GLX attributes according to the gl_config. */
   376     if( for_FBConfig ) {
   388     if( for_FBConfig ) {
   377         attribs[i++] = GLX_RENDER_TYPE;
   389         attribs[i++] = GLX_RENDER_TYPE;
   378 	attribs[i++] = GLX_RGBA_BIT;
   390 	attribs[i++] = GLX_RGBA_BIT;
   446         attribs[i++] = GLX_VISUAL_CAVEAT_EXT;
   458         attribs[i++] = GLX_VISUAL_CAVEAT_EXT;
   447         attribs[i++] = _this->gl_config.accelerated ? GLX_NONE_EXT :
   459         attribs[i++] = _this->gl_config.accelerated ? GLX_NONE_EXT :
   448                                                       GLX_SLOW_VISUAL_EXT;
   460                                                       GLX_SLOW_VISUAL_EXT;
   449     }
   461     }
   450 
   462 
       
   463     // If we're supposed to use DirectColor visuals, and we've got the EXT_visual_info
       
   464     //  extension, then add GLX_X_VISUAL_TYPE_EXT.
       
   465     if (X11_UseDirectColorVisuals() &&
       
   466         _this->gl_data->HAS_GLX_EXT_visual_info) {
       
   467         attribs[i++] = GLX_X_VISUAL_TYPE_EXT;
       
   468         attribs[i++] = GLX_DIRECT_COLOR_EXT;
       
   469     }
       
   470 
   451     attribs[i++] = None;
   471     attribs[i++] = None;
       
   472 
       
   473     SDL_assert(i <= MAX_ATTRIBUTES);
   452  
   474  
   453     return i;
   475     return i;
   454 }
   476 }
   455 
   477 
   456 XVisualInfo *
   478 XVisualInfo *