3 * Mesa 3-D graphics library
6 * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
15 * The above copyright notice and this permission notice shall be included
16 * in all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 * This is the GLX API dispatcher. Calls to the glX* functions are
29 * either routed to the real GLX encoders or to Mesa's pseudo-GLX functions.
30 * See the glxapi.h file for more details.
42 extern struct _glxapi_table
*_real_GetGLXDispatchTable(void);
43 extern struct _glxapi_table
*_mesa_GetGLXDispatchTable(void);
46 struct display_dispatch
{
48 struct _glxapi_table
*Table
;
49 struct display_dispatch
*Next
;
52 static struct display_dispatch
*DispatchList
= NULL
;
55 /* Display -> Dispatch caching */
56 static Display
*prevDisplay
= NULL
;
57 static struct _glxapi_table
*prevTable
= NULL
;
60 static struct _glxapi_table
*
61 get_dispatch(Display
*dpy
)
66 /* search list of display/dispatch pairs for this display */
68 const struct display_dispatch
*d
= DispatchList
;
73 return d
->Table
; /* done! */
79 /* A new display, determine if we should use real GLX
80 * or Mesa's pseudo-GLX.
83 struct _glxapi_table
*t
= NULL
;
85 #ifdef GLX_BUILT_IN_XMESA
86 if (!getenv("LIBGL_FORCE_XMESA")) {
88 if (XQueryExtension( dpy
, "GLX", &ignore
, &ignore
, &ignore
)) {
89 /* the X server has the GLX extension */
90 t
= _real_GetGLXDispatchTable();
96 /* Fallback to Mesa with Xlib driver */
97 #ifdef GLX_BUILT_IN_XMESA
98 if (getenv("LIBGL_DEBUG")) {
100 "libGL: server %s lacks the GLX extension.",
102 fprintf(stderr
, " Using Mesa Xlib renderer.\n");
105 t
= _mesa_GetGLXDispatchTable();
106 assert(t
); /* this has to work */
110 struct display_dispatch
*d
;
111 d
= (struct display_dispatch
*) malloc(sizeof(struct display_dispatch
));
115 /* insert at head of list */
116 d
->Next
= DispatchList
;
126 /* If we get here that means we can't use real GLX on this display
127 * and the Mesa pseudo-GLX software renderer wasn't compiled in.
128 * Or, we ran out of memory!
134 #define GET_DISPATCH(DPY, TABLE) \
135 if (DPY == prevDisplay) { \
142 TABLE = get_dispatch(DPY); \
148 /* Set by glXMakeCurrent() and glXMakeContextCurrent() only */
149 #ifndef GLX_BUILT_IN_XMESA
150 static GLXContext CurrentContext
= 0;
151 #define __glXGetCurrentContext() CurrentContext;
156 * GLX API entrypoints
159 /*** GLX_VERSION_1_0 ***/
161 XVisualInfo
*glXChooseVisual(Display
*dpy
, int screen
, int *list
)
163 struct _glxapi_table
*t
;
164 GET_DISPATCH(dpy
, t
);
167 return (t
->ChooseVisual
)(dpy
, screen
, list
);
171 void glXCopyContext(Display
*dpy
, GLXContext src
, GLXContext dst
, unsigned long mask
)
173 struct _glxapi_table
*t
;
174 GET_DISPATCH(dpy
, t
);
177 (t
->CopyContext
)(dpy
, src
, dst
, mask
);
181 GLXContext
glXCreateContext(Display
*dpy
, XVisualInfo
*visinfo
, GLXContext shareList
, Bool direct
)
183 struct _glxapi_table
*t
;
184 GET_DISPATCH(dpy
, t
);
187 return (t
->CreateContext
)(dpy
, visinfo
, shareList
, direct
);
191 GLXPixmap
glXCreateGLXPixmap(Display
*dpy
, XVisualInfo
*visinfo
, Pixmap pixmap
)
193 struct _glxapi_table
*t
;
194 GET_DISPATCH(dpy
, t
);
197 return (t
->CreateGLXPixmap
)(dpy
, visinfo
, pixmap
);
201 void glXDestroyContext(Display
*dpy
, GLXContext ctx
)
203 struct _glxapi_table
*t
;
204 GET_DISPATCH(dpy
, t
);
207 (t
->DestroyContext
)(dpy
, ctx
);
211 void glXDestroyGLXPixmap(Display
*dpy
, GLXPixmap pixmap
)
213 struct _glxapi_table
*t
;
214 GET_DISPATCH(dpy
, t
);
217 (t
->DestroyGLXPixmap
)(dpy
, pixmap
);
221 int glXGetConfig(Display
*dpy
, XVisualInfo
*visinfo
, int attrib
, int *value
)
223 struct _glxapi_table
*t
;
224 GET_DISPATCH(dpy
, t
);
226 return GLX_NO_EXTENSION
;
227 return (t
->GetConfig
)(dpy
, visinfo
, attrib
, value
);
231 #ifdef GLX_BUILT_IN_XMESA
232 /* Use real libGL's glXGetCurrentContext() function */
234 /* stand-alone Mesa */
235 GLXContext
glXGetCurrentContext(void)
237 return CurrentContext
;
242 #ifdef GLX_BUILT_IN_XMESA
243 /* Use real libGL's glXGetCurrentContext() function */
245 /* stand-alone Mesa */
246 GLXDrawable
glXGetCurrentDrawable(void)
248 __GLXcontext
*gc
= (__GLXcontext
*) glXGetCurrentContext();
249 return gc
? gc
->currentDrawable
: 0;
254 Bool
glXIsDirect(Display
*dpy
, GLXContext ctx
)
256 struct _glxapi_table
*t
;
257 GET_DISPATCH(dpy
, t
);
260 return (t
->IsDirect
)(dpy
, ctx
);
264 Bool
glXMakeCurrent(Display
*dpy
, GLXDrawable drawable
, GLXContext ctx
)
267 struct _glxapi_table
*t
;
268 GET_DISPATCH(dpy
, t
);
272 b
= (*t
->MakeCurrent
)(dpy
, drawable
, ctx
);
273 #ifndef GLX_BUILT_IN_XMESA
275 CurrentContext
= ctx
;
282 Bool
glXQueryExtension(Display
*dpy
, int *errorb
, int *event
)
284 struct _glxapi_table
*t
;
285 GET_DISPATCH(dpy
, t
);
288 return (t
->QueryExtension
)(dpy
, errorb
, event
);
292 Bool
glXQueryVersion(Display
*dpy
, int *maj
, int *min
)
294 struct _glxapi_table
*t
;
295 GET_DISPATCH(dpy
, t
);
298 return (t
->QueryVersion
)(dpy
, maj
, min
);
302 void glXSwapBuffers(Display
*dpy
, GLXDrawable drawable
)
304 struct _glxapi_table
*t
;
305 GET_DISPATCH(dpy
, t
);
308 (t
->SwapBuffers
)(dpy
, drawable
);
312 void glXUseXFont(Font font
, int first
, int count
, int listBase
)
314 struct _glxapi_table
*t
;
315 Display
*dpy
= glXGetCurrentDisplay();
316 GET_DISPATCH(dpy
, t
);
319 (t
->UseXFont
)(font
, first
, count
, listBase
);
325 struct _glxapi_table
*t
;
326 Display
*dpy
= glXGetCurrentDisplay();
327 GET_DISPATCH(dpy
, t
);
336 struct _glxapi_table
*t
;
337 Display
*dpy
= glXGetCurrentDisplay();
338 GET_DISPATCH(dpy
, t
);
346 /*** GLX_VERSION_1_1 ***/
348 const char *glXGetClientString(Display
*dpy
, int name
)
350 struct _glxapi_table
*t
;
351 GET_DISPATCH(dpy
, t
);
354 return (t
->GetClientString
)(dpy
, name
);
358 const char *glXQueryExtensionsString(Display
*dpy
, int screen
)
360 struct _glxapi_table
*t
;
361 GET_DISPATCH(dpy
, t
);
364 return (t
->QueryExtensionsString
)(dpy
, screen
);
368 const char *glXQueryServerString(Display
*dpy
, int screen
, int name
)
370 struct _glxapi_table
*t
;
371 GET_DISPATCH(dpy
, t
);
374 return (t
->QueryServerString
)(dpy
, screen
, name
);
378 /*** GLX_VERSION_1_2 ***/
380 #if !defined(GLX_BUILT_IN_XMESA)
381 Display
*glXGetCurrentDisplay(void)
383 /* Same code as in libGL's glxext.c */
384 __GLXcontext
*gc
= (__GLXcontext
*) glXGetCurrentContext();
385 if (NULL
== gc
) return NULL
;
386 return gc
->currentDpy
;
392 /*** GLX_VERSION_1_3 ***/
394 GLXFBConfig
*glXChooseFBConfig(Display
*dpy
, int screen
, const int *attribList
, int *nitems
)
396 struct _glxapi_table
*t
;
397 GET_DISPATCH(dpy
, t
);
400 return (t
->ChooseFBConfig
)(dpy
, screen
, attribList
, nitems
);
404 GLXContext
glXCreateNewContext(Display
*dpy
, GLXFBConfig config
, int renderType
, GLXContext shareList
, Bool direct
)
406 struct _glxapi_table
*t
;
407 GET_DISPATCH(dpy
, t
);
410 return (t
->CreateNewContext
)(dpy
, config
, renderType
, shareList
, direct
);
414 GLXPbuffer
glXCreatePbuffer(Display
*dpy
, GLXFBConfig config
, const int *attribList
)
416 struct _glxapi_table
*t
;
417 GET_DISPATCH(dpy
, t
);
420 return (t
->CreatePbuffer
)(dpy
, config
, attribList
);
424 GLXPixmap
glXCreatePixmap(Display
*dpy
, GLXFBConfig config
, Pixmap pixmap
, const int *attribList
)
426 struct _glxapi_table
*t
;
427 GET_DISPATCH(dpy
, t
);
430 return (t
->CreatePixmap
)(dpy
, config
, pixmap
, attribList
);
434 GLXWindow
glXCreateWindow(Display
*dpy
, GLXFBConfig config
, Window win
, const int *attribList
)
436 struct _glxapi_table
*t
;
437 GET_DISPATCH(dpy
, t
);
440 return (t
->CreateWindow
)(dpy
, config
, win
, attribList
);
444 void glXDestroyPbuffer(Display
*dpy
, GLXPbuffer pbuf
)
446 struct _glxapi_table
*t
;
447 GET_DISPATCH(dpy
, t
);
450 (t
->DestroyPbuffer
)(dpy
, pbuf
);
454 void glXDestroyPixmap(Display
*dpy
, GLXPixmap pixmap
)
456 struct _glxapi_table
*t
;
457 GET_DISPATCH(dpy
, t
);
460 (t
->DestroyPixmap
)(dpy
, pixmap
);
464 void glXDestroyWindow(Display
*dpy
, GLXWindow window
)
466 struct _glxapi_table
*t
;
467 GET_DISPATCH(dpy
, t
);
470 (t
->DestroyWindow
)(dpy
, window
);
474 #ifdef GLX_BUILT_IN_XMESA
475 /* Use the glXGetCurrentReadDrawable() function from libGL */
477 GLXDrawable
glXGetCurrentReadDrawable(void)
479 __GLXcontext
*gc
= (__GLXcontext
*) glXGetCurrentContext();
480 return gc
? gc
->currentReadable
: 0;
485 int glXGetFBConfigAttrib(Display
*dpy
, GLXFBConfig config
, int attribute
, int *value
)
487 struct _glxapi_table
*t
;
488 GET_DISPATCH(dpy
, t
);
490 return GLX_NO_EXTENSION
;
491 return (t
->GetFBConfigAttrib
)(dpy
, config
, attribute
, value
);
495 GLXFBConfig
*glXGetFBConfigs(Display
*dpy
, int screen
, int *nelements
)
497 struct _glxapi_table
*t
;
498 GET_DISPATCH(dpy
, t
);
501 return (t
->GetFBConfigs
)(dpy
, screen
, nelements
);
504 void glXGetSelectedEvent(Display
*dpy
, GLXDrawable drawable
, unsigned long *mask
)
506 struct _glxapi_table
*t
;
507 GET_DISPATCH(dpy
, t
);
510 (t
->GetSelectedEvent
)(dpy
, drawable
, mask
);
514 XVisualInfo
*glXGetVisualFromFBConfig(Display
*dpy
, GLXFBConfig config
)
516 struct _glxapi_table
*t
;
517 GET_DISPATCH(dpy
, t
);
520 return (t
->GetVisualFromFBConfig
)(dpy
, config
);
524 Bool
glXMakeContextCurrent(Display
*dpy
, GLXDrawable draw
, GLXDrawable read
, GLXContext ctx
)
527 struct _glxapi_table
*t
;
528 GET_DISPATCH(dpy
, t
);
531 b
= (t
->MakeContextCurrent
)(dpy
, draw
, read
, ctx
);
532 #ifndef GLX_BUILT_IN_XMESA
534 CurrentContext
= ctx
;
541 int glXQueryContext(Display
*dpy
, GLXContext ctx
, int attribute
, int *value
)
543 struct _glxapi_table
*t
;
544 GET_DISPATCH(dpy
, t
);
547 return 0; /* XXX correct? */
548 return (t
->QueryContext
)(dpy
, ctx
, attribute
, value
);
552 void glXQueryDrawable(Display
*dpy
, GLXDrawable draw
, int attribute
, unsigned int *value
)
554 struct _glxapi_table
*t
;
555 GET_DISPATCH(dpy
, t
);
558 (t
->QueryDrawable
)(dpy
, draw
, attribute
, value
);
562 void glXSelectEvent(Display
*dpy
, GLXDrawable drawable
, unsigned long mask
)
564 struct _glxapi_table
*t
;
565 GET_DISPATCH(dpy
, t
);
568 (t
->SelectEvent
)(dpy
, drawable
, mask
);
573 /*** GLX_SGI_swap_control ***/
575 int glXSwapIntervalSGI(int interval
)
577 struct _glxapi_table
*t
;
578 Display
*dpy
= glXGetCurrentDisplay();
579 GET_DISPATCH(dpy
, t
);
582 return (t
->SwapIntervalSGI
)(interval
);
587 /*** GLX_SGI_video_sync ***/
589 int glXGetVideoSyncSGI(unsigned int *count
)
591 struct _glxapi_table
*t
;
592 Display
*dpy
= glXGetCurrentDisplay();
593 GET_DISPATCH(dpy
, t
);
596 return (t
->GetVideoSyncSGI
)(count
);
599 int glXWaitVideoSyncSGI(int divisor
, int remainder
, unsigned int *count
)
601 struct _glxapi_table
*t
;
602 Display
*dpy
= glXGetCurrentDisplay();
603 GET_DISPATCH(dpy
, t
);
606 return (t
->WaitVideoSyncSGI
)(divisor
, remainder
, count
);
611 /*** GLX_SGI_make_current_read ***/
613 Bool
glXMakeCurrentReadSGI(Display
*dpy
, GLXDrawable draw
, GLXDrawable read
, GLXContext ctx
)
615 struct _glxapi_table
*t
;
616 GET_DISPATCH(dpy
, t
);
619 return (t
->MakeCurrentReadSGI
)(dpy
, draw
, read
, ctx
);
622 #ifdef GLX_BUILT_IN_XMESA
623 /* Use glXGetCurrentReadDrawableSGI() from libGL */
625 /* stand-alone Mesa */
626 GLXDrawable
glXGetCurrentReadDrawableSGI(void)
628 return glXGetCurrentReadDrawable();
635 GLXVideoSourceSGIX
glXCreateGLXVideoSourceSGIX(Display
*dpy
, int screen
, VLServer server
, VLPath path
, int nodeClass
, VLNode drainNode
)
637 struct _glxapi_table
*t
;
638 GET_DISPATCH(dpy
, t
);
641 return (t
->CreateGLXVideoSourceSGIX
)(dpy
, screen
, server
, path
, nodeClass
, drainNode
);
644 void glXDestroyGLXVideoSourceSGIX(Display
*dpy
, GLXVideoSourceSGIX src
)
646 struct _glxapi_table
*t
;
647 GET_DISPATCH(dpy
, t
);
650 return (t
->DestroyGLXVideoSourceSGIX
)(dpy
, src
);
656 /*** GLX_EXT_import_context ***/
658 void glXFreeContextEXT(Display
*dpy
, GLXContext context
)
660 struct _glxapi_table
*t
;
661 GET_DISPATCH(dpy
, t
);
664 (t
->FreeContextEXT
)(dpy
, context
);
667 #ifdef GLX_BUILT_IN_XMESA
668 /* Use real libGL's glXGetContextIDEXT() function */
670 /* stand-alone Mesa */
671 GLXContextID
glXGetContextIDEXT(const GLXContext context
)
673 return ((__GLXcontext
*) context
)->xid
;
677 #ifdef GLX_BUILT_IN_XMESA
678 /* Use real libGL's glXGetCurrentDisplayEXT() function */
680 /* stand-alone Mesa */
681 Display
*glXGetCurrentDisplayEXT(void)
683 return glXGetCurrentDisplay();
687 GLXContext
glXImportContextEXT(Display
*dpy
, GLXContextID contextID
)
689 struct _glxapi_table
*t
;
690 GET_DISPATCH(dpy
, t
);
693 return (t
->ImportContextEXT
)(dpy
, contextID
);
696 int glXQueryContextInfoEXT(Display
*dpy
, GLXContext context
, int attribute
,int *value
)
698 struct _glxapi_table
*t
;
699 GET_DISPATCH(dpy
, t
);
701 return 0; /* XXX ok? */
702 return (t
->QueryContextInfoEXT
)(dpy
, context
, attribute
, value
);
707 /*** GLX_SGIX_fbconfig ***/
709 int glXGetFBConfigAttribSGIX(Display
*dpy
, GLXFBConfigSGIX config
, int attribute
, int *value
)
711 struct _glxapi_table
*t
;
712 GET_DISPATCH(dpy
, t
);
715 return (t
->GetFBConfigAttribSGIX
)(dpy
, config
, attribute
, value
);
718 GLXFBConfigSGIX
*glXChooseFBConfigSGIX(Display
*dpy
, int screen
, int *attrib_list
, int *nelements
)
720 struct _glxapi_table
*t
;
721 GET_DISPATCH(dpy
, t
);
724 return (t
->ChooseFBConfigSGIX
)(dpy
, screen
, attrib_list
, nelements
);
727 GLXPixmap
glXCreateGLXPixmapWithConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
, Pixmap pixmap
)
729 struct _glxapi_table
*t
;
730 GET_DISPATCH(dpy
, t
);
733 return (t
->CreateGLXPixmapWithConfigSGIX
)(dpy
, config
, pixmap
);
736 GLXContext
glXCreateContextWithConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
, int render_type
, GLXContext share_list
, Bool direct
)
738 struct _glxapi_table
*t
;
739 GET_DISPATCH(dpy
, t
);
742 return (t
->CreateContextWithConfigSGIX
)(dpy
, config
, render_type
, share_list
, direct
);
745 XVisualInfo
* glXGetVisualFromFBConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
)
747 struct _glxapi_table
*t
;
748 GET_DISPATCH(dpy
, t
);
751 return (t
->GetVisualFromFBConfigSGIX
)(dpy
, config
);
754 GLXFBConfigSGIX
glXGetFBConfigFromVisualSGIX(Display
*dpy
, XVisualInfo
*vis
)
756 struct _glxapi_table
*t
;
757 GET_DISPATCH(dpy
, t
);
760 return (t
->GetFBConfigFromVisualSGIX
)(dpy
, vis
);
765 /*** GLX_SGIX_pbuffer ***/
767 GLXPbufferSGIX
glXCreateGLXPbufferSGIX(Display
*dpy
, GLXFBConfigSGIX config
, unsigned int width
, unsigned int height
, int *attrib_list
)
769 struct _glxapi_table
*t
;
770 GET_DISPATCH(dpy
, t
);
773 return (t
->CreateGLXPbufferSGIX
)(dpy
, config
, width
, height
, attrib_list
);
776 void glXDestroyGLXPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuf
)
778 struct _glxapi_table
*t
;
779 GET_DISPATCH(dpy
, t
);
782 (t
->DestroyGLXPbufferSGIX
)(dpy
, pbuf
);
785 int glXQueryGLXPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuf
, int attribute
, unsigned int *value
)
787 struct _glxapi_table
*t
;
788 GET_DISPATCH(dpy
, t
);
791 return (t
->QueryGLXPbufferSGIX
)(dpy
, pbuf
, attribute
, value
);
794 void glXSelectEventSGIX(Display
*dpy
, GLXDrawable drawable
, unsigned long mask
)
796 struct _glxapi_table
*t
;
797 GET_DISPATCH(dpy
, t
);
800 (t
->SelectEventSGIX
)(dpy
, drawable
, mask
);
803 void glXGetSelectedEventSGIX(Display
*dpy
, GLXDrawable drawable
, unsigned long *mask
)
805 struct _glxapi_table
*t
;
806 GET_DISPATCH(dpy
, t
);
809 (t
->GetSelectedEventSGIX
)(dpy
, drawable
, mask
);
814 /*** GLX_SGI_cushion ***/
816 void glXCushionSGI(Display
*dpy
, Window win
, float cushion
)
818 struct _glxapi_table
*t
;
819 GET_DISPATCH(dpy
, t
);
822 (t
->CushionSGI
)(dpy
, win
, cushion
);
827 /*** GLX_SGIX_video_resize ***/
829 int glXBindChannelToWindowSGIX(Display
*dpy
, int screen
, int channel
, Window window
)
831 struct _glxapi_table
*t
;
832 GET_DISPATCH(dpy
, t
);
835 return (t
->BindChannelToWindowSGIX
)(dpy
, screen
, channel
, window
);
838 int glXChannelRectSGIX(Display
*dpy
, int screen
, int channel
, int x
, int y
, int w
, int h
)
840 struct _glxapi_table
*t
;
841 GET_DISPATCH(dpy
, t
);
844 return (t
->ChannelRectSGIX
)(dpy
, screen
, channel
, x
, y
, w
, h
);
847 int glXQueryChannelRectSGIX(Display
*dpy
, int screen
, int channel
, int *x
, int *y
, int *w
, int *h
)
849 struct _glxapi_table
*t
;
850 GET_DISPATCH(dpy
, t
);
853 return (t
->QueryChannelRectSGIX
)(dpy
, screen
, channel
, x
, y
, w
, h
);
856 int glXQueryChannelDeltasSGIX(Display
*dpy
, int screen
, int channel
, int *dx
, int *dy
, int *dw
, int *dh
)
858 struct _glxapi_table
*t
;
859 GET_DISPATCH(dpy
, t
);
862 return (t
->QueryChannelDeltasSGIX
)(dpy
, screen
, channel
, dx
, dy
, dw
, dh
);
865 int glXChannelRectSyncSGIX(Display
*dpy
, int screen
, int channel
, GLenum synctype
)
867 struct _glxapi_table
*t
;
868 GET_DISPATCH(dpy
, t
);
871 return (t
->ChannelRectSyncSGIX
)(dpy
, screen
, channel
, synctype
);
876 #if defined(_DM_BUFFER_H_)
878 Bool
glXAssociateDMPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuffer
, DMparams
*params
, DMbuffer dmbuffer
)
880 struct _glxapi_table
*t
;
881 GET_DISPATCH(dpy
, t
);
884 return (t
->AssociateDMPbufferSGIX
)(dpy
, pbuffer
, params
, dmbuffer
);
890 /*** GLX_SGIX_swap_group ***/
892 void glXJoinSwapGroupSGIX(Display
*dpy
, GLXDrawable drawable
, GLXDrawable member
)
894 struct _glxapi_table
*t
;
895 GET_DISPATCH(dpy
, t
);
898 (*t
->JoinSwapGroupSGIX
)(dpy
, drawable
, member
);
902 /*** GLX_SGIX_swap_barrier ***/
904 void glXBindSwapBarrierSGIX(Display
*dpy
, GLXDrawable drawable
, int barrier
)
906 struct _glxapi_table
*t
;
907 GET_DISPATCH(dpy
, t
);
910 (*t
->BindSwapBarrierSGIX
)(dpy
, drawable
, barrier
);
913 Bool
glXQueryMaxSwapBarriersSGIX(Display
*dpy
, int screen
, int *max
)
915 struct _glxapi_table
*t
;
916 GET_DISPATCH(dpy
, t
);
919 return (*t
->QueryMaxSwapBarriersSGIX
)(dpy
, screen
, max
);
924 /*** GLX_SUN_get_transparent_index ***/
926 Status
glXGetTransparentIndexSUN(Display
*dpy
, Window overlay
, Window underlay
, long *pTransparent
)
928 struct _glxapi_table
*t
;
929 GET_DISPATCH(dpy
, t
);
932 return (*t
->GetTransparentIndexSUN
)(dpy
, overlay
, underlay
, pTransparent
);
937 /*** GLX_MESA_copy_sub_buffer ***/
939 void glXCopySubBufferMESA(Display
*dpy
, GLXDrawable drawable
, int x
, int y
, int width
, int height
)
941 struct _glxapi_table
*t
;
942 GET_DISPATCH(dpy
, t
);
945 (t
->CopySubBufferMESA
)(dpy
, drawable
, x
, y
, width
, height
);
950 /*** GLX_MESA_release_buffers ***/
952 Bool
glXReleaseBuffersMESA(Display
*dpy
, Window w
)
954 struct _glxapi_table
*t
;
955 GET_DISPATCH(dpy
, t
);
958 return (t
->ReleaseBuffersMESA
)(dpy
, w
);
963 /*** GLX_MESA_pixmap_colormap ***/
965 GLXPixmap
glXCreateGLXPixmapMESA(Display
*dpy
, XVisualInfo
*visinfo
, Pixmap pixmap
, Colormap cmap
)
967 struct _glxapi_table
*t
;
968 GET_DISPATCH(dpy
, t
);
971 return (t
->CreateGLXPixmapMESA
)(dpy
, visinfo
, pixmap
, cmap
);
976 /*** GLX_MESA_set_3dfx_mode ***/
978 Bool
glXSet3DfxModeMESA(int mode
)
980 struct _glxapi_table
*t
;
981 Display
*dpy
= glXGetCurrentDisplay();
982 GET_DISPATCH(dpy
, t
);
985 return (t
->Set3DfxModeMESA
)(mode
);
990 /*** GLX_NV_vertex_array_range ***/
993 glXAllocateMemoryNV( GLsizei size
,
994 GLfloat readFrequency
,
995 GLfloat writeFrequency
,
998 struct _glxapi_table
*t
;
999 Display
*dpy
= glXGetCurrentDisplay();
1000 GET_DISPATCH(dpy
, t
);
1003 return (t
->AllocateMemoryNV
)(size
, readFrequency
, writeFrequency
, priority
);
1008 glXFreeMemoryNV( GLvoid
*pointer
)
1010 struct _glxapi_table
*t
;
1011 Display
*dpy
= glXGetCurrentDisplay();
1012 GET_DISPATCH(dpy
, t
);
1015 (t
->FreeMemoryNV
)(pointer
);
1019 /*** GLX_MESA_agp_offset */
1022 glXGetAGPOffsetMESA( const GLvoid
*pointer
)
1024 struct _glxapi_table
*t
;
1025 Display
*dpy
= glXGetCurrentDisplay();
1026 GET_DISPATCH(dpy
, t
);
1029 return (t
->GetAGPOffsetMESA
)(pointer
);
1033 /*** GLX_ARB_render_Texture ***/
1036 glXBindTexImageARB( Display
*dpy
, GLXPbuffer pbuffer
, int buffer
)
1038 struct _glxapi_table
*t
;
1039 GET_DISPATCH(dpy
, t
);
1042 return (t
->BindTexImageARB
)(dpy
, pbuffer
, buffer
);
1047 glXReleaseTexImageARB(Display
*dpy
, GLXPbuffer pbuffer
, int buffer
)
1049 struct _glxapi_table
*t
;
1050 GET_DISPATCH(dpy
, t
);
1053 return (t
->ReleaseTexImageARB
)(dpy
, pbuffer
, buffer
);
1058 glXDrawableAttribARB( Display
*dpy
, GLXDrawable draw
, const int *attribList
)
1060 struct _glxapi_table
*t
;
1061 GET_DISPATCH(dpy
, t
);
1064 return (t
->DrawableAttribARB
)(dpy
, draw
, attribList
);
1069 /**********************************************************************/
1070 /* GLX API management functions */
1071 /**********************************************************************/
1075 _glxapi_get_version(void)
1082 * Return array of extension strings.
1085 _glxapi_get_extensions(void)
1087 static const char *extensions
[] = {
1088 #ifdef GLX_EXT_import_context
1089 "GLX_EXT_import_context",
1091 #ifdef GLX_SGI_video_sync
1092 "GLX_SGI_video_sync",
1094 #ifdef GLX_MESA_copy_sub_buffer
1095 "GLX_MESA_copy_sub_buffer",
1097 #ifdef GLX_MESA_release_buffers
1098 "GLX_MESA_release_buffers",
1100 #ifdef GLX_MESA_pixmap_colormap
1101 "GLX_MESA_pixmap_colormap",
1103 #ifdef GLX_MESA_set_3dfx_mode
1104 "GLX_MESA_set_3dfx_mode",
1106 #ifdef GLX_SGIX_fbconfig
1107 "GLX_SGIX_fbconfig",
1109 #ifdef GLX_SGIX_pbuffer
1112 #ifdef GLX_ARB_render_texture
1113 "GLX_ARB_render_texture",
1122 * Return size of the GLX dispatch table, in entries, not bytes.
1125 _glxapi_get_dispatch_table_size(void)
1127 return sizeof(struct _glxapi_table
) / sizeof(void *);
1132 generic_no_op_func(void)
1139 * Initialize all functions in given dispatch table to be no-ops
1142 _glxapi_set_no_op_table(struct _glxapi_table
*t
)
1144 GLuint n
= _glxapi_get_dispatch_table_size();
1146 void **dispatch
= (void **) t
;
1147 for (i
= 0; i
< n
; i
++) {
1148 dispatch
[i
] = (void *) generic_no_op_func
;
1153 struct name_address_pair
{
1158 static struct name_address_pair GLX_functions
[] = {
1159 /*** GLX_VERSION_1_0 ***/
1160 { "glXChooseVisual", (GLvoid
*) glXChooseVisual
},
1161 { "glXCopyContext", (GLvoid
*) glXCopyContext
},
1162 { "glXCreateContext", (GLvoid
*) glXCreateContext
},
1163 { "glXCreateGLXPixmap", (GLvoid
*) glXCreateGLXPixmap
},
1164 { "glXDestroyContext", (GLvoid
*) glXDestroyContext
},
1165 { "glXDestroyGLXPixmap", (GLvoid
*) glXDestroyGLXPixmap
},
1166 { "glXGetConfig", (GLvoid
*) glXGetConfig
},
1167 { "glXGetCurrentContext", (GLvoid
*) glXGetCurrentContext
},
1168 { "glXGetCurrentDrawable", (GLvoid
*) glXGetCurrentDrawable
},
1169 { "glXIsDirect", (GLvoid
*) glXIsDirect
},
1170 { "glXMakeCurrent", (GLvoid
*) glXMakeCurrent
},
1171 { "glXQueryExtension", (GLvoid
*) glXQueryExtension
},
1172 { "glXQueryVersion", (GLvoid
*) glXQueryVersion
},
1173 { "glXSwapBuffers", (GLvoid
*) glXSwapBuffers
},
1174 { "glXUseXFont", (GLvoid
*) glXUseXFont
},
1175 { "glXWaitGL", (GLvoid
*) glXWaitGL
},
1176 { "glXWaitX", (GLvoid
*) glXWaitX
},
1178 /*** GLX_VERSION_1_1 ***/
1179 { "glXGetClientString", (GLvoid
*) glXGetClientString
},
1180 { "glXQueryExtensionsString", (GLvoid
*) glXQueryExtensionsString
},
1181 { "glXQueryServerString", (GLvoid
*) glXQueryServerString
},
1183 /*** GLX_VERSION_1_2 ***/
1184 { "glXGetCurrentDisplay", (GLvoid
*) glXGetCurrentDisplay
},
1186 /*** GLX_VERSION_1_3 ***/
1187 { "glXChooseFBConfig", (GLvoid
*) glXChooseFBConfig
},
1188 { "glXCreateNewContext", (GLvoid
*) glXCreateNewContext
},
1189 { "glXCreatePbuffer", (GLvoid
*) glXCreatePbuffer
},
1190 { "glXCreatePixmap", (GLvoid
*) glXCreatePixmap
},
1191 { "glXCreateWindow", (GLvoid
*) glXCreateWindow
},
1192 { "glXDestroyPbuffer", (GLvoid
*) glXDestroyPbuffer
},
1193 { "glXDestroyPixmap", (GLvoid
*) glXDestroyPixmap
},
1194 { "glXDestroyWindow", (GLvoid
*) glXDestroyWindow
},
1195 { "glXGetCurrentReadDrawable", (GLvoid
*) glXGetCurrentReadDrawable
},
1196 { "glXGetFBConfigAttrib", (GLvoid
*) glXGetFBConfigAttrib
},
1197 { "glXGetFBConfigs", (GLvoid
*) glXGetFBConfigs
},
1198 { "glXGetSelectedEvent", (GLvoid
*) glXGetSelectedEvent
},
1199 { "glXGetVisualFromFBConfig", (GLvoid
*) glXGetVisualFromFBConfig
},
1200 { "glXMakeContextCurrent", (GLvoid
*) glXMakeContextCurrent
},
1201 { "glXQueryContext", (GLvoid
*) glXQueryContext
},
1202 { "glXQueryDrawable", (GLvoid
*) glXQueryDrawable
},
1203 { "glXSelectEvent", (GLvoid
*) glXSelectEvent
},
1205 /*** GLX_VERSION_1_4 ***/
1206 { "glXGetProcAddress", (GLvoid
*) glXGetProcAddress
},
1208 /*** GLX_SGI_swap_control ***/
1209 { "glXSwapIntervalSGI", (GLvoid
*) glXSwapIntervalSGI
},
1211 /*** GLX_SGI_video_sync ***/
1212 { "glXGetVideoSyncSGI", (GLvoid
*) glXGetVideoSyncSGI
},
1213 { "glXWaitVideoSyncSGI", (GLvoid
*) glXWaitVideoSyncSGI
},
1215 /*** GLX_SGI_make_current_read ***/
1216 { "glXMakeCurrentReadSGI", (GLvoid
*) glXMakeCurrentReadSGI
},
1217 { "glXGetCurrentReadDrawableSGI", (GLvoid
*) glXGetCurrentReadDrawableSGI
},
1219 /*** GLX_SGIX_video_source ***/
1221 { "glXCreateGLXVideoSourceSGIX", (GLvoid
*) glXCreateGLXVideoSourceSGIX
},
1222 { "glXDestroyGLXVideoSourceSGIX", (GLvoid
*) glXDestroyGLXVideoSourceSGIX
},
1225 /*** GLX_EXT_import_context ***/
1226 { "glXFreeContextEXT", (GLvoid
*) glXFreeContextEXT
},
1227 { "glXGetContextIDEXT", (GLvoid
*) glXGetContextIDEXT
},
1228 { "glXGetCurrentDisplayEXT", (GLvoid
*) glXGetCurrentDisplayEXT
},
1229 { "glXImportContextEXT", (GLvoid
*) glXImportContextEXT
},
1230 { "glXQueryContextInfoEXT", (GLvoid
*) glXQueryContextInfoEXT
},
1232 /*** GLX_SGIX_fbconfig ***/
1233 { "glXGetFBConfigAttribSGIX", (GLvoid
*) glXGetFBConfigAttribSGIX
},
1234 { "glXChooseFBConfigSGIX", (GLvoid
*) glXChooseFBConfigSGIX
},
1235 { "glXCreateGLXPixmapWithConfigSGIX", (GLvoid
*) glXCreateGLXPixmapWithConfigSGIX
},
1236 { "glXCreateContextWithConfigSGIX", (GLvoid
*) glXCreateContextWithConfigSGIX
},
1237 { "glXGetVisualFromFBConfigSGIX", (GLvoid
*) glXGetVisualFromFBConfigSGIX
},
1238 { "glXGetFBConfigFromVisualSGIX", (GLvoid
*) glXGetFBConfigFromVisualSGIX
},
1240 /*** GLX_SGIX_pbuffer ***/
1241 { "glXCreateGLXPbufferSGIX", (GLvoid
*) glXCreateGLXPbufferSGIX
},
1242 { "glXDestroyGLXPbufferSGIX", (GLvoid
*) glXDestroyGLXPbufferSGIX
},
1243 { "glXQueryGLXPbufferSGIX", (GLvoid
*) glXQueryGLXPbufferSGIX
},
1244 { "glXSelectEventSGIX", (GLvoid
*) glXSelectEventSGIX
},
1245 { "glXGetSelectedEventSGIX", (GLvoid
*) glXGetSelectedEventSGIX
},
1247 /*** GLX_SGI_cushion ***/
1248 { "glXCushionSGI", (GLvoid
*) glXCushionSGI
},
1250 /*** GLX_SGIX_video_resize ***/
1251 { "glXBindChannelToWindowSGIX", (GLvoid
*) glXBindChannelToWindowSGIX
},
1252 { "glXChannelRectSGIX", (GLvoid
*) glXChannelRectSGIX
},
1253 { "glXQueryChannelRectSGIX", (GLvoid
*) glXQueryChannelRectSGIX
},
1254 { "glXQueryChannelDeltasSGIX", (GLvoid
*) glXQueryChannelDeltasSGIX
},
1255 { "glXChannelRectSyncSGIX", (GLvoid
*) glXChannelRectSyncSGIX
},
1257 /*** GLX_SGIX_dmbuffer **/
1258 #if defined(_DM_BUFFER_H_)
1259 { "glXAssociateDMPbufferSGIX", (GLvoid
*) glXAssociateDMPbufferSGIX
},
1262 /*** GLX_SGIX_swap_group ***/
1263 { "glXJoinSwapGroupSGIX", (GLvoid
*) glXJoinSwapGroupSGIX
},
1265 /*** GLX_SGIX_swap_barrier ***/
1266 { "glXBindSwapBarrierSGIX", (GLvoid
*) glXBindSwapBarrierSGIX
},
1267 { "glXQueryMaxSwapBarriersSGIX", (GLvoid
*) glXQueryMaxSwapBarriersSGIX
},
1269 /*** GLX_SUN_get_transparent_index ***/
1270 { "glXGetTransparentIndexSUN", (GLvoid
*) glXGetTransparentIndexSUN
},
1272 /*** GLX_MESA_copy_sub_buffer ***/
1273 { "glXCopySubBufferMESA", (GLvoid
*) glXCopySubBufferMESA
},
1275 /*** GLX_MESA_pixmap_colormap ***/
1276 { "glXCreateGLXPixmapMESA", (GLvoid
*) glXCreateGLXPixmapMESA
},
1278 /*** GLX_MESA_release_buffers ***/
1279 { "glXReleaseBuffersMESA", (GLvoid
*) glXReleaseBuffersMESA
},
1281 /*** GLX_MESA_set_3dfx_mode ***/
1282 { "glXSet3DfxModeMESA", (GLvoid
*) glXSet3DfxModeMESA
},
1284 /*** GLX_ARB_get_proc_address ***/
1285 { "glXGetProcAddressARB", (GLvoid
*) glXGetProcAddressARB
},
1287 /*** GLX_NV_vertex_array_range ***/
1288 { "glXAllocateMemoryNV", (GLvoid
*) glXAllocateMemoryNV
},
1289 { "glXFreeMemoryNV", (GLvoid
*) glXFreeMemoryNV
},
1291 /*** GLX_MESA_agp_offset ***/
1292 { "glXGetAGPOffsetMESA", (GLvoid
*) glXGetAGPOffsetMESA
},
1294 /*** GLX_ARB_render_texture ***/
1295 { "glXBindTexImageARB", (GLvoid
*) glXBindTexImageARB
},
1296 { "glXReleaseTexImageARB", (GLvoid
*) glXReleaseTexImageARB
},
1297 { "glXDrawableAttribARB", (GLvoid
*) glXDrawableAttribARB
},
1299 { NULL
, NULL
} /* end of list */
1305 * Return address of named glX function, or NULL if not found.
1308 _glxapi_get_proc_address(const char *funcName
)
1311 for (i
= 0; GLX_functions
[i
].Name
; i
++) {
1312 if (strcmp(GLX_functions
[i
].Name
, funcName
) == 0)
1313 return GLX_functions
[i
].Address
;
1321 * This function does not get dispatched through the dispatch table
1322 * since it's really a "meta" function.
1324 void (*glXGetProcAddressARB(const GLubyte
*procName
))()
1326 typedef void (*gl_function
)();
1329 f
= (gl_function
) _glxapi_get_proc_address((const char *) procName
);
1334 f
= (gl_function
) _glapi_get_proc_address((const char *) procName
);
1340 void (*glXGetProcAddress(const GLubyte
*procName
))()
1342 return glXGetProcAddressARB(procName
);