~ubuntu-branches/ubuntu/vivid/libsdl2/vivid

« back to all changes in this revision

Viewing changes to src/video/x11/SDL_x11opengl.c

  • Committer: Package Import Robot
  • Author(s): Manuel A. Fernandez Montecelo, Felix Geyer
  • Date: 2013-12-28 12:31:19 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20131228123119-e0k27gckmnzskfgb
Tags: 2.0.1+dfsg1-1
* New upstream release (Closes: #728974)
  - Remove patch applied upstream:
    bug-723797-false_positives_in_mouse_wheel_code.patch
* Bump Standards-Version to 3.9.5, no changes needed.

[ Felix Geyer ]
* Import upstream gpg key for uscan to verify the orig tarball.

Show diffs side-by-side

added added

removed removed

Lines of Context:
106
106
#endif
107
107
#endif
108
108
 
 
109
#ifndef GLX_ARB_framebuffer_sRGB
 
110
#define GLX_ARB_framebuffer_sRGB
 
111
#ifndef GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB
 
112
#define GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB                0x20B2
 
113
#endif
 
114
#endif
 
115
 
109
116
#ifndef GLX_EXT_swap_control
110
117
#define GLX_SWAP_INTERVAL_EXT              0x20F1
111
118
#define GLX_MAX_SWAP_INTERVAL_EXT          0x20F2
140
147
        return SDL_SetError("OpenGL context already created");
141
148
    }
142
149
 
143
 
    /* If SDL_GL_CONTEXT_EGL has been changed to 1, switch over to X11_GLES functions  */
144
 
    if (_this->gl_config.use_egl == 1) {
145
 
#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
146
 
        _this->GL_LoadLibrary = X11_GLES_LoadLibrary;
147
 
        _this->GL_GetProcAddress = X11_GLES_GetProcAddress;
148
 
        _this->GL_UnloadLibrary = X11_GLES_UnloadLibrary;
149
 
        _this->GL_CreateContext = X11_GLES_CreateContext;
150
 
        _this->GL_MakeCurrent = X11_GLES_MakeCurrent;
151
 
        _this->GL_SetSwapInterval = X11_GLES_SetSwapInterval;
152
 
        _this->GL_GetSwapInterval = X11_GLES_GetSwapInterval;
153
 
        _this->GL_SwapWindow = X11_GLES_SwapWindow;
154
 
        _this->GL_DeleteContext = X11_GLES_DeleteContext;
155
 
        return X11_GLES_LoadLibrary(_this, path);
156
 
#else
157
 
        return SDL_SetError("SDL not configured with OpenGL ES/EGL support");
158
 
#endif
159
 
    }
160
 
 
161
 
 
162
150
    /* Load the OpenGL library */
163
151
    if (path == NULL) {
164
152
        path = SDL_getenv("SDL_OPENGL_LIBRARY");
228
216
 
229
217
    /* Initialize extensions */
230
218
    X11_GL_InitExtensions(_this);
 
219
    
 
220
    /* If we need a GL ES context and there's no  
 
221
     * GLX_EXT_create_context_es2_profile extension, switch over to X11_GLES functions  
 
222
     */
 
223
    if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES && 
 
224
        ! _this->gl_data->HAS_GLX_EXT_create_context_es2_profile ) {
 
225
#if SDL_VIDEO_OPENGL_EGL
 
226
        X11_GL_UnloadLibrary(_this);
 
227
        /* Better avoid conflicts! */
 
228
        if (_this->gl_config.dll_handle != NULL ) {
 
229
            GL_UnloadObject(_this->gl_config.dll_handle);
 
230
            _this->gl_config.dll_handle = NULL;
 
231
        }
 
232
        _this->GL_LoadLibrary = X11_GLES_LoadLibrary;
 
233
        _this->GL_GetProcAddress = X11_GLES_GetProcAddress;
 
234
        _this->GL_UnloadLibrary = X11_GLES_UnloadLibrary;
 
235
        _this->GL_CreateContext = X11_GLES_CreateContext;
 
236
        _this->GL_MakeCurrent = X11_GLES_MakeCurrent;
 
237
        _this->GL_SetSwapInterval = X11_GLES_SetSwapInterval;
 
238
        _this->GL_GetSwapInterval = X11_GLES_GetSwapInterval;
 
239
        _this->GL_SwapWindow = X11_GLES_SwapWindow;
 
240
        _this->GL_DeleteContext = X11_GLES_DeleteContext;
 
241
        return X11_GLES_LoadLibrary(_this, NULL);
 
242
#else
 
243
        return SDL_SetError("SDL not configured with EGL support");
 
244
#endif
 
245
    }
231
246
 
232
247
    return 0;
233
248
}
254
269
#endif
255
270
 
256
271
    /* Free OpenGL memory */
257
 
    if (_this->gl_data) {
258
 
        SDL_free(_this->gl_data);
259
 
        _this->gl_data = NULL;
260
 
    }
 
272
    SDL_free(_this->gl_data);
 
273
    _this->gl_data = NULL;
261
274
}
262
275
 
263
276
static SDL_bool
314
327
    xattr.background_pixel = 0;
315
328
    xattr.border_pixel = 0;
316
329
    xattr.colormap =
