egl: Cleanup _EGLDisplay initialization.
[mesa.git] / src / egl / drivers / glx / egl_glx.c
1 /**************************************************************************
2 *
3 * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28
29 /**
30 * This is an EGL driver that wraps GLX. This gives the benefit of being
31 * completely agnostic of the direct rendering implementation.
32 *
33 * Authors: Alan Hourihane <alanh@tungstengraphics.com>
34 */
35
36 #include <stdlib.h>
37 #include <string.h>
38 #include <X11/Xlib.h>
39 #include <dlfcn.h>
40 #include "GL/glx.h"
41
42 #include "eglconfig.h"
43 #include "eglcontext.h"
44 #include "egldefines.h"
45 #include "egldisplay.h"
46 #include "egldriver.h"
47 #include "eglcurrent.h"
48 #include "egllog.h"
49 #include "eglsurface.h"
50
51 #define CALLOC_STRUCT(T) (struct T *) calloc(1, sizeof(struct T))
52
53 #ifndef GLX_VERSION_1_4
54 #error "GL/glx.h must be equal to or greater than GLX 1.4"
55 #endif
56
57 /* GLX 1.0 */
58 typedef GLXContext (*GLXCREATECONTEXTPROC)( Display *dpy, XVisualInfo *vis, GLXContext shareList, Bool direct );
59 typedef void (*GLXDESTROYCONTEXTPROC)( Display *dpy, GLXContext ctx );
60 typedef Bool (*GLXMAKECURRENTPROC)( Display *dpy, GLXDrawable drawable, GLXContext ctx);
61 typedef void (*GLXSWAPBUFFERSPROC)( Display *dpy, GLXDrawable drawable );
62 typedef GLXPixmap (*GLXCREATEGLXPIXMAPPROC)( Display *dpy, XVisualInfo *visual, Pixmap pixmap );
63 typedef void (*GLXDESTROYGLXPIXMAPPROC)( Display *dpy, GLXPixmap pixmap );
64 typedef Bool (*GLXQUERYVERSIONPROC)( Display *dpy, int *maj, int *min );
65 typedef int (*GLXGETCONFIGPROC)( Display *dpy, XVisualInfo *visual, int attrib, int *value );
66 typedef void (*GLXWAITGLPROC)( void );
67 typedef void (*GLXWAITXPROC)( void );
68
69 /* GLX 1.1 */
70 typedef const char *(*GLXQUERYEXTENSIONSSTRINGPROC)( Display *dpy, int screen );
71 typedef const char *(*GLXQUERYSERVERSTRINGPROC)( Display *dpy, int screen, int name );
72 typedef const char *(*GLXGETCLIENTSTRINGPROC)( Display *dpy, int name );
73
74 /** subclass of _EGLDriver */
75 struct GLX_egl_driver
76 {
77 _EGLDriver Base; /**< base class */
78
79 void *handle;
80
81 /* GLX 1.0 */
82 GLXCREATECONTEXTPROC glXCreateContext;
83 GLXDESTROYCONTEXTPROC glXDestroyContext;
84 GLXMAKECURRENTPROC glXMakeCurrent;
85 GLXSWAPBUFFERSPROC glXSwapBuffers;
86 GLXCREATEGLXPIXMAPPROC glXCreateGLXPixmap;
87 GLXDESTROYGLXPIXMAPPROC glXDestroyGLXPixmap;
88 GLXQUERYVERSIONPROC glXQueryVersion;
89 GLXGETCONFIGPROC glXGetConfig;
90 GLXWAITGLPROC glXWaitGL;
91 GLXWAITXPROC glXWaitX;
92
93 /* GLX 1.1 */
94 GLXQUERYEXTENSIONSSTRINGPROC glXQueryExtensionsString;
95 GLXQUERYSERVERSTRINGPROC glXQueryServerString;
96 GLXGETCLIENTSTRINGPROC glXGetClientString;
97
98 /* GLX 1.3 or (GLX_SGI_make_current_read and GLX_SGIX_fbconfig) */
99 PFNGLXGETFBCONFIGSPROC glXGetFBConfigs;
100 PFNGLXGETFBCONFIGATTRIBPROC glXGetFBConfigAttrib;
101 PFNGLXGETVISUALFROMFBCONFIGPROC glXGetVisualFromFBConfig;
102 PFNGLXCREATEWINDOWPROC glXCreateWindow;
103 PFNGLXDESTROYWINDOWPROC glXDestroyWindow;
104 PFNGLXCREATEPIXMAPPROC glXCreatePixmap;
105 PFNGLXDESTROYPIXMAPPROC glXDestroyPixmap;
106 PFNGLXCREATEPBUFFERPROC glXCreatePbuffer;
107 PFNGLXDESTROYPBUFFERPROC glXDestroyPbuffer;
108 PFNGLXCREATENEWCONTEXTPROC glXCreateNewContext;
109 PFNGLXMAKECONTEXTCURRENTPROC glXMakeContextCurrent;
110
111 /* GLX 1.4 or GLX_ARB_get_proc_address */
112 PFNGLXGETPROCADDRESSPROC glXGetProcAddress;
113
114 /* GLX_SGIX_pbuffer */
115 PFNGLXCREATEGLXPBUFFERSGIXPROC glXCreateGLXPbufferSGIX;
116 PFNGLXDESTROYGLXPBUFFERSGIXPROC glXDestroyGLXPbufferSGIX;
117 };
118
119
120 /** driver data of _EGLDisplay */
121 struct GLX_egl_display
122 {
123 Display *dpy;
124 XVisualInfo *visuals;
125 GLXFBConfig *fbconfigs;
126
127 int glx_maj, glx_min;
128
129 const char *extensions;
130 EGLBoolean have_1_3;
131 EGLBoolean have_make_current_read;
132 EGLBoolean have_fbconfig;
133 EGLBoolean have_pbuffer;
134
135 /* workaround quirks of different GLX implementations */
136 EGLBoolean single_buffered_quirk;
137 EGLBoolean glx_window_quirk;
138 };
139
140
141 /** subclass of _EGLContext */
142 struct GLX_egl_context
143 {
144 _EGLContext Base; /**< base class */
145
146 GLXContext context;
147 };
148
149
150 /** subclass of _EGLSurface */
151 struct GLX_egl_surface
152 {
153 _EGLSurface Base; /**< base class */
154
155 Drawable drawable;
156 GLXDrawable glx_drawable;
157
158 void (*destroy)(Display *, GLXDrawable);
159 };
160
161
162 /** subclass of _EGLConfig */
163 struct GLX_egl_config
164 {
165 _EGLConfig Base; /**< base class */
166 EGLBoolean double_buffered;
167 int index;
168 };
169
170 /* standard typecasts */
171 _EGL_DRIVER_STANDARD_TYPECASTS(GLX_egl)
172
173 static int
174 GLX_egl_config_index(_EGLConfig *conf)
175 {
176 struct GLX_egl_config *GLX_conf = GLX_egl_config(conf);
177 return GLX_conf->index;
178 }
179
180
181 static const struct {
182 int attr;
183 int egl_attr;
184 } fbconfig_attributes[] = {
185 /* table 3.1 of GLX 1.4 */
186 { GLX_FBCONFIG_ID, 0 },
187 { GLX_BUFFER_SIZE, EGL_BUFFER_SIZE },
188 { GLX_LEVEL, EGL_LEVEL },
189 { GLX_DOUBLEBUFFER, 0 },
190 { GLX_STEREO, 0 },
191 { GLX_AUX_BUFFERS, 0 },
192 { GLX_RED_SIZE, EGL_RED_SIZE },
193 { GLX_GREEN_SIZE, EGL_GREEN_SIZE },
194 { GLX_BLUE_SIZE, EGL_BLUE_SIZE },
195 { GLX_ALPHA_SIZE, EGL_ALPHA_SIZE },
196 { GLX_DEPTH_SIZE, EGL_DEPTH_SIZE },
197 { GLX_STENCIL_SIZE, EGL_STENCIL_SIZE },
198 { GLX_ACCUM_RED_SIZE, 0 },
199 { GLX_ACCUM_GREEN_SIZE, 0 },
200 { GLX_ACCUM_BLUE_SIZE, 0 },
201 { GLX_ACCUM_ALPHA_SIZE, 0 },
202 { GLX_SAMPLE_BUFFERS, EGL_SAMPLE_BUFFERS },
203 { GLX_SAMPLES, EGL_SAMPLES },
204 { GLX_RENDER_TYPE, 0 },
205 { GLX_DRAWABLE_TYPE, EGL_SURFACE_TYPE },
206 { GLX_X_RENDERABLE, EGL_NATIVE_RENDERABLE },
207 { GLX_X_VISUAL_TYPE, EGL_NATIVE_VISUAL_TYPE },
208 { GLX_CONFIG_CAVEAT, EGL_CONFIG_CAVEAT },
209 { GLX_TRANSPARENT_TYPE, EGL_TRANSPARENT_TYPE },
210 { GLX_TRANSPARENT_INDEX_VALUE, 0 },
211 { GLX_TRANSPARENT_RED_VALUE, EGL_TRANSPARENT_RED_VALUE },
212 { GLX_TRANSPARENT_GREEN_VALUE, EGL_TRANSPARENT_GREEN_VALUE },
213 { GLX_TRANSPARENT_BLUE_VALUE, EGL_TRANSPARENT_BLUE_VALUE },
214 { GLX_MAX_PBUFFER_WIDTH, EGL_MAX_PBUFFER_WIDTH },
215 { GLX_MAX_PBUFFER_HEIGHT, EGL_MAX_PBUFFER_HEIGHT },
216 { GLX_MAX_PBUFFER_PIXELS, EGL_MAX_PBUFFER_PIXELS },
217 { GLX_VISUAL_ID, EGL_NATIVE_VISUAL_ID }
218 };
219
220
221 static EGLBoolean
222 convert_fbconfig(struct GLX_egl_driver *GLX_drv,
223 struct GLX_egl_display *GLX_dpy, GLXFBConfig fbconfig,
224 struct GLX_egl_config *GLX_conf)
225 {
226 Display *dpy = GLX_dpy->dpy;
227 int err, attr, val;
228 unsigned i;
229
230 /* must have rgba bit */
231 err = GLX_drv->glXGetFBConfigAttrib(dpy, fbconfig, GLX_RENDER_TYPE, &val);
232 if (err || !(val & GLX_RGBA_BIT))
233 return EGL_FALSE;
234
235 /* must know whether it is double-buffered */
236 err = GLX_drv->glXGetFBConfigAttrib(dpy, fbconfig, GLX_DOUBLEBUFFER, &val);
237 if (err)
238 return EGL_FALSE;
239 GLX_conf->double_buffered = val;
240
241 GLX_conf->Base.RenderableType = EGL_OPENGL_BIT;
242 GLX_conf->Base.Conformant = EGL_OPENGL_BIT;
243
244 for (i = 0; i < ARRAY_SIZE(fbconfig_attributes); i++) {
245 EGLint egl_attr, egl_val;
246
247 attr = fbconfig_attributes[i].attr;
248 egl_attr = fbconfig_attributes[i].egl_attr;
249 if (!egl_attr)
250 continue;
251
252 err = GLX_drv->glXGetFBConfigAttrib(dpy, fbconfig, attr, &val);
253 if (err) {
254 if (err == GLX_BAD_ATTRIBUTE) {
255 err = 0;
256 continue;
257 }
258 break;
259 }
260
261 switch (egl_attr) {
262 case EGL_SURFACE_TYPE:
263 egl_val = 0;
264 if (val & GLX_WINDOW_BIT)
265 egl_val |= EGL_WINDOW_BIT;
266 /* pixmap and pbuffer surfaces must be single-buffered in EGL */
267 if (!GLX_conf->double_buffered) {
268 if (val & GLX_PIXMAP_BIT)
269 egl_val |= EGL_PIXMAP_BIT;
270 if (val & GLX_PBUFFER_BIT)
271 egl_val |= EGL_PBUFFER_BIT;
272 }
273 break;
274 case EGL_NATIVE_VISUAL_TYPE:
275 switch (val) {
276 case GLX_TRUE_COLOR:
277 egl_val = TrueColor;
278 break;
279 case GLX_DIRECT_COLOR:
280 egl_val = DirectColor;
281 break;
282 case GLX_PSEUDO_COLOR:
283 egl_val = PseudoColor;
284 break;
285 case GLX_STATIC_COLOR:
286 egl_val = StaticColor;
287 break;
288 case GLX_GRAY_SCALE:
289 egl_val = GrayScale;
290 break;
291 case GLX_STATIC_GRAY:
292 egl_val = StaticGray;
293 break;
294 default:
295 egl_val = EGL_NONE;
296 break;
297 }
298 break;
299 case EGL_CONFIG_CAVEAT:
300 egl_val = EGL_NONE;
301 if (val == GLX_SLOW_CONFIG) {
302 egl_val = EGL_SLOW_CONFIG;
303 }
304 else if (val == GLX_NON_CONFORMANT_CONFIG) {
305 GLX_conf->Base.Conformant &= ~EGL_OPENGL_BIT;
306 egl_val = EGL_NONE;
307 }
308 break;
309 case EGL_TRANSPARENT_TYPE:
310 egl_val = (val == GLX_TRANSPARENT_RGB) ?
311 EGL_TRANSPARENT_RGB : EGL_NONE;
312 break;
313 default:
314 egl_val = val;
315 break;
316 }
317
318 _eglSetConfigKey(&GLX_conf->Base, egl_attr, egl_val);
319 }
320 if (err)
321 return EGL_FALSE;
322
323 if (!GLX_conf->Base.SurfaceType)
324 return EGL_FALSE;
325
326 return EGL_TRUE;
327 }
328
329 static const struct {
330 int attr;
331 int egl_attr;
332 } visual_attributes[] = {
333 /* table 3.7 of GLX 1.4 */
334 { GLX_USE_GL, 0 },
335 { GLX_BUFFER_SIZE, EGL_BUFFER_SIZE },
336 { GLX_LEVEL, EGL_LEVEL },
337 { GLX_RGBA, 0 },
338 { GLX_DOUBLEBUFFER, 0 },
339 { GLX_STEREO, 0 },
340 { GLX_AUX_BUFFERS, 0 },
341 { GLX_RED_SIZE, EGL_RED_SIZE },
342 { GLX_GREEN_SIZE, EGL_GREEN_SIZE },
343 { GLX_BLUE_SIZE, EGL_BLUE_SIZE },
344 { GLX_ALPHA_SIZE, EGL_ALPHA_SIZE },
345 { GLX_DEPTH_SIZE, EGL_DEPTH_SIZE },
346 { GLX_STENCIL_SIZE, EGL_STENCIL_SIZE },
347 { GLX_ACCUM_RED_SIZE, 0 },
348 { GLX_ACCUM_GREEN_SIZE, 0 },
349 { GLX_ACCUM_BLUE_SIZE, 0 },
350 { GLX_ACCUM_ALPHA_SIZE, 0 },
351 { GLX_SAMPLE_BUFFERS, EGL_SAMPLE_BUFFERS },
352 { GLX_SAMPLES, EGL_SAMPLES },
353 { GLX_FBCONFIG_ID, 0 },
354 /* GLX_EXT_visual_rating */
355 { GLX_VISUAL_CAVEAT_EXT, EGL_CONFIG_CAVEAT }
356 };
357
358 static EGLBoolean
359 convert_visual(struct GLX_egl_driver *GLX_drv,
360 struct GLX_egl_display *GLX_dpy, XVisualInfo *vinfo,
361 struct GLX_egl_config *GLX_conf)
362 {
363 Display *dpy = GLX_dpy->dpy;
364 int err, attr, val;
365 unsigned i;
366
367 /* the visual must support OpenGL and RGBA buffer */
368 err = GLX_drv->glXGetConfig(dpy, vinfo, GLX_USE_GL, &val);
369 if (!err && val)
370 err = GLX_drv->glXGetConfig(dpy, vinfo, GLX_RGBA, &val);
371 if (err || !val)
372 return EGL_FALSE;
373
374 /* must know whether it is double-buffered */
375 err = GLX_drv->glXGetConfig(dpy, vinfo, GLX_DOUBLEBUFFER, &val);
376 if (err)
377 return EGL_FALSE;
378 GLX_conf->double_buffered = val;
379
380 GLX_conf->Base.RenderableType = EGL_OPENGL_BIT;
381 GLX_conf->Base.Conformant = EGL_OPENGL_BIT;
382 GLX_conf->Base.SurfaceType = EGL_WINDOW_BIT;
383 /* pixmap surfaces must be single-buffered in EGL */
384 if (!GLX_conf->double_buffered)
385 GLX_conf->Base.SurfaceType |= EGL_PIXMAP_BIT;
386
387 GLX_conf->Base.NativeVisualID = vinfo->visualid;
388 GLX_conf->Base.NativeVisualType = vinfo->class;
389 GLX_conf->Base.NativeRenderable = EGL_TRUE;
390
391 for (i = 0; i < ARRAY_SIZE(visual_attributes); i++) {
392 EGLint egl_attr, egl_val;
393
394 attr = visual_attributes[i].attr;
395 egl_attr = visual_attributes[i].egl_attr;
396 if (!egl_attr)
397 continue;
398
399 err = GLX_drv->glXGetConfig(dpy, vinfo, attr, &val);
400 if (err) {
401 if (err == GLX_BAD_ATTRIBUTE) {
402 err = 0;
403 continue;
404 }
405 break;
406 }
407
408 switch (egl_attr) {
409 case EGL_CONFIG_CAVEAT:
410 egl_val = EGL_NONE;
411 if (val == GLX_SLOW_VISUAL_EXT) {
412 egl_val = EGL_SLOW_CONFIG;
413 }
414 else if (val == GLX_NON_CONFORMANT_VISUAL_EXT) {
415 GLX_conf->Base.Conformant &= ~EGL_OPENGL_BIT;
416 egl_val = EGL_NONE;
417 }
418 break;
419 break;
420 default:
421 egl_val = val;
422 break;
423 }
424 _eglSetConfigKey(&GLX_conf->Base, egl_attr, egl_val);
425 }
426
427 return (err) ? EGL_FALSE : EGL_TRUE;
428 }
429
430
431 static void
432 fix_config(struct GLX_egl_display *GLX_dpy, struct GLX_egl_config *GLX_conf)
433 {
434 _EGLConfig *conf = &GLX_conf->Base;
435
436 if (!GLX_conf->double_buffered && GLX_dpy->single_buffered_quirk) {
437 /* some GLX impls do not like single-buffered window surface */
438 conf->SurfaceType &= ~EGL_WINDOW_BIT;
439 /* pbuffer bit is usually not set */
440 if (GLX_dpy->have_pbuffer)
441 conf->SurfaceType |= EGL_PBUFFER_BIT;
442 }
443
444 /* no visual attribs unless window bit is set */
445 if (!(conf->SurfaceType & EGL_WINDOW_BIT)) {
446 conf->NativeVisualID = 0;
447 conf->NativeVisualType = EGL_NONE;
448 }
449
450 if (conf->TransparentType != EGL_TRANSPARENT_RGB) {
451 /* some impls set them to -1 (GLX_DONT_CARE) */
452 conf->TransparentRedValue = 0;
453 conf->TransparentGreenValue = 0;
454 conf->TransparentBlueValue = 0;
455 }
456
457 /* make sure buffer size is set correctly */
458 conf->BufferSize =
459 conf->RedSize + conf->GreenSize + conf->BlueSize + conf->AlphaSize;
460 }
461
462
463 static EGLBoolean
464 create_configs(_EGLDriver *drv, _EGLDisplay *dpy, EGLint screen)
465 {
466 struct GLX_egl_driver *GLX_drv = GLX_egl_driver(drv);
467 struct GLX_egl_display *GLX_dpy = GLX_egl_display(dpy);
468 EGLint num_configs = 0, i;
469 EGLint id = 1;
470
471 if (GLX_dpy->have_fbconfig) {
472 GLX_dpy->fbconfigs =
473 GLX_drv->glXGetFBConfigs(GLX_dpy->dpy, screen, &num_configs);
474 }
475 else {
476 XVisualInfo vinfo_template;
477 long mask;
478
479 vinfo_template.screen = screen;
480 mask = VisualScreenMask;
481 GLX_dpy->visuals = XGetVisualInfo(GLX_dpy->dpy, mask, &vinfo_template,
482 &num_configs);
483 }
484
485 if (!num_configs)
486 return EGL_FALSE;
487
488 for (i = 0; i < num_configs; i++) {
489 struct GLX_egl_config *GLX_conf, template;
490 EGLBoolean ok;
491
492 memset(&template, 0, sizeof(template));
493 _eglInitConfig(&template.Base, dpy, id);
494 if (GLX_dpy->have_fbconfig) {
495 ok = convert_fbconfig(GLX_drv, GLX_dpy,
496 GLX_dpy->fbconfigs[i], &template);
497 }
498 else {
499 ok = convert_visual(GLX_drv, GLX_dpy,
500 &GLX_dpy->visuals[i], &template);
501 }
502 if (!ok)
503 continue;
504
505 fix_config(GLX_dpy, &template);
506 if (!_eglValidateConfig(&template.Base, EGL_FALSE)) {
507 _eglLog(_EGL_DEBUG, "GLX: failed to validate config %d", i);
508 continue;
509 }
510
511 GLX_conf = CALLOC_STRUCT(GLX_egl_config);
512 if (GLX_conf) {
513 memcpy(GLX_conf, &template, sizeof(template));
514 GLX_conf->index = i;
515
516 _eglLinkConfig(&GLX_conf->Base);
517 id++;
518 }
519 }
520
521 return EGL_TRUE;
522 }
523
524
525 static void
526 check_extensions(struct GLX_egl_driver *GLX_drv,
527 struct GLX_egl_display *GLX_dpy, EGLint screen)
528 {
529 GLX_dpy->extensions =
530 GLX_drv->glXQueryExtensionsString(GLX_dpy->dpy, screen);
531 if (GLX_dpy->extensions) {
532 if (strstr(GLX_dpy->extensions, "GLX_SGI_make_current_read")) {
533 /* GLX 1.3 entry points are used */
534 GLX_dpy->have_make_current_read = EGL_TRUE;
535 }
536
537 if (strstr(GLX_dpy->extensions, "GLX_SGIX_fbconfig")) {
538 /* GLX 1.3 entry points are used */
539 GLX_dpy->have_fbconfig = EGL_TRUE;
540 }
541
542 if (strstr(GLX_dpy->extensions, "GLX_SGIX_pbuffer")) {
543 if (GLX_drv->glXCreateGLXPbufferSGIX &&
544 GLX_drv->glXDestroyGLXPbufferSGIX &&
545 GLX_dpy->have_fbconfig)
546 GLX_dpy->have_pbuffer = EGL_TRUE;
547 }
548 }
549
550 if (GLX_dpy->glx_maj == 1 && GLX_dpy->glx_min >= 3) {
551 GLX_dpy->have_1_3 = EGL_TRUE;
552 GLX_dpy->have_make_current_read = EGL_TRUE;
553 GLX_dpy->have_fbconfig = EGL_TRUE;
554 GLX_dpy->have_pbuffer = EGL_TRUE;
555 }
556 }
557
558
559 static void
560 check_quirks(struct GLX_egl_driver *GLX_drv,
561 struct GLX_egl_display *GLX_dpy, EGLint screen)
562 {
563 const char *vendor;
564
565 GLX_dpy->single_buffered_quirk = EGL_TRUE;
566 GLX_dpy->glx_window_quirk = EGL_TRUE;
567
568 vendor = GLX_drv->glXGetClientString(GLX_dpy->dpy, GLX_VENDOR);
569 if (vendor && strstr(vendor, "NVIDIA")) {
570 vendor = GLX_drv->glXQueryServerString(GLX_dpy->dpy, screen, GLX_VENDOR);
571 if (vendor && strstr(vendor, "NVIDIA")) {
572 _eglLog(_EGL_DEBUG, "disable quirks");
573 GLX_dpy->single_buffered_quirk = EGL_FALSE;
574 GLX_dpy->glx_window_quirk = EGL_FALSE;
575 }
576 }
577 }
578
579
580 /**
581 * Called via eglInitialize(), GLX_drv->API.Initialize().
582 */
583 static EGLBoolean
584 GLX_eglInitialize(_EGLDriver *drv, _EGLDisplay *disp)
585 {
586 struct GLX_egl_driver *GLX_drv = GLX_egl_driver(drv);
587 struct GLX_egl_display *GLX_dpy;
588
589 if (disp->Platform != _EGL_PLATFORM_X11)
590 return EGL_FALSE;
591
592 GLX_dpy = CALLOC_STRUCT(GLX_egl_display);
593 if (!GLX_dpy)
594 return _eglError(EGL_BAD_ALLOC, "eglInitialize");
595
596 GLX_dpy->dpy = (Display *) disp->PlatformDisplay;
597 if (!GLX_dpy->dpy) {
598 GLX_dpy->dpy = XOpenDisplay(NULL);
599 if (!GLX_dpy->dpy) {
600 _eglLog(_EGL_WARNING, "GLX: XOpenDisplay failed");
601 free(GLX_dpy);
602 return EGL_FALSE;
603 }
604 }
605
606 if (!GLX_drv->glXQueryVersion(GLX_dpy->dpy,
607 &GLX_dpy->glx_maj, &GLX_dpy->glx_min)) {
608 _eglLog(_EGL_WARNING, "GLX: glXQueryVersion failed");
609 if (!disp->PlatformDisplay)
610 XCloseDisplay(GLX_dpy->dpy);
611 free(GLX_dpy);
612 return EGL_FALSE;
613 }
614
615 disp->DriverData = (void *) GLX_dpy;
616 disp->ClientAPIs = EGL_OPENGL_BIT;
617
618 check_extensions(GLX_drv, GLX_dpy, DefaultScreen(GLX_dpy->dpy));
619 check_quirks(GLX_drv, GLX_dpy, DefaultScreen(GLX_dpy->dpy));
620
621 create_configs(drv, disp, DefaultScreen(GLX_dpy->dpy));
622 if (!_eglGetArraySize(disp->Configs)) {
623 _eglLog(_EGL_WARNING, "GLX: failed to create any config");
624 if (!disp->PlatformDisplay)
625 XCloseDisplay(GLX_dpy->dpy);
626 free(GLX_dpy);
627 return EGL_FALSE;
628 }
629
630 /* we're supporting EGL 1.4 */
631 disp->VersionMajor = 1;
632 disp->VersionMinor = 4;
633
634 return EGL_TRUE;
635 }
636
637
638 /**
639 * Called via eglTerminate(), drv->API.Terminate().
640 */
641 static EGLBoolean
642 GLX_eglTerminate(_EGLDriver *drv, _EGLDisplay *disp)
643 {
644 struct GLX_egl_display *GLX_dpy = GLX_egl_display(disp);
645
646 _eglReleaseDisplayResources(drv, disp);
647 _eglCleanupDisplay(disp);
648
649 if (GLX_dpy->visuals)
650 XFree(GLX_dpy->visuals);
651 if (GLX_dpy->fbconfigs)
652 XFree(GLX_dpy->fbconfigs);
653
654 if (!disp->PlatformDisplay)
655 XCloseDisplay(GLX_dpy->dpy);
656 free(GLX_dpy);
657
658 disp->DriverData = NULL;
659
660 return EGL_TRUE;
661 }
662
663
664 /**
665 * Called via eglCreateContext(), drv->API.CreateContext().
666 */
667 static _EGLContext *
668 GLX_eglCreateContext(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf,
669 _EGLContext *share_list, const EGLint *attrib_list)
670 {
671 struct GLX_egl_driver *GLX_drv = GLX_egl_driver(drv);
672 struct GLX_egl_context *GLX_ctx = CALLOC_STRUCT(GLX_egl_context);
673 struct GLX_egl_display *GLX_dpy = GLX_egl_display(disp);
674 struct GLX_egl_context *GLX_ctx_shared = GLX_egl_context(share_list);
675
676 if (!GLX_ctx) {
677 _eglError(EGL_BAD_ALLOC, "eglCreateContext");
678 return NULL;
679 }
680
681 if (!_eglInitContext(&GLX_ctx->Base, disp, conf, attrib_list)) {
682 free(GLX_ctx);
683 return NULL;
684 }
685
686 if (GLX_dpy->have_fbconfig) {
687 GLX_ctx->context = GLX_drv->glXCreateNewContext(GLX_dpy->dpy,
688 GLX_dpy->fbconfigs[GLX_egl_config_index(conf)],
689 GLX_RGBA_TYPE,
690 GLX_ctx_shared ? GLX_ctx_shared->context : NULL,
691 GL_TRUE);
692 }
693 else {
694 GLX_ctx->context = GLX_drv->glXCreateContext(GLX_dpy->dpy,
695 &GLX_dpy->visuals[GLX_egl_config_index(conf)],
696 GLX_ctx_shared ? GLX_ctx_shared->context : NULL,
697 GL_TRUE);
698 }
699 if (!GLX_ctx->context) {
700 free(GLX_ctx);
701 return NULL;
702 }
703
704 return &GLX_ctx->Base;
705 }
706
707
708 /**
709 * Destroy a surface. The display is allowed to be uninitialized.
710 */
711 static void
712 destroy_surface(_EGLDisplay *disp, _EGLSurface *surf)
713 {
714 struct GLX_egl_display *GLX_dpy = GLX_egl_display(disp);
715 struct GLX_egl_surface *GLX_surf = GLX_egl_surface(surf);
716
717 if (GLX_surf->destroy)
718 GLX_surf->destroy(GLX_dpy->dpy, GLX_surf->glx_drawable);
719
720 free(GLX_surf);
721 }
722
723
724 /**
725 * Called via eglMakeCurrent(), drv->API.MakeCurrent().
726 */
727 static EGLBoolean
728 GLX_eglMakeCurrent(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *dsurf,
729 _EGLSurface *rsurf, _EGLContext *ctx)
730 {
731 struct GLX_egl_driver *GLX_drv = GLX_egl_driver(drv);
732 struct GLX_egl_display *GLX_dpy = GLX_egl_display(disp);
733 struct GLX_egl_surface *GLX_dsurf = GLX_egl_surface(dsurf);
734 struct GLX_egl_surface *GLX_rsurf = GLX_egl_surface(rsurf);
735 struct GLX_egl_context *GLX_ctx = GLX_egl_context(ctx);
736 _EGLContext *old_ctx;
737 _EGLSurface *old_dsurf, *old_rsurf;
738 GLXDrawable ddraw, rdraw;
739 GLXContext cctx;
740 EGLBoolean ret = EGL_FALSE;
741
742 /* make new bindings */
743 if (!_eglBindContext(ctx, dsurf, rsurf, &old_ctx, &old_dsurf, &old_rsurf))
744 return EGL_FALSE;
745
746 ddraw = (GLX_dsurf) ? GLX_dsurf->glx_drawable : None;
747 rdraw = (GLX_rsurf) ? GLX_rsurf->glx_drawable : None;
748 cctx = (GLX_ctx) ? GLX_ctx->context : NULL;
749
750 if (GLX_dpy->have_make_current_read)
751 ret = GLX_drv->glXMakeContextCurrent(GLX_dpy->dpy, ddraw, rdraw, cctx);
752 else if (ddraw == rdraw)
753 ret = GLX_drv->glXMakeCurrent(GLX_dpy->dpy, ddraw, cctx);
754
755 if (ret) {
756 if (_eglPutSurface(old_dsurf))
757 destroy_surface(disp, old_dsurf);
758 if (_eglPutSurface(old_rsurf))
759 destroy_surface(disp, old_rsurf);
760 /* no destroy? */
761 _eglPutContext(old_ctx);
762 }
763 else {
764 /* undo the previous _eglBindContext */
765 _eglBindContext(old_ctx, old_dsurf, old_rsurf, &ctx, &dsurf, &rsurf);
766 assert(&GLX_ctx->Base == ctx &&
767 &GLX_dsurf->Base == dsurf &&
768 &GLX_rsurf->Base == rsurf);
769
770 _eglPutSurface(dsurf);
771 _eglPutSurface(rsurf);
772 _eglPutContext(ctx);
773
774 _eglPutSurface(old_dsurf);
775 _eglPutSurface(old_rsurf);
776 _eglPutContext(old_ctx);
777 }
778
779 return ret;
780 }
781
782 /** Get size of given window */
783 static Status
784 get_drawable_size(Display *dpy, Drawable d, uint *width, uint *height)
785 {
786 Window root;
787 Status stat;
788 int xpos, ypos;
789 unsigned int w, h, bw, depth;
790 stat = XGetGeometry(dpy, d, &root, &xpos, &ypos, &w, &h, &bw, &depth);
791 *width = w;
792 *height = h;
793 return stat;
794 }
795
796 /**
797 * Called via eglCreateWindowSurface(), drv->API.CreateWindowSurface().
798 */
799 static _EGLSurface *
800 GLX_eglCreateWindowSurface(_EGLDriver *drv, _EGLDisplay *disp,
801 _EGLConfig *conf, EGLNativeWindowType window,
802 const EGLint *attrib_list)
803 {
804 struct GLX_egl_driver *GLX_drv = GLX_egl_driver(drv);
805 struct GLX_egl_display *GLX_dpy = GLX_egl_display(disp);
806 struct GLX_egl_surface *GLX_surf;
807 uint width, height;
808
809 GLX_surf = CALLOC_STRUCT(GLX_egl_surface);
810 if (!GLX_surf) {
811 _eglError(EGL_BAD_ALLOC, "eglCreateWindowSurface");
812 return NULL;
813 }
814
815 if (!_eglInitSurface(&GLX_surf->Base, disp, EGL_WINDOW_BIT,
816 conf, attrib_list)) {
817 free(GLX_surf);
818 return NULL;
819 }
820
821 GLX_surf->drawable = window;
822
823 if (GLX_dpy->have_1_3 && !GLX_dpy->glx_window_quirk) {
824 GLX_surf->glx_drawable = GLX_drv->glXCreateWindow(GLX_dpy->dpy,
825 GLX_dpy->fbconfigs[GLX_egl_config_index(conf)],
826 GLX_surf->drawable, NULL);
827 }
828 else {
829 GLX_surf->glx_drawable = GLX_surf->drawable;
830 }
831
832 if (!GLX_surf->glx_drawable) {
833 free(GLX_surf);
834 return NULL;
835 }
836
837 if (GLX_dpy->have_1_3 && !GLX_dpy->glx_window_quirk)
838 GLX_surf->destroy = GLX_drv->glXDestroyWindow;
839
840 get_drawable_size(GLX_dpy->dpy, window, &width, &height);
841 GLX_surf->Base.Width = width;
842 GLX_surf->Base.Height = height;
843
844 return &GLX_surf->Base;
845 }
846
847 static _EGLSurface *
848 GLX_eglCreatePixmapSurface(_EGLDriver *drv, _EGLDisplay *disp,
849 _EGLConfig *conf, EGLNativePixmapType pixmap,
850 const EGLint *attrib_list)
851 {
852 struct GLX_egl_driver *GLX_drv = GLX_egl_driver(drv);
853 struct GLX_egl_display *GLX_dpy = GLX_egl_display(disp);
854 struct GLX_egl_surface *GLX_surf;
855 uint width, height;
856
857 GLX_surf = CALLOC_STRUCT(GLX_egl_surface);
858 if (!GLX_surf) {
859 _eglError(EGL_BAD_ALLOC, "eglCreatePixmapSurface");
860 return NULL;
861 }
862
863 if (!_eglInitSurface(&GLX_surf->Base, disp, EGL_PIXMAP_BIT,
864 conf, attrib_list)) {
865 free(GLX_surf);
866 return NULL;
867 }
868
869 GLX_surf->drawable = pixmap;
870
871 if (GLX_dpy->have_1_3) {
872 GLX_surf->glx_drawable = GLX_drv->glXCreatePixmap(GLX_dpy->dpy,
873 GLX_dpy->fbconfigs[GLX_egl_config_index(conf)],
874 GLX_surf->drawable, NULL);
875 }
876 else if (GLX_dpy->have_fbconfig) {
877 GLXFBConfig fbconfig = GLX_dpy->fbconfigs[GLX_egl_config_index(conf)];
878 XVisualInfo *vinfo;
879
880 vinfo = GLX_drv->glXGetVisualFromFBConfig(GLX_dpy->dpy, fbconfig);
881 if (vinfo) {
882 GLX_surf->glx_drawable = GLX_drv->glXCreateGLXPixmap(GLX_dpy->dpy,
883 vinfo, GLX_surf->drawable);
884 XFree(vinfo);
885 }
886 }
887 else {
888 GLX_surf->glx_drawable = GLX_drv->glXCreateGLXPixmap(GLX_dpy->dpy,
889 &GLX_dpy->visuals[GLX_egl_config_index(conf)],
890 GLX_surf->drawable);
891 }
892
893 if (!GLX_surf->glx_drawable) {
894 free(GLX_surf);
895 return NULL;
896 }
897
898 GLX_surf->destroy = (GLX_dpy->have_1_3) ?
899 GLX_drv->glXDestroyPixmap : GLX_drv->glXDestroyGLXPixmap;
900
901 get_drawable_size(GLX_dpy->dpy, pixmap, &width, &height);
902 GLX_surf->Base.Width = width;
903 GLX_surf->Base.Height = height;
904
905 return &GLX_surf->Base;
906 }
907
908 static _EGLSurface *
909 GLX_eglCreatePbufferSurface(_EGLDriver *drv, _EGLDisplay *disp,
910 _EGLConfig *conf, const EGLint *attrib_list)
911 {
912 struct GLX_egl_driver *GLX_drv = GLX_egl_driver(drv);
913 struct GLX_egl_display *GLX_dpy = GLX_egl_display(disp);
914 struct GLX_egl_surface *GLX_surf;
915 int attribs[5];
916 int i;
917
918 GLX_surf = CALLOC_STRUCT(GLX_egl_surface);
919 if (!GLX_surf) {
920 _eglError(EGL_BAD_ALLOC, "eglCreatePbufferSurface");
921 return NULL;
922 }
923
924 if (!_eglInitSurface(&GLX_surf->Base, disp, EGL_PBUFFER_BIT,
925 conf, attrib_list)) {
926 free(GLX_surf);
927 return NULL;
928 }
929
930 i = 0;
931 attribs[i] = None;
932
933 GLX_surf->drawable = None;
934
935 if (GLX_dpy->have_1_3) {
936 /* put geometry in attribs */
937 if (GLX_surf->Base.Width) {
938 attribs[i++] = GLX_PBUFFER_WIDTH;
939 attribs[i++] = GLX_surf->Base.Width;
940 }
941 if (GLX_surf->Base.Height) {
942 attribs[i++] = GLX_PBUFFER_HEIGHT;
943 attribs[i++] = GLX_surf->Base.Height;
944 }
945 attribs[i] = None;
946
947 GLX_surf->glx_drawable = GLX_drv->glXCreatePbuffer(GLX_dpy->dpy,
948 GLX_dpy->fbconfigs[GLX_egl_config_index(conf)], attribs);
949 }
950 else if (GLX_dpy->have_pbuffer) {
951 GLX_surf->glx_drawable = GLX_drv->glXCreateGLXPbufferSGIX(GLX_dpy->dpy,
952 GLX_dpy->fbconfigs[GLX_egl_config_index(conf)],
953 GLX_surf->Base.Width,
954 GLX_surf->Base.Height,
955 attribs);
956 }
957
958 if (!GLX_surf->glx_drawable) {
959 free(GLX_surf);
960 return NULL;
961 }
962
963 GLX_surf->destroy = (GLX_dpy->have_1_3) ?
964 GLX_drv->glXDestroyPbuffer : GLX_drv->glXDestroyGLXPbufferSGIX;
965
966 return &GLX_surf->Base;
967 }
968
969
970 static EGLBoolean
971 GLX_eglDestroySurface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf)
972 {
973 (void) drv;
974
975 if (_eglPutSurface(surf))
976 destroy_surface(disp, surf);
977
978 return EGL_TRUE;
979 }
980
981
982 static EGLBoolean
983 GLX_eglSwapBuffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw)
984 {
985 struct GLX_egl_driver *GLX_drv = GLX_egl_driver(drv);
986 struct GLX_egl_display *GLX_dpy = GLX_egl_display(disp);
987 struct GLX_egl_surface *GLX_surf = GLX_egl_surface(draw);
988
989 GLX_drv->glXSwapBuffers(GLX_dpy->dpy, GLX_surf->glx_drawable);
990
991 return EGL_TRUE;
992 }
993
994 /*
995 * Called from eglGetProcAddress() via drv->API.GetProcAddress().
996 */
997 static _EGLProc
998 GLX_eglGetProcAddress(_EGLDriver *drv, const char *procname)
999 {
1000 struct GLX_egl_driver *GLX_drv = GLX_egl_driver(drv);
1001
1002 return (_EGLProc) GLX_drv->glXGetProcAddress((const GLubyte *) procname);
1003 }
1004
1005 static EGLBoolean
1006 GLX_eglWaitClient(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx)
1007 {
1008 struct GLX_egl_driver *GLX_drv = GLX_egl_driver(drv);
1009
1010 (void) dpy;
1011 (void) ctx;
1012
1013 GLX_drv->glXWaitGL();
1014 return EGL_TRUE;
1015 }
1016
1017 static EGLBoolean
1018 GLX_eglWaitNative(_EGLDriver *drv, _EGLDisplay *dpy, EGLint engine)
1019 {
1020 struct GLX_egl_driver *GLX_drv = GLX_egl_driver(drv);
1021
1022 (void) dpy;
1023
1024 if (engine != EGL_CORE_NATIVE_ENGINE)
1025 return _eglError(EGL_BAD_PARAMETER, "eglWaitNative");
1026 GLX_drv->glXWaitX();
1027 return EGL_TRUE;
1028 }
1029
1030 static void
1031 GLX_Unload(_EGLDriver *drv)
1032 {
1033 struct GLX_egl_driver *GLX_drv = GLX_egl_driver(drv);
1034
1035 if (GLX_drv->handle)
1036 dlclose(GLX_drv->handle);
1037 free(GLX_drv);
1038 }
1039
1040
1041 static EGLBoolean
1042 GLX_Load(_EGLDriver *drv)
1043 {
1044 struct GLX_egl_driver *GLX_drv = GLX_egl_driver(drv);
1045 void *handle;
1046
1047 handle = dlopen("libGL.so", RTLD_LAZY | RTLD_LOCAL);
1048 if (!handle)
1049 goto fail;
1050
1051 GLX_drv->glXGetProcAddress = dlsym(handle, "glXGetProcAddress");
1052 if (!GLX_drv->glXGetProcAddress)
1053 GLX_drv->glXGetProcAddress = dlsym(handle, "glXGetProcAddressARB");
1054 if (!GLX_drv->glXGetProcAddress)
1055 goto fail;
1056
1057 #define GET_PROC(proc_type, proc_name, check) \
1058 do { \
1059 GLX_drv->proc_name = (proc_type) \
1060 GLX_drv->glXGetProcAddress((const GLubyte *) #proc_name); \
1061 if (check && !GLX_drv->proc_name) goto fail; \
1062 } while (0)
1063
1064 /* GLX 1.0 */
1065 GET_PROC(GLXCREATECONTEXTPROC, glXCreateContext, EGL_TRUE);
1066 GET_PROC(GLXDESTROYCONTEXTPROC, glXDestroyContext, EGL_TRUE);
1067 GET_PROC(GLXMAKECURRENTPROC, glXMakeCurrent, EGL_TRUE);
1068 GET_PROC(GLXSWAPBUFFERSPROC, glXSwapBuffers, EGL_TRUE);
1069 GET_PROC(GLXCREATEGLXPIXMAPPROC, glXCreateGLXPixmap, EGL_TRUE);
1070 GET_PROC(GLXDESTROYGLXPIXMAPPROC, glXDestroyGLXPixmap, EGL_TRUE);
1071 GET_PROC(GLXQUERYVERSIONPROC, glXQueryVersion, EGL_TRUE);
1072 GET_PROC(GLXGETCONFIGPROC, glXGetConfig, EGL_TRUE);
1073 GET_PROC(GLXWAITGLPROC, glXWaitGL, EGL_TRUE);
1074 GET_PROC(GLXWAITXPROC, glXWaitX, EGL_TRUE);
1075
1076 /* GLX 1.1 */
1077 GET_PROC(GLXQUERYEXTENSIONSSTRINGPROC, glXQueryExtensionsString, EGL_TRUE);
1078 GET_PROC(GLXQUERYSERVERSTRINGPROC, glXQueryServerString, EGL_TRUE);
1079 GET_PROC(GLXGETCLIENTSTRINGPROC, glXGetClientString, EGL_TRUE);
1080
1081 /* GLX 1.3 */
1082 GET_PROC(PFNGLXGETFBCONFIGSPROC, glXGetFBConfigs, EGL_FALSE);
1083 GET_PROC(PFNGLXGETFBCONFIGATTRIBPROC, glXGetFBConfigAttrib, EGL_FALSE);
1084 GET_PROC(PFNGLXGETVISUALFROMFBCONFIGPROC, glXGetVisualFromFBConfig, EGL_FALSE);
1085 GET_PROC(PFNGLXCREATEWINDOWPROC, glXCreateWindow, EGL_FALSE);
1086 GET_PROC(PFNGLXDESTROYWINDOWPROC, glXDestroyWindow, EGL_FALSE);
1087 GET_PROC(PFNGLXCREATEPIXMAPPROC, glXCreatePixmap, EGL_FALSE);
1088 GET_PROC(PFNGLXDESTROYPIXMAPPROC, glXDestroyPixmap, EGL_FALSE);
1089 GET_PROC(PFNGLXCREATEPBUFFERPROC, glXCreatePbuffer, EGL_FALSE);
1090 GET_PROC(PFNGLXDESTROYPBUFFERPROC, glXDestroyPbuffer, EGL_FALSE);
1091 GET_PROC(PFNGLXCREATENEWCONTEXTPROC, glXCreateNewContext, EGL_FALSE);
1092 GET_PROC(PFNGLXMAKECONTEXTCURRENTPROC, glXMakeContextCurrent, EGL_FALSE);
1093
1094 /* GLX_SGIX_pbuffer */
1095 GET_PROC(PFNGLXCREATEGLXPBUFFERSGIXPROC,
1096 glXCreateGLXPbufferSGIX, EGL_FALSE);
1097 GET_PROC(PFNGLXDESTROYGLXPBUFFERSGIXPROC,
1098 glXDestroyGLXPbufferSGIX, EGL_FALSE);
1099 #undef GET_PROC
1100
1101 GLX_drv->handle = handle;
1102
1103 return EGL_TRUE;
1104
1105 fail:
1106 if (handle)
1107 dlclose(handle);
1108 return EGL_FALSE;
1109 }
1110
1111
1112 /**
1113 * This is the main entrypoint into the driver, called by libEGL.
1114 * Create a new _EGLDriver object and init its dispatch table.
1115 */
1116 _EGLDriver *
1117 _EGL_MAIN(const char *args)
1118 {
1119 struct GLX_egl_driver *GLX_drv = CALLOC_STRUCT(GLX_egl_driver);
1120
1121 (void) args;
1122
1123 if (!GLX_drv)
1124 return NULL;
1125
1126 if (!GLX_Load(&GLX_drv->Base)) {
1127 _eglLog(_EGL_WARNING, "GLX: failed to load GLX");
1128 free(GLX_drv);
1129 return NULL;
1130 }
1131
1132 _eglInitDriverFallbacks(&GLX_drv->Base);
1133 GLX_drv->Base.API.Initialize = GLX_eglInitialize;
1134 GLX_drv->Base.API.Terminate = GLX_eglTerminate;
1135 GLX_drv->Base.API.CreateContext = GLX_eglCreateContext;
1136 GLX_drv->Base.API.MakeCurrent = GLX_eglMakeCurrent;
1137 GLX_drv->Base.API.CreateWindowSurface = GLX_eglCreateWindowSurface;
1138 GLX_drv->Base.API.CreatePixmapSurface = GLX_eglCreatePixmapSurface;
1139 GLX_drv->Base.API.CreatePbufferSurface = GLX_eglCreatePbufferSurface;
1140 GLX_drv->Base.API.DestroySurface = GLX_eglDestroySurface;
1141 GLX_drv->Base.API.SwapBuffers = GLX_eglSwapBuffers;
1142 GLX_drv->Base.API.GetProcAddress = GLX_eglGetProcAddress;
1143 GLX_drv->Base.API.WaitClient = GLX_eglWaitClient;
1144 GLX_drv->Base.API.WaitNative = GLX_eglWaitNative;
1145
1146 GLX_drv->Base.Name = "GLX";
1147 GLX_drv->Base.Unload = GLX_Unload;
1148
1149 return &GLX_drv->Base;
1150 }