src/video/x11/SDL_x11opengl.c
changeset 9355 0d1e81f10b7e
parent 9354 5709598d628a
child 9412 8b1436ce1028
equal deleted inserted replaced
9354:5709598d628a 9355:0d1e81f10b7e
   310 
   310 
   311 static void
   311 static void
   312 X11_GL_InitExtensions(_THIS)
   312 X11_GL_InitExtensions(_THIS)
   313 {
   313 {
   314     Display *display = ((SDL_VideoData *) _this->driverdata)->display;
   314     Display *display = ((SDL_VideoData *) _this->driverdata)->display;
   315     int screen = DefaultScreen(display);
   315     const int screen = DefaultScreen(display);
   316     XVisualInfo *vinfo;
       
   317     XSetWindowAttributes xattr;
       
   318     Window w;
       
   319     GLXContext context;
       
   320     const char *(*glXQueryExtensionsStringFunc) (Display *, int);
   316     const char *(*glXQueryExtensionsStringFunc) (Display *, int);
   321     const char *extensions;
   317     const char *extensions;
   322 
       
   323     vinfo = X11_GL_GetVisual(_this, display, screen);
       
   324     if (!vinfo) {
       
   325         return;
       
   326     }
       
   327     xattr.background_pixel = 0;
       
   328     xattr.border_pixel = 0;
       
   329     xattr.colormap =
       
   330         X11_XCreateColormap(display, RootWindow(display, screen), vinfo->visual,
       
   331                         AllocNone);
       
   332     w = X11_XCreateWindow(display, RootWindow(display, screen), 0, 0, 32, 32, 0,
       
   333                       vinfo->depth, InputOutput, vinfo->visual,
       
   334                       (CWBackPixel | CWBorderPixel | CWColormap), &xattr);
       
   335     context = _this->gl_data->glXCreateContext(display, vinfo, NULL, True);
       
   336     if (context) {
       
   337         _this->gl_data->glXMakeCurrent(display, w, context);
       
   338     }
       
   339     X11_XFree(vinfo);
       
   340 
   318 
   341     glXQueryExtensionsStringFunc =
   319     glXQueryExtensionsStringFunc =
   342         (const char *(*)(Display *, int)) X11_GL_GetProcAddress(_this,
   320         (const char *(*)(Display *, int)) X11_GL_GetProcAddress(_this,
   343                                                                 "glXQueryExtensionsString");
   321                                                                 "glXQueryExtensionsString");
   344     if (glXQueryExtensionsStringFunc) {
   322     if (glXQueryExtensionsStringFunc) {
   395     
   373     
   396     /* Check for GLX_EXT_create_context_es2_profile */
   374     /* Check for GLX_EXT_create_context_es2_profile */
   397     if (HasExtension("GLX_EXT_create_context_es2_profile", extensions)) {
   375     if (HasExtension("GLX_EXT_create_context_es2_profile", extensions)) {
   398         _this->gl_data->HAS_GLX_EXT_create_context_es2_profile = SDL_TRUE;
   376         _this->gl_data->HAS_GLX_EXT_create_context_es2_profile = SDL_TRUE;
   399     }
   377     }
   400 
       
   401     if (context) {
       
   402         _this->gl_data->glXMakeCurrent(display, None, NULL);
       
   403         _this->gl_data->glXDestroyContext(display, context);
       
   404     }
       
   405     X11_XDestroyWindow(display, w);
       
   406     X11_PumpEvents(_this);
       
   407 }
   378 }
   408 
   379 
   409 /* glXChooseVisual and glXChooseFBConfig have some small differences in
   380 /* glXChooseVisual and glXChooseFBConfig have some small differences in
   410  * the attribute encoding, it can be chosen with the for_FBConfig parameter.
   381  * the attribute encoding, it can be chosen with the for_FBConfig parameter.
   411  */
   382  */