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