removed some old DRI-isms
[mesa.git] / src / mesa / drivers / x11 / glxapi.c
1 /* $Id: glxapi.c,v 1.26 2001/05/29 19:48:46 brianp Exp $ */
2
3 /*
4 * Mesa 3-D graphics library
5 * Version: 3.5
6 *
7 * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
8 *
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
15 *
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 */
26
27
28 /*
29 * This is the GLX API dispatcher. Calls to the glX* functions are
30 * either routed to the real GLX encoders or to Mesa's pseudo-GLX functions.
31 */
32
33
34 #include <assert.h>
35 #include <stdlib.h>
36 #include <stdio.h>
37 #include <string.h>
38 /*#include <dlfcn.h>*/ /* XXX not portable? */
39 #include "glapi.h"
40 #include "glxapi.h"
41
42
43 extern struct _glxapi_table *_real_GetGLXDispatchTable(void);
44 extern struct _glxapi_table *_mesa_GetGLXDispatchTable(void);
45
46
47 struct display_dispatch {
48 Display *Dpy;
49 struct _glxapi_table *Table;
50 struct display_dispatch *Next;
51 };
52
53 static struct display_dispatch *DispatchList = NULL;
54
55
56 /* Display -> Dispatch caching */
57 static Display *prevDisplay = NULL;
58 static struct _glxapi_table *prevTable = NULL;
59
60
61 static struct _glxapi_table *
62 get_dispatch(Display *dpy)
63 {
64 if (!dpy)
65 return NULL;
66
67 /* search list of display/dispatch pairs for this display */
68 {
69 const struct display_dispatch *d = DispatchList;
70 while (d) {
71 if (d->Dpy == dpy) {
72 prevDisplay = dpy;
73 prevTable = d->Table;
74 return d->Table; /* done! */
75 }
76 d = d->Next;
77 }
78 }
79
80 /* A new display, determine if we should use real GLX
81 * or Mesa's pseudo-GLX.
82 */
83 {
84 struct _glxapi_table *t = NULL;
85
86 #ifdef GLX_BUILD_IN_XLIB_MESA
87 if (!getenv("LIBGL_FORCE_XMESA")) {
88 int ignore;
89 if (XQueryExtension( dpy, "GLX", &ignore, &ignore, &ignore )) {
90 /* the X server has the GLX extension */
91 t = _real_GetGLXDispatchTable();
92 }
93 }
94 #endif
95
96 if (!t) {
97 /* Fallback to Mesa with Xlib driver */
98 #ifdef GLX_BUILD_IN_XLIB_MESA
99 if (getenv("LIBGL_DEBUG")) {
100 fprintf(stderr,
101 "libGL: server lacks GLX extension. Using Mesa Xlib renderer.\n");
102 }
103 #endif
104 t = _mesa_GetGLXDispatchTable();
105 assert(t); /* this has to work */
106 }
107
108 if (t) {
109 struct display_dispatch *d;
110 d = (struct display_dispatch *) malloc(sizeof(struct display_dispatch));
111 if (d) {
112 d->Dpy = dpy;
113 d->Table = t;
114 /* insert at head of list */
115 d->Next = DispatchList;
116 DispatchList = d;
117 /* update cache */
118 prevDisplay = dpy;
119 prevTable = t;
120 return t;
121 }
122 }
123 }
124
125 /* If we get here that means we can't use real GLX on this display
126 * and the Mesa pseudo-GLX software renderer wasn't compiled in.
127 * Or, we ran out of memory!
128 */
129 return NULL;
130 }
131
132
133 #define GET_DISPATCH(DPY, TABLE) \
134 if (DPY == prevDisplay) { \
135 TABLE = prevTable; \
136 } \
137 else if (!DPY) { \
138 TABLE = NULL; \
139 } \
140 else { \
141 TABLE = get_dispatch(DPY); \
142 }
143
144
145
146
147 /* Set by glXMakeCurrent() and glXMakeContextCurrent() only */
148 #ifndef GLX_BUILD_IN_XLIB_MESA
149 static GLXContext CurrentContext = 0;
150 #define __glXGetCurrentContext() CurrentContext;
151 #endif
152
153
154 /*
155 * GLX API entrypoints
156 */
157
158 /*** GLX_VERSION_1_0 ***/
159
160 XVisualInfo *glXChooseVisual(Display *dpy, int screen, int *list)
161 {
162 struct _glxapi_table *t;
163 GET_DISPATCH(dpy, t);
164 if (!t)
165 return NULL;
166 return (t->ChooseVisual)(dpy, screen, list);
167 }
168
169
170 void glXCopyContext(Display *dpy, GLXContext src, GLXContext dst, unsigned long mask)
171 {
172 struct _glxapi_table *t;
173 GET_DISPATCH(dpy, t);
174 if (!t)
175 return;
176 (t->CopyContext)(dpy, src, dst, mask);
177 }
178
179
180 GLXContext glXCreateContext(Display *dpy, XVisualInfo *visinfo, GLXContext shareList, Bool direct)
181 {
182 struct _glxapi_table *t;
183 GET_DISPATCH(dpy, t);
184 if (!t)
185 return 0;
186 return (t->CreateContext)(dpy, visinfo, shareList, direct);
187 }
188
189
190 GLXPixmap glXCreateGLXPixmap(Display *dpy, XVisualInfo *visinfo, Pixmap pixmap)
191 {
192 struct _glxapi_table *t;
193 GET_DISPATCH(dpy, t);
194 if (!t)
195 return 0;
196 return (t->CreateGLXPixmap)(dpy, visinfo, pixmap);
197 }
198
199
200 void glXDestroyContext(Display *dpy, GLXContext ctx)
201 {
202 struct _glxapi_table *t;
203 GET_DISPATCH(dpy, t);
204 if (!t)
205 return;
206 (t->DestroyContext)(dpy, ctx);
207 }
208
209
210 void glXDestroyGLXPixmap(Display *dpy, GLXPixmap pixmap)
211 {
212 struct _glxapi_table *t;
213 GET_DISPATCH(dpy, t);
214 if (!t)
215 return;
216 (t->DestroyGLXPixmap)(dpy, pixmap);
217 }
218
219
220 int glXGetConfig(Display *dpy, XVisualInfo *visinfo, int attrib, int *value)
221 {
222 struct _glxapi_table *t;
223 GET_DISPATCH(dpy, t);
224 if (!t)
225 return GLX_NO_EXTENSION;
226 return (t->GetConfig)(dpy, visinfo, attrib, value);
227 }
228
229
230 #ifdef GLX_BUILD_IN_XLIB_MESA
231 /* Use real libGL's glXGetCurrentContext() function */
232 #else
233 /* stand-alone Mesa */
234 GLXContext glXGetCurrentContext(void)
235 {
236 return CurrentContext;
237 }
238 #endif
239
240
241 #ifdef GLX_BUILD_IN_XLIB_MESA
242 /* Use real libGL's glXGetCurrentContext() function */
243 #else
244 /* stand-alone Mesa */
245 GLXDrawable glXGetCurrentDrawable(void)
246 {
247 __GLXcontext *gc = (__GLXcontext *) glXGetCurrentContext();
248 return gc ? gc->currentDrawable : 0;
249 }
250 #endif
251
252
253 Bool glXIsDirect(Display *dpy, GLXContext ctx)
254 {
255 struct _glxapi_table *t;
256 GET_DISPATCH(dpy, t);
257 if (!t)
258 return False;
259 return (t->IsDirect)(dpy, ctx);
260 }
261
262
263 Bool glXMakeCurrent(Display *dpy, GLXDrawable drawable, GLXContext ctx)
264 {
265 Bool b;
266 struct _glxapi_table *t;
267 GET_DISPATCH(dpy, t);
268 if (!t)
269 return False;
270 b = (*t->MakeCurrent)(dpy, drawable, ctx);
271 #ifndef GLX_BUILD_IN_XLIB_MESA
272 if (b) {
273 CurrentContext = ctx;
274 }
275 #endif
276 return b;
277 }
278
279
280 Bool glXQueryExtension(Display *dpy, int *errorb, int *event)
281 {
282 struct _glxapi_table *t;
283 GET_DISPATCH(dpy, t);
284 if (!t)
285 return False;
286 return (t->QueryExtension)(dpy, errorb, event);
287 }
288
289
290 Bool glXQueryVersion(Display *dpy, int *maj, int *min)
291 {
292 struct _glxapi_table *t;
293 GET_DISPATCH(dpy, t);
294 if (!t)
295 return False;
296 return (t->QueryVersion)(dpy, maj, min);
297 }
298
299
300 void glXSwapBuffers(Display *dpy, GLXDrawable drawable)
301 {
302 struct _glxapi_table *t;
303 GET_DISPATCH(dpy, t);
304 if (!t)
305 return;
306 (t->SwapBuffers)(dpy, drawable);
307 }
308
309
310 void glXUseXFont(Font font, int first, int count, int listBase)
311 {
312 struct _glxapi_table *t;
313 Display *dpy = glXGetCurrentDisplay();
314 GET_DISPATCH(dpy, t);
315 if (!t)
316 return;
317 (t->UseXFont)(font, first, count, listBase);
318 }
319
320
321 void glXWaitGL(void)
322 {
323 struct _glxapi_table *t;
324 Display *dpy = glXGetCurrentDisplay();
325 GET_DISPATCH(dpy, t);
326 if (!t)
327 return;
328 (t->WaitGL)();
329 }
330
331
332 void glXWaitX(void)
333 {
334 struct _glxapi_table *t;
335 Display *dpy = glXGetCurrentDisplay();
336 GET_DISPATCH(dpy, t);
337 if (!t)
338 return;
339 (t->WaitX)();
340 }
341
342
343
344 /*** GLX_VERSION_1_1 ***/
345
346 const char *glXGetClientString(Display *dpy, int name)
347 {
348 struct _glxapi_table *t;
349 GET_DISPATCH(dpy, t);
350 if (!t)
351 return NULL;
352 return (t->GetClientString)(dpy, name);
353 }
354
355
356 const char *glXQueryExtensionsString(Display *dpy, int screen)
357 {
358 struct _glxapi_table *t;
359 GET_DISPATCH(dpy, t);
360 if (!t)
361 return NULL;
362 return (t->QueryExtensionsString)(dpy, screen);
363 }
364
365
366 const char *glXQueryServerString(Display *dpy, int screen, int name)
367 {
368 struct _glxapi_table *t;
369 GET_DISPATCH(dpy, t);
370 if (!t)
371 return NULL;
372 return (t->QueryServerString)(dpy, screen, name);
373 }
374
375
376 /*** GLX_VERSION_1_2 ***/
377
378 #if !defined(GLX_BUILD_IN_XLIB_MESA)
379 Display *glXGetCurrentDisplay(void)
380 {
381 /* Same code as in libGL's glxext.c */
382 __GLXcontext *gc = (__GLXcontext *) glXGetCurrentContext();
383 if (NULL == gc) return NULL;
384 return gc->currentDpy;
385 }
386 #endif
387
388
389
390 /*** GLX_VERSION_1_3 ***/
391
392 GLXFBConfig *glXChooseFBConfig(Display *dpy, int screen, const int *attribList, int *nitems)
393 {
394 struct _glxapi_table *t;
395 GET_DISPATCH(dpy, t);
396 if (!t)
397 return 0;
398 return (t->ChooseFBConfig)(dpy, screen, attribList, nitems);
399 }
400
401
402 GLXContext glXCreateNewContext(Display *dpy, GLXFBConfig config, int renderType, GLXContext shareList, Bool direct)
403 {
404 struct _glxapi_table *t;
405 GET_DISPATCH(dpy, t);
406 if (!t)
407 return 0;
408 return (t->CreateNewContext)(dpy, config, renderType, shareList, direct);
409 }
410
411
412 GLXPbuffer glXCreatePbuffer(Display *dpy, GLXFBConfig config, const int *attribList)
413 {
414 struct _glxapi_table *t;
415 GET_DISPATCH(dpy, t);
416 if (!t)
417 return 0;
418 return (t->CreatePbuffer)(dpy, config, attribList);
419 }
420
421
422 GLXPixmap glXCreatePixmap(Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attribList)
423 {
424 struct _glxapi_table *t;
425 GET_DISPATCH(dpy, t);
426 if (!t)
427 return 0;
428 return (t->CreatePixmap)(dpy, config, pixmap, attribList);
429 }
430
431
432 GLXWindow glXCreateWindow(Display *dpy, GLXFBConfig config, Window win, const int *attribList)
433 {
434 struct _glxapi_table *t;
435 GET_DISPATCH(dpy, t);
436 if (!t)
437 return 0;
438 return (t->CreateWindow)(dpy, config, win, attribList);
439 }
440
441
442 void glXDestroyPbuffer(Display *dpy, GLXPbuffer pbuf)
443 {
444 struct _glxapi_table *t;
445 GET_DISPATCH(dpy, t);
446 if (!t)
447 return;
448 (t->DestroyPbuffer)(dpy, pbuf);
449 }
450
451
452 void glXDestroyPixmap(Display *dpy, GLXPixmap pixmap)
453 {
454 struct _glxapi_table *t;
455 GET_DISPATCH(dpy, t);
456 if (!t)
457 return;
458 (t->DestroyPixmap)(dpy, pixmap);
459 }
460
461
462 void glXDestroyWindow(Display *dpy, GLXWindow window)
463 {
464 struct _glxapi_table *t;
465 GET_DISPATCH(dpy, t);
466 if (!t)
467 return;
468 (t->DestroyWindow)(dpy, window);
469 }
470
471
472 #ifdef GLX_BUILD_IN_XLIB_MESA
473 /* Use the glXGetCurrentReadDrawable() function from libGL */
474 #else
475 GLXDrawable glXGetCurrentReadDrawable(void)
476 {
477 __GLXcontext *gc = (__GLXcontext *) glXGetCurrentContext();
478 return gc ? gc->currentReadable : 0;
479 }
480 #endif
481
482
483 int glXGetFBConfigAttrib(Display *dpy, GLXFBConfig config, int attribute, int *value)
484 {
485 struct _glxapi_table *t;
486 GET_DISPATCH(dpy, t);
487 if (!t)
488 return GLX_NO_EXTENSION;
489 return (t->GetFBConfigAttrib)(dpy, config, attribute, value);
490 }
491
492
493 GLXFBConfig *glXGetFBConfigs(Display *dpy, int screen, int *nelements)
494 {
495 struct _glxapi_table *t;
496 GET_DISPATCH(dpy, t);
497 if (!t)
498 return 0;
499 return (t->GetFBConfigs)(dpy, screen, nelements);
500 }
501
502 void glXGetSelectedEvent(Display *dpy, GLXDrawable drawable, unsigned long *mask)
503 {
504 struct _glxapi_table *t;
505 GET_DISPATCH(dpy, t);
506 if (!t)
507 return;
508 (t->GetSelectedEvent)(dpy, drawable, mask);
509 }
510
511
512 XVisualInfo *glXGetVisualFromFBConfig(Display *dpy, GLXFBConfig config)
513 {
514 struct _glxapi_table *t;
515 GET_DISPATCH(dpy, t);
516 if (!t)
517 return NULL;
518 return (t->GetVisualFromFBConfig)(dpy, config);
519 }
520
521
522 Bool glXMakeContextCurrent(Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx)
523 {
524 Bool b;
525 struct _glxapi_table *t;
526 GET_DISPATCH(dpy, t);
527 if (!t)
528 return False;
529 b = (t->MakeContextCurrent)(dpy, draw, read, ctx);
530 #ifndef GLX_BUILD_IN_XLIB_MESA
531 if (b) {
532 CurrentContext = ctx;
533 }
534 #endif
535 return b;
536 }
537
538
539 int glXQueryContext(Display *dpy, GLXContext ctx, int attribute, int *value)
540 {
541 struct _glxapi_table *t;
542 GET_DISPATCH(dpy, t);
543 assert(t);
544 if (!t)
545 return 0; /* XXX correct? */
546 return (t->QueryContext)(dpy, ctx, attribute, value);
547 }
548
549
550 void glXQueryDrawable(Display *dpy, GLXDrawable draw, int attribute, unsigned int *value)
551 {
552 struct _glxapi_table *t;
553 GET_DISPATCH(dpy, t);
554 if (!t)
555 return;
556 (t->QueryDrawable)(dpy, draw, attribute, value);
557 }
558
559
560 void glXSelectEvent(Display *dpy, GLXDrawable drawable, unsigned long mask)
561 {
562 struct _glxapi_table *t;
563 GET_DISPATCH(dpy, t);
564 if (!t)
565 return;
566 (t->SelectEvent)(dpy, drawable, mask);
567 }
568
569
570
571 /*** GLX_SGI_swap_control ***/
572
573 int glXSwapIntervalSGI(int interval)
574 {
575 struct _glxapi_table *t;
576 Display *dpy = glXGetCurrentDisplay();
577 GET_DISPATCH(dpy, t);
578 if (!t)
579 return 0;
580 return (t->SwapIntervalSGI)(interval);
581 }
582
583
584
585 /*** GLX_SGI_video_sync ***/
586
587 int glXGetVideoSyncSGI(unsigned int *count)
588 {
589 struct _glxapi_table *t;
590 Display *dpy = glXGetCurrentDisplay();
591 GET_DISPATCH(dpy, t);
592 if (!t)
593 return 0;
594 return (t->GetVideoSyncSGI)(count);
595 }
596
597 int glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count)
598 {
599 struct _glxapi_table *t;
600 Display *dpy = glXGetCurrentDisplay();
601 GET_DISPATCH(dpy, t);
602 if (!t)
603 return 0;
604 return (t->WaitVideoSyncSGI)(divisor, remainder, count);
605 }
606
607
608
609 /*** GLX_SGI_make_current_read ***/
610
611 Bool glXMakeCurrentReadSGI(Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx)
612 {
613 struct _glxapi_table *t;
614 GET_DISPATCH(dpy, t);
615 if (!t)
616 return 0;
617 return (t->MakeCurrentReadSGI)(dpy, draw, read, ctx);
618 }
619
620 #ifdef GLX_BUILD_IN_XLIB_MESA
621 /* Use glXGetCurrentReadDrawableSGI() from libGL */
622 #else
623 /* stand-alone Mesa */
624 GLXDrawable glXGetCurrentReadDrawableSGI(void)
625 {
626 return glXGetCurrentReadDrawable();
627 }
628 #endif
629
630
631 #if defined(_VL_H)
632
633 GLXVideoSourceSGIX glXCreateGLXVideoSourceSGIX(Display *dpy, int screen, VLServer server, VLPath path, int nodeClass, VLNode drainNode)
634 {
635 struct _glxapi_table *t;
636 GET_DISPATCH(dpy, t);
637 if (!t)
638 return 0;
639 return (t->CreateGLXVideoSourceSGIX)(dpy, screen, server, path, nodeClass, drainNode);
640 }
641
642 void glXDestroyGLXVideoSourceSGIX(Display *dpy, GLXVideoSourceSGIX src)
643 {
644 struct _glxapi_table *t;
645 GET_DISPATCH(dpy, t);
646 if (!t)
647 return 0;
648 return (t->DestroyGLXVideoSourceSGIX)(dpy, src);
649 }
650
651 #endif
652
653
654 /*** GLX_EXT_import_context ***/
655
656 void glXFreeContextEXT(Display *dpy, GLXContext context)
657 {
658 struct _glxapi_table *t;
659 GET_DISPATCH(dpy, t);
660 if (!t)
661 return;
662 (t->FreeContextEXT)(dpy, context);
663 }
664
665 #ifdef GLX_BUILD_IN_XLIB_MESA
666 /* Use real libGL's glXGetContextIDEXT() function */
667 #else
668 /* stand-alone Mesa */
669 GLXContextID glXGetContextIDEXT(const GLXContext context)
670 {
671 return ((__GLXcontext *) context)->xid;
672 }
673 #endif
674
675 #ifdef GLX_BUILD_IN_XLIB_MESA
676 /* Use real libGL's glXGetCurrentDisplayEXT() function */
677 #else
678 /* stand-alone Mesa */
679 Display *glXGetCurrentDisplayEXT(void)
680 {
681 return glXGetCurrentDisplay();
682 }
683 #endif
684
685 GLXContext glXImportContextEXT(Display *dpy, GLXContextID contextID)
686 {
687 struct _glxapi_table *t;
688 GET_DISPATCH(dpy, t);
689 if (!t)
690 return 0;
691 return (t->ImportContextEXT)(dpy, contextID);
692 }
693
694 int glXQueryContextInfoEXT(Display *dpy, GLXContext context, int attribute,int *value)
695 {
696 struct _glxapi_table *t;
697 GET_DISPATCH(dpy, t);
698 if (!t)
699 return 0; /* XXX ok? */
700 return (t->QueryContextInfoEXT)(dpy, context, attribute, value);
701 }
702
703
704
705 /*** GLX_SGIX_fbconfig ***/
706
707 int glXGetFBConfigAttribSGIX(Display *dpy, GLXFBConfigSGIX config, int attribute, int *value)
708 {
709 struct _glxapi_table *t;
710 GET_DISPATCH(dpy, t);
711 if (!t)
712 return 0;
713 return (t->GetFBConfigAttribSGIX)(dpy, config, attribute, value);
714 }
715
716 GLXFBConfigSGIX *glXChooseFBConfigSGIX(Display *dpy, int screen, int *attrib_list, int *nelements)
717 {
718 struct _glxapi_table *t;
719 GET_DISPATCH(dpy, t);
720 if (!t)
721 return 0;
722 return (t->ChooseFBConfigSGIX)(dpy, screen, attrib_list, nelements);
723 }
724
725 GLXPixmap glXCreateGLXPixmapWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, Pixmap pixmap)
726 {
727 struct _glxapi_table *t;
728 GET_DISPATCH(dpy, t);
729 if (!t)
730 return 0;
731 return (t->CreateGLXPixmapWithConfigSGIX)(dpy, config, pixmap);
732 }
733
734 GLXContext glXCreateContextWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, int render_type, GLXContext share_list, Bool direct)
735 {
736 struct _glxapi_table *t;
737 GET_DISPATCH(dpy, t);
738 if (!t)
739 return 0;
740 return (t->CreateContextWithConfigSGIX)(dpy, config, render_type, share_list, direct);
741 }
742
743 XVisualInfo * glXGetVisualFromFBConfigSGIX(Display *dpy, GLXFBConfigSGIX config)
744 {
745 struct _glxapi_table *t;
746 GET_DISPATCH(dpy, t);
747 if (!t)
748 return 0;
749 return (t->GetVisualFromFBConfigSGIX)(dpy, config);
750 }
751
752 GLXFBConfigSGIX glXGetFBConfigFromVisualSGIX(Display *dpy, XVisualInfo *vis)
753 {
754 struct _glxapi_table *t;
755 GET_DISPATCH(dpy, t);
756 if (!t)
757 return 0;
758 return (t->GetFBConfigFromVisualSGIX)(dpy, vis);
759 }
760
761
762
763 /*** GLX_SGIX_pbuffer ***/
764
765 GLXPbufferSGIX glXCreateGLXPbufferSGIX(Display *dpy, GLXFBConfigSGIX config, unsigned int width, unsigned int height, int *attrib_list)
766 {
767 struct _glxapi_table *t;
768 GET_DISPATCH(dpy, t);
769 if (!t)
770 return 0;
771 return (t->CreateGLXPbufferSGIX)(dpy, config, width, height, attrib_list);
772 }
773
774 void glXDestroyGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf)
775 {
776 struct _glxapi_table *t;
777 GET_DISPATCH(dpy, t);
778 if (!t)
779 return;
780 (t->DestroyGLXPbufferSGIX)(dpy, pbuf);
781 }
782
783 int glXQueryGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf, int attribute, unsigned int *value)
784 {
785 struct _glxapi_table *t;
786 GET_DISPATCH(dpy, t);
787 if (!t)
788 return 0;
789 return (t->QueryGLXPbufferSGIX)(dpy, pbuf, attribute, value);
790 }
791
792 void glXSelectEventSGIX(Display *dpy, GLXDrawable drawable, unsigned long mask)
793 {
794 struct _glxapi_table *t;
795 GET_DISPATCH(dpy, t);
796 if (!t)
797 return;
798 (t->SelectEventSGIX)(dpy, drawable, mask);
799 }
800
801 void glXGetSelectedEventSGIX(Display *dpy, GLXDrawable drawable, unsigned long *mask)
802 {
803 struct _glxapi_table *t;
804 GET_DISPATCH(dpy, t);
805 if (!t)
806 return;
807 (t->GetSelectedEventSGIX)(dpy, drawable, mask);
808 }
809
810
811
812 /*** GLX_SGI_cushion ***/
813
814 void glXCushionSGI(Display *dpy, Window win, float cushion)
815 {
816 struct _glxapi_table *t;
817 GET_DISPATCH(dpy, t);
818 if (!t)
819 return;
820 (t->CushionSGI)(dpy, win, cushion);
821 }
822
823
824
825 /*** GLX_SGIX_video_resize ***/
826
827 int glXBindChannelToWindowSGIX(Display *dpy, int screen, int channel , Window window)
828 {
829 struct _glxapi_table *t;
830 GET_DISPATCH(dpy, t);
831 if (!t)
832 return 0;
833 return (t->BindChannelToWindowSGIX)(dpy, screen, channel, window);
834 }
835
836 int glXChannelRectSGIX(Display *dpy, int screen, int channel, int x, int y, int w, int h)
837 {
838 struct _glxapi_table *t;
839 GET_DISPATCH(dpy, t);
840 if (!t)
841 return 0;
842 return (t->ChannelRectSGIX)(dpy, screen, channel, x, y, w, h);
843 }
844
845 int glXQueryChannelRectSGIX(Display *dpy, int screen, int channel, int *x, int *y, int *w, int *h)
846 {
847 struct _glxapi_table *t;
848 GET_DISPATCH(dpy, t);
849 if (!t)
850 return 0;
851 return (t->QueryChannelRectSGIX)(dpy, screen, channel, x, y, w, h);
852 }
853
854 int glXQueryChannelDeltasSGIX(Display *dpy, int screen, int channel, int *dx, int *dy, int *dw, int *dh)
855 {
856 struct _glxapi_table *t;
857 GET_DISPATCH(dpy, t);
858 if (!t)
859 return 0;
860 return (t->QueryChannelDeltasSGIX)(dpy, screen, channel, dx, dy, dw, dh);
861 }
862
863 int glXChannelRectSyncSGIX(Display *dpy, int screen, int channel, GLenum synctype)
864 {
865 struct _glxapi_table *t;
866 GET_DISPATCH(dpy, t);
867 if (!t)
868 return 0;
869 return (t->ChannelRectSyncSGIX)(dpy, screen, channel, synctype);
870 }
871
872
873
874 #if defined(_DM_BUFFER_H_)
875
876 Bool glXAssociateDMPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuffer, DMparams *params, DMbuffer dmbuffer)
877 {
878 struct _glxapi_table *t;
879 GET_DISPATCH(dpy, t);
880 if (!t)
881 return False;
882 return (t->AssociateDMPbufferSGIX)(dpy, pbuffer, params, dmbuffer);
883 }
884
885 #endif
886
887
888 /*** GLX_SGIX_swap_group ***/
889
890 void glXJoinSwapGroupSGIX(Display *dpy, GLXDrawable drawable, GLXDrawable member)
891 {
892 struct _glxapi_table *t;
893 GET_DISPATCH(dpy, t);
894 if (!t)
895 return;
896 (*t->JoinSwapGroupSGIX)(dpy, drawable, member);
897 }
898
899
900 /*** GLX_SGIX_swap_barrier ***/
901
902 void glXBindSwapBarrierSGIX(Display *dpy, GLXDrawable drawable, int barrier)
903 {
904 struct _glxapi_table *t;
905 GET_DISPATCH(dpy, t);
906 if (!t)
907 return;
908 (*t->BindSwapBarrierSGIX)(dpy, drawable, barrier);
909 }
910
911 Bool glXQueryMaxSwapBarriersSGIX(Display *dpy, int screen, int *max)
912 {
913 struct _glxapi_table *t;
914 GET_DISPATCH(dpy, t);
915 if (!t)
916 return False;
917 return (*t->QueryMaxSwapBarriersSGIX)(dpy, screen, max);
918 }
919
920
921
922 /*** GLX_SUN_get_transparent_index ***/
923
924 Status glXGetTransparentIndexSUN(Display *dpy, Window overlay, Window underlay, long *pTransparent)
925 {
926 struct _glxapi_table *t;
927 GET_DISPATCH(dpy, t);
928 if (!t)
929 return False;
930 return (*t->GetTransparentIndexSUN)(dpy, overlay, underlay, pTransparent);
931 }
932
933
934
935 /*** GLX_MESA_copy_sub_buffer ***/
936
937 void glXCopySubBufferMESA(Display *dpy, GLXDrawable drawable, int x, int y, int width, int height)
938 {
939 struct _glxapi_table *t;
940 GET_DISPATCH(dpy, t);
941 if (!t)
942 return;
943 (t->CopySubBufferMESA)(dpy, drawable, x, y, width, height);
944 }
945
946
947
948 /*** GLX_MESA_release_buffers ***/
949
950 Bool glXReleaseBuffersMESA(Display *dpy, Window w)
951 {
952 struct _glxapi_table *t;
953 GET_DISPATCH(dpy, t);
954 if (!t)
955 return False;
956 return (t->ReleaseBuffersMESA)(dpy, w);
957 }
958
959
960
961 /*** GLX_MESA_pixmap_colormap ***/
962
963 GLXPixmap glXCreateGLXPixmapMESA(Display *dpy, XVisualInfo *visinfo, Pixmap pixmap, Colormap cmap)
964 {
965 struct _glxapi_table *t;
966 GET_DISPATCH(dpy, t);
967 if (!t)
968 return 0;
969 return (t->CreateGLXPixmapMESA)(dpy, visinfo, pixmap, cmap);
970 }
971
972
973
974 /*** GLX_MESA_set_3dfx_mode ***/
975
976 Bool glXSet3DfxModeMESA(int mode)
977 {
978 struct _glxapi_table *t;
979 Display *dpy = glXGetCurrentDisplay();
980 GET_DISPATCH(dpy, t);
981 if (!t)
982 return False;
983 return (t->Set3DfxModeMESA)(mode);
984 }
985
986
987
988
989 /**********************************************************************/
990 /* GLX API management functions */
991 /**********************************************************************/
992
993
994 const char *
995 _glxapi_get_version(void)
996 {
997 return "1.3";
998 }
999
1000
1001 /*
1002 * Return array of extension strings.
1003 */
1004 const char **
1005 _glxapi_get_extensions(void)
1006 {
1007 static const char *extensions[] = {
1008 #ifdef GLX_EXT_import_context
1009 "GLX_EXT_import_context",
1010 #endif
1011 #ifdef GLX_SGI_video_sync
1012 "GLX_SGI_video_sync",
1013 #endif
1014 #ifdef GLX_MESA_copy_sub_buffer
1015 "GLX_MESA_copy_sub_buffer",
1016 #endif
1017 #ifdef GLX_MESA_release_buffers
1018 "GLX_MESA_release_buffers",
1019 #endif
1020 #ifdef GLX_MESA_pixmap_colormap
1021 "GLX_MESA_pixmap_colormap",
1022 #endif
1023 #ifdef GLX_MESA_set_3dfx_mode
1024 "GLX_MESA_set_3dfx_mode",
1025 #endif
1026 NULL
1027 };
1028 return extensions;
1029 }
1030
1031
1032 /*
1033 * Return size of the GLX dispatch table, in entries, not bytes.
1034 */
1035 GLuint
1036 _glxapi_get_dispatch_table_size(void)
1037 {
1038 return sizeof(struct _glxapi_table) / sizeof(void *);
1039 }
1040
1041
1042 static int
1043 generic_no_op_func(void)
1044 {
1045 return 0;
1046 }
1047
1048
1049 /*
1050 * Initialize all functions in given dispatch table to be no-ops
1051 */
1052 void
1053 _glxapi_set_no_op_table(struct _glxapi_table *t)
1054 {
1055 GLuint n = _glxapi_get_dispatch_table_size();
1056 GLuint i;
1057 void **dispatch = (void **) t;
1058 for (i = 0; i < n; i++) {
1059 dispatch[i] = (void *) generic_no_op_func;
1060 }
1061 }
1062
1063
1064 #if 00
1065 /*
1066 * Open the named library and use dlsym() to populate the given dispatch
1067 * table with GLX function pointers.
1068 * Return: true = all OK
1069 * false = can't open libName or can't get required GLX function
1070 */
1071 GLboolean
1072 _glxapi_load_library_table(const char *libName, struct _glxapi_table *t)
1073 {
1074 void *libHandle;
1075 void **entry; /* used to avoid a lot of cast/type warnings */
1076
1077 libHandle = dlopen(libName, 0);
1078 if (!libHandle) {
1079 return GL_FALSE;
1080 }
1081
1082 #define GET_REQ_FUNCTION(ENTRY, NAME) \
1083 entry = (void **) &(t->ENTRY); \
1084 *entry = dlsym(libHandle, NAME); \
1085 if (!*entry) { \
1086 fprintf(stderr, "libGL Error: couldn't load %s from %s\n", \
1087 NAME, libName); \
1088 dlclose(libHandle); \
1089 return GL_FALSE; \
1090 }
1091
1092 /* 1.0 and 1.1 functions */
1093 GET_REQ_FUNCTION(ChooseVisual, "glXChooseVisual");
1094 GET_REQ_FUNCTION(CopyContext, "glXCopyContext");
1095 GET_REQ_FUNCTION(CreateContext, "glXCreateContext");
1096 GET_REQ_FUNCTION(CreateGLXPixmap, "glXCreateGLXPixmap");
1097 GET_REQ_FUNCTION(DestroyContext, "glXDestroyContext");
1098 GET_REQ_FUNCTION(GetConfig, "glXGetConfig");
1099 GET_REQ_FUNCTION(IsDirect, "glXIsDirect");
1100 GET_REQ_FUNCTION(MakeCurrent, "glXMakeCurrent");
1101 GET_REQ_FUNCTION(QueryExtension, "glXQueryExtension");
1102 GET_REQ_FUNCTION(QueryVersion, "glXQueryVersion");
1103 GET_REQ_FUNCTION(SwapBuffers, "glXSwapBuffers");
1104 GET_REQ_FUNCTION(UseXFont, "glXUseXFont");
1105 GET_REQ_FUNCTION(WaitGL, "glXWaitGL");
1106 GET_REQ_FUNCTION(WaitX, "glXWaitX");
1107 GET_REQ_FUNCTION(GetClientString, "glXGetClientString");
1108 GET_REQ_FUNCTION(QueryExtensionsString, "glXQueryExtensionsString");
1109 GET_REQ_FUNCTION(QueryServerString, "glXQueryServerString");
1110
1111 #define GET_OPT_FUNCTION(ENTRY, NAME) \
1112 entry = (void **) &(t->ENTRY); \
1113 *entry = dlsym(libHandle, NAME); \
1114 if (!*entry) { \
1115 *entry = (void *) generic_no_op_func; \
1116 }
1117
1118 /* 1.2, 1.3 and extensions */
1119 GET_OPT_FUNCTION(ChooseFBConfig, "glXChooseFBConfig");
1120 GET_OPT_FUNCTION(CreateNewContext, "glXCreateNewContext");
1121 GET_OPT_FUNCTION(CreatePbuffer, "glXCreatePbuffer");
1122 GET_OPT_FUNCTION(CreatePixmap, "glXCreatePixmap");
1123 GET_OPT_FUNCTION(CreateWindow, "glXCreateWindow");
1124 GET_OPT_FUNCTION(DestroyPbuffer, "glXDestroyPbuffer");
1125 GET_OPT_FUNCTION(DestroyPixmap, "glXDestroyPixmap");
1126 GET_OPT_FUNCTION(DestroyWindow, "glXDestroyWindow");
1127 GET_OPT_FUNCTION(GetFBConfigAttrib, "glXGetFBConfigAttrib");
1128 GET_OPT_FUNCTION(GetFBConfigs, "glXGetFBConfigs");
1129 GET_OPT_FUNCTION(GetSelectedEvent, "glXGetSelectedEvent");
1130 GET_OPT_FUNCTION(GetVisualFromFBConfig, "glXGetVisualFromFBConfig");
1131 GET_OPT_FUNCTION(MakeContextCurrent, "glXMakeContextCurrent");
1132 GET_OPT_FUNCTION(QueryContext, "glXQueryContext");
1133 GET_OPT_FUNCTION(QueryDrawable, "glXQueryDrawable");
1134 GET_OPT_FUNCTION(SelectEvent, "glXSelectEvent");
1135 /*** GLX_SGI_swap_control ***/
1136 GET_OPT_FUNCTION(SwapIntervalSGI, "glXSwapIntervalSGI");
1137 /*** GLX_SGI_video_sync ***/
1138 GET_OPT_FUNCTION(GetVideoSyncSGI, "glXGetVideoSyncSGI");
1139 GET_OPT_FUNCTION(WaitVideoSyncSGI, "glXWaitVideoSyncSGI");
1140 /*** GLX_SGI_make_current_read ***/
1141 GET_OPT_FUNCTION(MakeCurrentReadSGI, "glXMakeCurrentReadSGI");
1142 GET_OPT_FUNCTION(GetCurrentReadDrawableSGI, "glXGetCurrentReadDrawableSGI");
1143 /*** GLX_SGIX_video_source ***/
1144 #if defined(_VL_H)
1145 GET_OPT_FUNCTION(CreateGLXVideoSourceSGIX, "glXCreateGLXVideoSourceSGIX");
1146 GET_OPT_FUNCTION(DestroyGLXVideoSourceSGIX, "glXDestroyGLXVideoSourceSGIX");
1147 #endif
1148 /*** GLX_EXT_import_context ***/
1149 GET_OPT_FUNCTION(FreeContextEXT, "glXFreeContextEXT");
1150 GET_OPT_FUNCTION(GetContextIDEXT, "glXGetContextIDEXT");
1151 GET_OPT_FUNCTION(GetCurrentDisplayEXT, "glXGetCurrentDisplayEXT");
1152 GET_OPT_FUNCTION(ImportContextEXT, "glXImportContextEXT");
1153 GET_OPT_FUNCTION(QueryContextInfoEXT, "glXQueryContextInfoEXT");
1154 /*** GLX_SGIX_fbconfig ***/
1155 GET_OPT_FUNCTION(GetFBConfigAttribSGIX, "glXGetFBConfigAttribSGIX");
1156 GET_OPT_FUNCTION(ChooseFBConfigSGIX, "glXChooseFBConfigSGIX");
1157 GET_OPT_FUNCTION(CreateGLXPixmapWithConfigSGIX, "glXCreateGLXPixmapWithConfigSGIX");
1158 GET_OPT_FUNCTION(CreateContextWithConfigSGIX, "glXCreateContextWithConfigSGIX");
1159 GET_OPT_FUNCTION(GetVisualFromFBConfigSGIX, "glXGetVisualFromFBConfigSGIX");
1160 GET_OPT_FUNCTION(GetFBConfigFromVisualSGIX, "glXGetFBConfigFromVisualSGIX");
1161 /*** GLX_SGIX_pbuffer ***/
1162 GET_OPT_FUNCTION(CreateGLXPbufferSGIX, "glXCreateGLXPbufferSGIX");
1163 GET_OPT_FUNCTION(DestroyGLXPbufferSGIX, "glXDestroyGLXPbufferSGIX");
1164 GET_OPT_FUNCTION(QueryGLXPbufferSGIX, "glXQueryGLXPbufferSGIX");
1165 GET_OPT_FUNCTION(SelectEventSGIX, "glXSelectEventSGIX");
1166 GET_OPT_FUNCTION(GetSelectedEventSGIX, "glXGetSelectedEventSGIX");
1167 /*** GLX_SGI_cushion ***/
1168 GET_OPT_FUNCTION(CushionSGI, "glXCushionSGI");
1169 /*** GLX_SGIX_video_resize ***/
1170 GET_OPT_FUNCTION(BindChannelToWindowSGIX, "glXBindChannelToWindowSGIX");
1171 GET_OPT_FUNCTION(ChannelRectSGIX, "glXChannelRectSGIX");
1172 GET_OPT_FUNCTION(QueryChannelRectSGIX, "glXQueryChannelRectSGIX");
1173 GET_OPT_FUNCTION(QueryChannelDeltasSGIX, "glXQueryChannelDeltasSGIX");
1174 GET_OPT_FUNCTION(ChannelRectSyncSGIX, "glXChannelRectSyncSGIX");
1175 /*** GLX_SGIX_dmbuffer ***/
1176 #if defined (_DM_BUFFER_H_)
1177 GET_OPT_FUNCTION(AssociateDMPbufferSGIX, "glXAssociateDMPbufferSGIX");
1178 #endif
1179 /*** GLX_SGIX_swap_group ***/
1180 GET_OPT_FUNCTION(JoinSwapGroupSGIX, "glXJoinSwapGroupSGIX");
1181 /*** GLX_SGIX_swap_barrier ***/
1182 GET_OPT_FUNCTION(BindSwapBarrierSGIX, "glXBindSwapBarrierSGIX");
1183 GET_OPT_FUNCTION(QueryMaxSwapBarriersSGIX, "glXQueryMaxSwapBarriersSGIX");
1184 /*** GLX_SUN_get_transparent_index ***/
1185 GET_OPT_FUNCTION(GetTransparentIndexSUN, "glXGetTransparentIndexSUN");
1186 /*** GLX_MESA_copy_sub_buffer ***/
1187 GET_OPT_FUNCTION(CopySubBufferMESA, "glXCopySubBufferMESA");
1188 /*** GLX_MESA_release_buffers ***/
1189 GET_OPT_FUNCTION(ReleaseBuffersMESA, "glXReleaseBuffersMESA");
1190 /*** GLX_MESA_pixmap_colormap ***/
1191 GET_OPT_FUNCTION(CreateGLXPixmapMESA, "glXCreateGLXPixmapMESA");
1192 /*** GLX_MESA_set_3dfx_mode ***/
1193 GET_OPT_FUNCTION(Set3DfxModeMESA, "glXSet3DfxModeMESA");
1194
1195 return GL_TRUE;
1196 }
1197 #endif
1198
1199
1200
1201 struct name_address_pair {
1202 const char *Name;
1203 GLvoid *Address;
1204 };
1205
1206 static struct name_address_pair GLX_functions[] = {
1207 /*** GLX_VERSION_1_0 ***/
1208 { "glXChooseVisual", (GLvoid *) glXChooseVisual },
1209 { "glXCopyContext", (GLvoid *) glXCopyContext },
1210 { "glXCreateContext", (GLvoid *) glXCreateContext },
1211 { "glXCreateGLXPixmap", (GLvoid *) glXCreateGLXPixmap },
1212 { "glXDestroyContext", (GLvoid *) glXDestroyContext },
1213 { "glXDestroyGLXPixmap", (GLvoid *) glXDestroyGLXPixmap },
1214 { "glXGetConfig", (GLvoid *) glXGetConfig },
1215 { "glXGetCurrentContext", (GLvoid *) glXGetCurrentContext },
1216 { "glXGetCurrentDrawable", (GLvoid *) glXGetCurrentDrawable },
1217 { "glXIsDirect", (GLvoid *) glXIsDirect },
1218 { "glXMakeCurrent", (GLvoid *) glXMakeCurrent },
1219 { "glXQueryExtension", (GLvoid *) glXQueryExtension },
1220 { "glXQueryVersion", (GLvoid *) glXQueryVersion },
1221 { "glXSwapBuffers", (GLvoid *) glXSwapBuffers },
1222 { "glXUseXFont", (GLvoid *) glXUseXFont },
1223 { "glXWaitGL", (GLvoid *) glXWaitGL },
1224 { "glXWaitX", (GLvoid *) glXWaitX },
1225
1226 /*** GLX_VERSION_1_1 ***/
1227 { "glXGetClientString", (GLvoid *) glXGetClientString },
1228 { "glXQueryExtensionsString", (GLvoid *) glXQueryExtensionsString },
1229 { "glXQueryServerString", (GLvoid *) glXQueryServerString },
1230
1231 /*** GLX_VERSION_1_2 ***/
1232 { "glXGetCurrentDisplay", (GLvoid *) glXGetCurrentDisplay },
1233
1234 /*** GLX_VERSION_1_3 ***/
1235 { "glXChooseFBConfig", (GLvoid *) glXChooseFBConfig },
1236 { "glXCreateNewContext", (GLvoid *) glXCreateNewContext },
1237 { "glXCreatePbuffer", (GLvoid *) glXCreatePbuffer },
1238 { "glXCreatePixmap", (GLvoid *) glXCreatePixmap },
1239 { "glXCreateWindow", (GLvoid *) glXCreateWindow },
1240 { "glXDestroyPbuffer", (GLvoid *) glXDestroyPbuffer },
1241 { "glXDestroyPixmap", (GLvoid *) glXDestroyPixmap },
1242 { "glXDestroyWindow", (GLvoid *) glXDestroyWindow },
1243 { "glXGetCurrentReadDrawable", (GLvoid *) glXGetCurrentReadDrawable },
1244 { "glXGetFBConfigAttrib", (GLvoid *) glXGetFBConfigAttrib },
1245 { "glXGetFBConfigs", (GLvoid *) glXGetFBConfigs },
1246 { "glXGetSelectedEvent", (GLvoid *) glXGetSelectedEvent },
1247 { "glXGetVisualFromFBConfig", (GLvoid *) glXGetVisualFromFBConfig },
1248 { "glXMakeContextCurrent", (GLvoid *) glXMakeContextCurrent },
1249 { "glXQueryContext", (GLvoid *) glXQueryContext },
1250 { "glXQueryDrawable", (GLvoid *) glXQueryDrawable },
1251 { "glXSelectEvent", (GLvoid *) glXSelectEvent },
1252
1253 /*** GLX_SGI_swap_control ***/
1254 { "glXSwapIntervalSGI", (GLvoid *) glXSwapIntervalSGI },
1255
1256 /*** GLX_SGI_video_sync ***/
1257 { "glXGetVideoSyncSGI", (GLvoid *) glXGetVideoSyncSGI },
1258 { "glXWaitVideoSyncSGI", (GLvoid *) glXWaitVideoSyncSGI },
1259
1260 /*** GLX_SGI_make_current_read ***/
1261 { "glXMakeCurrentReadSGI", (GLvoid *) glXMakeCurrentReadSGI },
1262 { "glXGetCurrentReadDrawableSGI", (GLvoid *) glXGetCurrentReadDrawableSGI },
1263
1264 /*** GLX_SGIX_video_source ***/
1265 #if defined(_VL_H)
1266 { "glXCreateGLXVideoSourceSGIX", (GLvoid *) glXCreateGLXVideoSourceSGIX },
1267 { "glXDestroyGLXVideoSourceSGIX", (GLvoid *) glXDestroyGLXVideoSourceSGIX },
1268 #endif
1269
1270 /*** GLX_EXT_import_context ***/
1271 { "glXFreeContextEXT", (GLvoid *) glXFreeContextEXT },
1272 { "glXGetContextIDEXT", (GLvoid *) glXGetContextIDEXT },
1273 { "glXGetCurrentDisplayEXT", (GLvoid *) glXGetCurrentDisplayEXT },
1274 { "glXImportContextEXT", (GLvoid *) glXImportContextEXT },
1275 { "glXQueryContextInfoEXT", (GLvoid *) glXQueryContextInfoEXT },
1276
1277 /*** GLX_SGIX_fbconfig ***/
1278 { "glXGetFBConfigAttribSGIX", (GLvoid *) glXGetFBConfigAttribSGIX },
1279 { "glXChooseFBConfigSGIX", (GLvoid *) glXChooseFBConfigSGIX },
1280 { "glXCreateGLXPixmapWithConfigSGIX", (GLvoid *) glXCreateGLXPixmapWithConfigSGIX },
1281 { "glXCreateContextWithConfigSGIX", (GLvoid *) glXCreateContextWithConfigSGIX },
1282 { "glXGetVisualFromFBConfigSGIX", (GLvoid *) glXGetVisualFromFBConfigSGIX },
1283 { "glXGetFBConfigFromVisualSGIX", (GLvoid *) glXGetFBConfigFromVisualSGIX },
1284
1285 /*** GLX_SGIX_pbuffer ***/
1286 { "glXCreateGLXPbufferSGIX", (GLvoid *) glXCreateGLXPbufferSGIX },
1287 { "glXDestroyGLXPbufferSGIX", (GLvoid *) glXDestroyGLXPbufferSGIX },
1288 { "glXQueryGLXPbufferSGIX", (GLvoid *) glXQueryGLXPbufferSGIX },
1289 { "glXSelectEventSGIX", (GLvoid *) glXSelectEventSGIX },
1290 { "glXGetSelectedEventSGIX", (GLvoid *) glXGetSelectedEventSGIX },
1291
1292 /*** GLX_SGI_cushion ***/
1293 { "glXCushionSGI", (GLvoid *) glXCushionSGI },
1294
1295 /*** GLX_SGIX_video_resize ***/
1296 { "glXBindChannelToWindowSGIX", (GLvoid *) glXBindChannelToWindowSGIX },
1297 { "glXChannelRectSGIX", (GLvoid *) glXChannelRectSGIX },
1298 { "glXQueryChannelRectSGIX", (GLvoid *) glXQueryChannelRectSGIX },
1299 { "glXQueryChannelDeltasSGIX", (GLvoid *) glXQueryChannelDeltasSGIX },
1300 { "glXChannelRectSyncSGIX", (GLvoid *) glXChannelRectSyncSGIX },
1301
1302 /*** GLX_SGIX_dmbuffer **/
1303 #if defined(_DM_BUFFER_H_)
1304 { "glXAssociateDMPbufferSGIX", (GLvoid *) glXAssociateDMPbufferSGIX },
1305 #endif
1306
1307 /*** GLX_SGIX_swap_group ***/
1308 { "glXJoinSwapGroupSGIX", (GLvoid *) glXJoinSwapGroupSGIX },
1309
1310 /*** GLX_SGIX_swap_barrier ***/
1311 { "glXBindSwapBarrierSGIX", (GLvoid *) glXBindSwapBarrierSGIX },
1312 { "glXQueryMaxSwapBarriersSGIX", (GLvoid *) glXQueryMaxSwapBarriersSGIX },
1313
1314 /*** GLX_SUN_get_transparent_index ***/
1315 { "glXGetTransparentIndexSUN", (GLvoid *) glXGetTransparentIndexSUN },
1316
1317 /*** GLX_MESA_copy_sub_buffer ***/
1318 { "glXCopySubBufferMESA", (GLvoid *) glXCopySubBufferMESA },
1319
1320 /*** GLX_MESA_pixmap_colormap ***/
1321 { "glXCreateGLXPixmapMESA", (GLvoid *) glXCreateGLXPixmapMESA },
1322
1323 /*** GLX_MESA_release_buffers ***/
1324 { "glXReleaseBuffersMESA", (GLvoid *) glXReleaseBuffersMESA },
1325
1326 /*** GLX_MESA_set_3dfx_mode ***/
1327 { "glXSet3DfxModeMESA", (GLvoid *) glXSet3DfxModeMESA },
1328
1329 /*** GLX_ARB_get_proc_address ***/
1330 { "glXGetProcAddressARB", (GLvoid *) glXGetProcAddressARB },
1331
1332 { NULL, NULL } /* end of list */
1333 };
1334
1335
1336
1337 /*
1338 * Return address of named glX function, or NULL if not found.
1339 */
1340 const GLvoid *
1341 _glxapi_get_proc_address(const char *funcName)
1342 {
1343 GLuint i;
1344 for (i = 0; GLX_functions[i].Name; i++) {
1345 if (strcmp(GLX_functions[i].Name, funcName) == 0)
1346 return GLX_functions[i].Address;
1347 }
1348 return NULL;
1349 }
1350
1351
1352
1353 /*
1354 * This function does not get dispatched through the dispatch table
1355 * since it's really a "meta" function.
1356 */
1357 void (*glXGetProcAddressARB(const GLubyte *procName))()
1358 {
1359 typedef void (*gl_function)();
1360 gl_function f;
1361
1362 f = (gl_function) _glxapi_get_proc_address((const char *) procName);
1363 if (f) {
1364 return f;
1365 }
1366
1367 f = (gl_function) _glapi_get_proc_address((const char *) procName);
1368 return f;
1369 }