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
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");
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);
157
return SDL_SetError("SDL not configured with OpenGL ES/EGL support");
162
150
/* Load the OpenGL library */
163
151
if (path == NULL) {
164
152
path = SDL_getenv("SDL_OPENGL_LIBRARY");
229
217
/* Initialize extensions */
230
218
X11_GL_InitExtensions(_this);
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
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;
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);
243
return SDL_SetError("SDL not configured with EGL support");
314
327
xattr.background_pixel = 0;
315
328
xattr.border_pixel = 0;
317
XCreateColormap(display, RootWindow(display, screen), vinfo->visual,
330
X11_XCreateColormap(display, RootWindow(display, screen), vinfo->visual,
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);
324
337
_this->gl_data->glXMakeCurrent(display, w, context);
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;
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;
374
392
_this->gl_data->glXMakeCurrent(display, None, NULL);
375
393
_this->gl_data->glXDestroyContext(display, context);
377
XDestroyWindow(display, w);
395
X11_XDestroyWindow(display, w);
378
396
X11_PumpEvents(_this);
461
479
attribs[i++] = _this->gl_config.multisamplesamples;
482
if (_this->gl_config.framebuffer_srgb_capable) {
483
attribs[i++] = GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB;
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;
548
573
GLXContext context = NULL, share_context;
574
PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribs = NULL;
550
576
if (_this->gl_config.share_with_current_context) {
551
577
share_context = (GLXContext)SDL_GL_GetCurrentContext();
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);
565
591
if (_this->gl_config.major_version < 3 &&
566
592
_this->gl_config.profile_mask == 0 &&
599
625
attribs[iattr++] = 0;
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");
649
XSync(display, False);
650
XSetErrorHandler(handler);
675
X11_XSync(display, False);
676
X11_XSetErrorHandler(handler);
653
679
SDL_SetError("Could not create GL context");