317
 
        XCreateColormap(display, RootWindow(display, screen), vinfo->visual,
 
330
        X11_XCreateColormap(display, RootWindow(display, screen), vinfo->visual,
318
331
                        AllocNone);
319
 
    w = XCreateWindow(display, RootWindow(display, screen), 0, 0, 32, 32, 0,
 
332
    w = X11_XCreateWindow(display, RootWindow(display, screen), 0, 0, 32, 32, 0,
320
333
                      vinfo->depth, InputOutput, vinfo->visual,
321
334
                      (CWBackPixel | CWBorderPixel | CWColormap), &xattr);
322
335
    context = _this->gl_data->glXCreateContext(display, vinfo, NULL, True);
323
336
    if (context) {
324
337
        _this->gl_data->glXMakeCurrent(display, w, context);
325
338
    }
326
 
    XFree(vinfo);
 
339
    X11_XFree(vinfo);
327
340
 
328
341
    glXQueryExtensionsStringFunc =
329
342
        (const char *(*)(Display *, int)) X11_GL_GetProcAddress(_this,
369
382
    if (HasExtension("GLX_EXT_visual_info", extensions)) {
370
383
        _this->gl_data->HAS_GLX_EXT_visual_info = SDL_TRUE;
371
384
    }
 
385
    
 
386
    /* Check for GLX_EXT_create_context_es2_profile */
 
387
    if (HasExtension("GLX_EXT_create_context_es2_profile", extensions)) {
 
388
        _this->gl_data->HAS_GLX_EXT_create_context_es2_profile = SDL_TRUE;
 
389
    }
372
390
 
373
391
    if (context) {
374
392
        _this->gl_data->glXMakeCurrent(display, None, NULL);
375
393
        _this->gl_data->glXDestroyContext(display, context);
376
394
    }
377
 
    XDestroyWindow(display, w);
 
395
    X11_XDestroyWindow(display, w);
378
396
    X11_PumpEvents(_this);
379
397
}
380
398
 
461
479
        attribs[i++] = _this->gl_config.multisamplesamples;
462
480
    }
463
481
 
 
482
    if (_this->gl_config.framebuffer_srgb_capable) {
 
483
        attribs[i++] = GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB;
 
484
        if( for_FBConfig ) {
 
485
            attribs[i++] = True;
 
486
        }
 
487
    }
 
488
 
464
489
    if (_this->gl_config.accelerated >= 0 &&
465
490
        _this->gl_data->HAS_GLX_EXT_visual_rating) {
466
491
        attribs[i++] = GLX_VISUAL_CAVEAT_EXT;
546
571
    XVisualInfo v, *vinfo;
547
572
    int n;
548
573
    GLXContext context = NULL, share_context;
 
574
    PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribs = NULL;
549
575
 
550
576
    if (_this->gl_config.share_with_current_context) {
551
577
        share_context = (GLXContext)SDL_GL_GetCurrentContext();
554
580
    }
555
581
 
556
582
    /* We do this to create a clean separation between X and GLX errors. */
557
 
    XSync(display, False);
 
583
    X11_XSync(display, False);
558
584
    errorBase = _this->gl_data->errorBase;
559
 
    handler = XSetErrorHandler(X11_GL_CreateContextErrorHandler);
560
 
    XGetWindowAttributes(display, data->xwindow, &xattr);
 
585
    handler = X11_XSetErrorHandler(X11_GL_CreateContextErrorHandler);
 
586
    X11_XGetWindowAttributes(display, data->xwindow, &xattr);
561
587
    v.screen = screen;
562
 
    v.visualid = XVisualIDFromVisual(xattr.visual);
563
 
    vinfo = XGetVisualInfo(display, VisualScreenMask | VisualIDMask, &v, &n);
 
588
    v.visualid = X11_XVisualIDFromVisual(xattr.visual);
 
589
    vinfo = X11_XGetVisualInfo(display, VisualScreenMask | VisualIDMask, &v, &n);
564
590
    if (vinfo) {
565
591
        if (_this->gl_config.major_version < 3 &&
566
592
            _this->gl_config.profile_mask == 0 &&
599
625
                attribs[iattr++] = 0;
600
626
 
601
627
                /* Get a pointer to the context creation function for GL 3.0 */
602
 
                PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribs =
 
628
                glXCreateContextAttribs =
603
629
                    (PFNGLXCREATECONTEXTATTRIBSARBPROC) _this->gl_data->
604
630
                    glXGetProcAddress((GLubyte *)
605
631
                                      "glXCreateContextAttribsARB");
644
670
                }
645
671
            }
646
672
        }
647
 
        XFree(vinfo);
 
673
        X11_XFree(vinfo);
648
674
    }
649
 
    XSync(display, False);
650
 
    XSetErrorHandler(handler);
 
675
    X11_XSync(display, False);
 
676
    X11_XSetErrorHandler(handler);
651
677
 
652
678
    if (!context) {
653
679
        SDL_SetError("Could not create GL context");
789
815
        return;
790
816
    }
791
817
    _this->gl_data->glXDestroyContext(display, glx_context);
792
 
    XSync(display, False);
 
818
    X11_XSync(display, False);
793
819
}
794
820
 
795
821
#endif /* SDL_VIDEO_OPENGL_GLX */