2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
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:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
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.
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.
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 ***/
162 glXChooseVisual(Display
*dpy
, int screen
, int *list
)
164 struct _glxapi_table
*t
;
165 GET_DISPATCH(dpy
, t
);
168 return (t
->ChooseVisual
)(dpy
, screen
, list
);
173 glXCopyContext(Display
*dpy
, GLXContext src
, GLXContext dst
, unsigned long mask
)
175 struct _glxapi_table
*t
;
176 GET_DISPATCH(dpy
, t
);
179 (t
->CopyContext
)(dpy
, src
, dst
, mask
);
184 glXCreateContext(Display
*dpy
, XVisualInfo
*visinfo
, GLXContext shareList
, Bool direct
)
186 struct _glxapi_table
*t
;
187 GET_DISPATCH(dpy
, t
);
190 return (t
->CreateContext
)(dpy
, visinfo
, shareList
, direct
);
195 glXCreateGLXPixmap(Display
*dpy
, XVisualInfo
*visinfo
, Pixmap pixmap
)
197 struct _glxapi_table
*t
;
198 GET_DISPATCH(dpy
, t
);
201 return (t
->CreateGLXPixmap
)(dpy
, visinfo
, pixmap
);
206 glXDestroyContext(Display
*dpy
, GLXContext ctx
)
208 struct _glxapi_table
*t
;
209 GET_DISPATCH(dpy
, t
);
212 (t
->DestroyContext
)(dpy
, ctx
);
217 glXDestroyGLXPixmap(Display
*dpy
, GLXPixmap pixmap
)
219 struct _glxapi_table
*t
;
220 GET_DISPATCH(dpy
, t
);
223 (t
->DestroyGLXPixmap
)(dpy
, pixmap
);
228 glXGetConfig(Display
*dpy
, XVisualInfo
*visinfo
, int attrib
, int *value
)
230 struct _glxapi_table
*t
;
231 GET_DISPATCH(dpy
, t
);
233 return GLX_NO_EXTENSION
;
234 return (t
->GetConfig
)(dpy
, visinfo
, attrib
, value
);
238 #ifdef GLX_BUILT_IN_XMESA
239 /* Use real libGL's glXGetCurrentContext() function */
241 /* stand-alone Mesa */
243 glXGetCurrentContext(void)
245 return CurrentContext
;
250 #ifdef GLX_BUILT_IN_XMESA
251 /* Use real libGL's glXGetCurrentContext() function */
253 /* stand-alone Mesa */
255 glXGetCurrentDrawable(void)
257 __GLXcontext
*gc
= (__GLXcontext
*) glXGetCurrentContext();
258 return gc
? gc
->currentDrawable
: 0;
264 glXIsDirect(Display
*dpy
, GLXContext ctx
)
266 struct _glxapi_table
*t
;
267 GET_DISPATCH(dpy
, t
);
270 return (t
->IsDirect
)(dpy
, ctx
);
275 glXMakeCurrent(Display
*dpy
, GLXDrawable drawable
, GLXContext ctx
)
278 struct _glxapi_table
*t
;
279 GET_DISPATCH(dpy
, t
);
283 b
= (*t
->MakeCurrent
)(dpy
, drawable
, ctx
);
284 #ifndef GLX_BUILT_IN_XMESA
286 CurrentContext
= ctx
;
294 glXQueryExtension(Display
*dpy
, int *errorb
, int *event
)
296 struct _glxapi_table
*t
;
297 GET_DISPATCH(dpy
, t
);
300 return (t
->QueryExtension
)(dpy
, errorb
, event
);
305 glXQueryVersion(Display
*dpy
, int *maj
, int *min
)
307 struct _glxapi_table
*t
;
308 GET_DISPATCH(dpy
, t
);
311 return (t
->QueryVersion
)(dpy
, maj
, min
);
316 glXSwapBuffers(Display
*dpy
, GLXDrawable drawable
)
318 struct _glxapi_table
*t
;
319 GET_DISPATCH(dpy
, t
);
322 (t
->SwapBuffers
)(dpy
, drawable
);
327 glXUseXFont(Font font
, int first
, int count
, int listBase
)
329 struct _glxapi_table
*t
;
330 Display
*dpy
= glXGetCurrentDisplay();
331 GET_DISPATCH(dpy
, t
);
334 (t
->UseXFont
)(font
, first
, count
, listBase
);
341 struct _glxapi_table
*t
;
342 Display
*dpy
= glXGetCurrentDisplay();
343 GET_DISPATCH(dpy
, t
);
353 struct _glxapi_table
*t
;
354 Display
*dpy
= glXGetCurrentDisplay();
355 GET_DISPATCH(dpy
, t
);
363 /*** GLX_VERSION_1_1 ***/
366 glXGetClientString(Display
*dpy
, int name
)
368 struct _glxapi_table
*t
;
369 GET_DISPATCH(dpy
, t
);
372 return (t
->GetClientString
)(dpy
, name
);
377 glXQueryExtensionsString(Display
*dpy
, int screen
)
379 struct _glxapi_table
*t
;
380 GET_DISPATCH(dpy
, t
);
383 return (t
->QueryExtensionsString
)(dpy
, screen
);
388 glXQueryServerString(Display
*dpy
, int screen
, int name
)
390 struct _glxapi_table
*t
;
391 GET_DISPATCH(dpy
, t
);
394 return (t
->QueryServerString
)(dpy
, screen
, name
);
398 /*** GLX_VERSION_1_2 ***/
400 #if !defined(GLX_BUILT_IN_XMESA)
402 glXGetCurrentDisplay(void)
404 /* Same code as in libGL's glxext.c */
405 __GLXcontext
*gc
= (__GLXcontext
*) glXGetCurrentContext();
406 if (NULL
== gc
) return NULL
;
407 return gc
->currentDpy
;
413 /*** GLX_VERSION_1_3 ***/
416 glXChooseFBConfig(Display
*dpy
, int screen
, const int *attribList
, int *nitems
)
418 struct _glxapi_table
*t
;
419 GET_DISPATCH(dpy
, t
);
422 return (t
->ChooseFBConfig
)(dpy
, screen
, attribList
, nitems
);
427 glXCreateNewContext(Display
*dpy
, GLXFBConfig config
, int renderType
, GLXContext shareList
, Bool direct
)
429 struct _glxapi_table
*t
;
430 GET_DISPATCH(dpy
, t
);
433 return (t
->CreateNewContext
)(dpy
, config
, renderType
, shareList
, direct
);
438 glXCreatePbuffer(Display
*dpy
, GLXFBConfig config
, const int *attribList
)
440 struct _glxapi_table
*t
;
441 GET_DISPATCH(dpy
, t
);
444 return (t
->CreatePbuffer
)(dpy
, config
, attribList
);
449 glXCreatePixmap(Display
*dpy
, GLXFBConfig config
, Pixmap pixmap
, const int *attribList
)
451 struct _glxapi_table
*t
;
452 GET_DISPATCH(dpy
, t
);
455 return (t
->CreatePixmap
)(dpy
, config
, pixmap
, attribList
);
460 glXCreateWindow(Display
*dpy
, GLXFBConfig config
, Window win
, const int *attribList
)
462 struct _glxapi_table
*t
;
463 GET_DISPATCH(dpy
, t
);
466 return (t
->CreateWindow
)(dpy
, config
, win
, attribList
);
471 glXDestroyPbuffer(Display
*dpy
, GLXPbuffer pbuf
)
473 struct _glxapi_table
*t
;
474 GET_DISPATCH(dpy
, t
);
477 (t
->DestroyPbuffer
)(dpy
, pbuf
);
482 glXDestroyPixmap(Display
*dpy
, GLXPixmap pixmap
)
484 struct _glxapi_table
*t
;
485 GET_DISPATCH(dpy
, t
);
488 (t
->DestroyPixmap
)(dpy
, pixmap
);
493 glXDestroyWindow(Display
*dpy
, GLXWindow window
)
495 struct _glxapi_table
*t
;
496 GET_DISPATCH(dpy
, t
);
499 (t
->DestroyWindow
)(dpy
, window
);
503 #ifdef GLX_BUILT_IN_XMESA
504 /* Use the glXGetCurrentReadDrawable() function from libGL */
507 glXGetCurrentReadDrawable(void)
509 __GLXcontext
*gc
= (__GLXcontext
*) glXGetCurrentContext();
510 return gc
? gc
->currentReadable
: 0;
516 glXGetFBConfigAttrib(Display
*dpy
, GLXFBConfig config
, int attribute
, int *value
)
518 struct _glxapi_table
*t
;
519 GET_DISPATCH(dpy
, t
);
521 return GLX_NO_EXTENSION
;
522 return (t
->GetFBConfigAttrib
)(dpy
, config
, attribute
, value
);
527 glXGetFBConfigs(Display
*dpy
, int screen
, int *nelements
)
529 struct _glxapi_table
*t
;
530 GET_DISPATCH(dpy
, t
);
533 return (t
->GetFBConfigs
)(dpy
, screen
, nelements
);
537 glXGetSelectedEvent(Display
*dpy
, GLXDrawable drawable
, unsigned long *mask
)
539 struct _glxapi_table
*t
;
540 GET_DISPATCH(dpy
, t
);
543 (t
->GetSelectedEvent
)(dpy
, drawable
, mask
);
548 glXGetVisualFromFBConfig(Display
*dpy
, GLXFBConfig config
)
550 struct _glxapi_table
*t
;
551 GET_DISPATCH(dpy
, t
);
554 return (t
->GetVisualFromFBConfig
)(dpy
, config
);
559 glXMakeContextCurrent(Display
*dpy
, GLXDrawable draw
, GLXDrawable read
, GLXContext ctx
)
562 struct _glxapi_table
*t
;
563 GET_DISPATCH(dpy
, t
);
566 b
= (t
->MakeContextCurrent
)(dpy
, draw
, read
, ctx
);
567 #ifndef GLX_BUILT_IN_XMESA
569 CurrentContext
= ctx
;
577 glXQueryContext(Display
*dpy
, GLXContext ctx
, int attribute
, int *value
)
579 struct _glxapi_table
*t
;
580 GET_DISPATCH(dpy
, t
);
583 return 0; /* XXX correct? */
584 return (t
->QueryContext
)(dpy
, ctx
, attribute
, value
);
589 glXQueryDrawable(Display
*dpy
, GLXDrawable draw
, int attribute
, unsigned int *value
)
591 struct _glxapi_table
*t
;
592 GET_DISPATCH(dpy
, t
);
595 (t
->QueryDrawable
)(dpy
, draw
, attribute
, value
);
600 glXSelectEvent(Display
*dpy
, GLXDrawable drawable
, unsigned long mask
)
602 struct _glxapi_table
*t
;
603 GET_DISPATCH(dpy
, t
);
606 (t
->SelectEvent
)(dpy
, drawable
, mask
);
611 /*** GLX_SGI_swap_control ***/
614 glXSwapIntervalSGI(int interval
)
616 struct _glxapi_table
*t
;
617 Display
*dpy
= glXGetCurrentDisplay();
618 GET_DISPATCH(dpy
, t
);
621 return (t
->SwapIntervalSGI
)(interval
);
626 /*** GLX_SGI_video_sync ***/
629 glXGetVideoSyncSGI(unsigned int *count
)
631 struct _glxapi_table
*t
;
632 Display
*dpy
= glXGetCurrentDisplay();
633 GET_DISPATCH(dpy
, t
);
636 return (t
->GetVideoSyncSGI
)(count
);
640 glXWaitVideoSyncSGI(int divisor
, int remainder
, unsigned int *count
)
642 struct _glxapi_table
*t
;
643 Display
*dpy
= glXGetCurrentDisplay();
644 GET_DISPATCH(dpy
, t
);
647 return (t
->WaitVideoSyncSGI
)(divisor
, remainder
, count
);
652 /*** GLX_SGI_make_current_read ***/
655 glXMakeCurrentReadSGI(Display
*dpy
, GLXDrawable draw
, GLXDrawable read
, GLXContext ctx
)
657 struct _glxapi_table
*t
;
658 GET_DISPATCH(dpy
, t
);
661 return (t
->MakeCurrentReadSGI
)(dpy
, draw
, read
, ctx
);
664 #ifdef GLX_BUILT_IN_XMESA
665 /* Use glXGetCurrentReadDrawableSGI() from libGL */
667 /* stand-alone Mesa */
669 glXGetCurrentReadDrawableSGI(void)
671 return glXGetCurrentReadDrawable();
678 GLXVideoSourceSGIX PUBLIC
679 glXCreateGLXVideoSourceSGIX(Display
*dpy
, int screen
, VLServer server
, VLPath path
, int nodeClass
, VLNode drainNode
)
681 struct _glxapi_table
*t
;
682 GET_DISPATCH(dpy
, t
);
685 return (t
->CreateGLXVideoSourceSGIX
)(dpy
, screen
, server
, path
, nodeClass
, drainNode
);
689 glXDestroyGLXVideoSourceSGIX(Display
*dpy
, GLXVideoSourceSGIX src
)
691 struct _glxapi_table
*t
;
692 GET_DISPATCH(dpy
, t
);
695 return (t
->DestroyGLXVideoSourceSGIX
)(dpy
, src
);
701 /*** GLX_EXT_import_context ***/
704 glXFreeContextEXT(Display
*dpy
, GLXContext context
)
706 struct _glxapi_table
*t
;
707 GET_DISPATCH(dpy
, t
);
710 (t
->FreeContextEXT
)(dpy
, context
);
713 #ifdef GLX_BUILT_IN_XMESA
714 /* Use real libGL's glXGetContextIDEXT() function */
716 /* stand-alone Mesa */
718 glXGetContextIDEXT(const GLXContext context
)
720 return ((__GLXcontext
*) context
)->xid
;
724 #ifdef GLX_BUILT_IN_XMESA
725 /* Use real libGL's glXGetCurrentDisplayEXT() function */
727 /* stand-alone Mesa */
729 glXGetCurrentDisplayEXT(void)
731 return glXGetCurrentDisplay();
736 glXImportContextEXT(Display
*dpy
, GLXContextID contextID
)
738 struct _glxapi_table
*t
;
739 GET_DISPATCH(dpy
, t
);
742 return (t
->ImportContextEXT
)(dpy
, contextID
);
746 glXQueryContextInfoEXT(Display
*dpy
, GLXContext context
, int attribute
,int *value
)
748 struct _glxapi_table
*t
;
749 GET_DISPATCH(dpy
, t
);
751 return 0; /* XXX ok? */
752 return (t
->QueryContextInfoEXT
)(dpy
, context
, attribute
, value
);
757 /*** GLX_SGIX_fbconfig ***/
760 glXGetFBConfigAttribSGIX(Display
*dpy
, GLXFBConfigSGIX config
, int attribute
, int *value
)
762 struct _glxapi_table
*t
;
763 GET_DISPATCH(dpy
, t
);
766 return (t
->GetFBConfigAttribSGIX
)(dpy
, config
, attribute
, value
);
769 GLXFBConfigSGIX PUBLIC
*
770 glXChooseFBConfigSGIX(Display
*dpy
, int screen
, int *attrib_list
, int *nelements
)
772 struct _glxapi_table
*t
;
773 GET_DISPATCH(dpy
, t
);
776 return (t
->ChooseFBConfigSGIX
)(dpy
, screen
, attrib_list
, nelements
);
780 glXCreateGLXPixmapWithConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
, Pixmap pixmap
)
782 struct _glxapi_table
*t
;
783 GET_DISPATCH(dpy
, t
);
786 return (t
->CreateGLXPixmapWithConfigSGIX
)(dpy
, config
, pixmap
);
790 glXCreateContextWithConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
, int render_type
, GLXContext share_list
, Bool direct
)
792 struct _glxapi_table
*t
;
793 GET_DISPATCH(dpy
, t
);
796 return (t
->CreateContextWithConfigSGIX
)(dpy
, config
, render_type
, share_list
, direct
);
800 glXGetVisualFromFBConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
)
802 struct _glxapi_table
*t
;
803 GET_DISPATCH(dpy
, t
);
806 return (t
->GetVisualFromFBConfigSGIX
)(dpy
, config
);
809 GLXFBConfigSGIX PUBLIC
810 glXGetFBConfigFromVisualSGIX(Display
*dpy
, XVisualInfo
*vis
)
812 struct _glxapi_table
*t
;
813 GET_DISPATCH(dpy
, t
);
816 return (t
->GetFBConfigFromVisualSGIX
)(dpy
, vis
);
821 /*** GLX_SGIX_pbuffer ***/
823 GLXPbufferSGIX PUBLIC
824 glXCreateGLXPbufferSGIX(Display
*dpy
, GLXFBConfigSGIX config
, unsigned int width
, unsigned int height
, int *attrib_list
)
826 struct _glxapi_table
*t
;
827 GET_DISPATCH(dpy
, t
);
830 return (t
->CreateGLXPbufferSGIX
)(dpy
, config
, width
, height
, attrib_list
);
834 glXDestroyGLXPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuf
)
836 struct _glxapi_table
*t
;
837 GET_DISPATCH(dpy
, t
);
840 (t
->DestroyGLXPbufferSGIX
)(dpy
, pbuf
);
844 glXQueryGLXPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuf
, int attribute
, unsigned int *value
)
846 struct _glxapi_table
*t
;
847 GET_DISPATCH(dpy
, t
);
850 return (t
->QueryGLXPbufferSGIX
)(dpy
, pbuf
, attribute
, value
);
854 glXSelectEventSGIX(Display
*dpy
, GLXDrawable drawable
, unsigned long mask
)
856 struct _glxapi_table
*t
;
857 GET_DISPATCH(dpy
, t
);
860 (t
->SelectEventSGIX
)(dpy
, drawable
, mask
);
864 glXGetSelectedEventSGIX(Display
*dpy
, GLXDrawable drawable
, unsigned long *mask
)
866 struct _glxapi_table
*t
;
867 GET_DISPATCH(dpy
, t
);
870 (t
->GetSelectedEventSGIX
)(dpy
, drawable
, mask
);
875 /*** GLX_SGI_cushion ***/
878 glXCushionSGI(Display
*dpy
, Window win
, float cushion
)
880 struct _glxapi_table
*t
;
881 GET_DISPATCH(dpy
, t
);
884 (t
->CushionSGI
)(dpy
, win
, cushion
);
889 /*** GLX_SGIX_video_resize ***/
892 glXBindChannelToWindowSGIX(Display
*dpy
, int screen
, int channel
, Window window
)
894 struct _glxapi_table
*t
;
895 GET_DISPATCH(dpy
, t
);
898 return (t
->BindChannelToWindowSGIX
)(dpy
, screen
, channel
, window
);
902 glXChannelRectSGIX(Display
*dpy
, int screen
, int channel
, int x
, int y
, int w
, int h
)
904 struct _glxapi_table
*t
;
905 GET_DISPATCH(dpy
, t
);
908 return (t
->ChannelRectSGIX
)(dpy
, screen
, channel
, x
, y
, w
, h
);
912 glXQueryChannelRectSGIX(Display
*dpy
, int screen
, int channel
, int *x
, int *y
, int *w
, int *h
)
914 struct _glxapi_table
*t
;
915 GET_DISPATCH(dpy
, t
);
918 return (t
->QueryChannelRectSGIX
)(dpy
, screen
, channel
, x
, y
, w
, h
);
922 glXQueryChannelDeltasSGIX(Display
*dpy
, int screen
, int channel
, int *dx
, int *dy
, int *dw
, int *dh
)
924 struct _glxapi_table
*t
;
925 GET_DISPATCH(dpy
, t
);
928 return (t
->QueryChannelDeltasSGIX
)(dpy
, screen
, channel
, dx
, dy
, dw
, dh
);
932 glXChannelRectSyncSGIX(Display
*dpy
, int screen
, int channel
, GLenum synctype
)
934 struct _glxapi_table
*t
;
935 GET_DISPATCH(dpy
, t
);
938 return (t
->ChannelRectSyncSGIX
)(dpy
, screen
, channel
, synctype
);
943 #if defined(_DM_BUFFER_H_)
946 glXAssociateDMPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuffer
, DMparams
*params
, DMbuffer dmbuffer
)
948 struct _glxapi_table
*t
;
949 GET_DISPATCH(dpy
, t
);
952 return (t
->AssociateDMPbufferSGIX
)(dpy
, pbuffer
, params
, dmbuffer
);
958 /*** GLX_SGIX_swap_group ***/
961 glXJoinSwapGroupSGIX(Display
*dpy
, GLXDrawable drawable
, GLXDrawable member
)
963 struct _glxapi_table
*t
;
964 GET_DISPATCH(dpy
, t
);
967 (*t
->JoinSwapGroupSGIX
)(dpy
, drawable
, member
);
971 /*** GLX_SGIX_swap_barrier ***/
974 glXBindSwapBarrierSGIX(Display
*dpy
, GLXDrawable drawable
, int barrier
)
976 struct _glxapi_table
*t
;
977 GET_DISPATCH(dpy
, t
);
980 (*t
->BindSwapBarrierSGIX
)(dpy
, drawable
, barrier
);
984 glXQueryMaxSwapBarriersSGIX(Display
*dpy
, int screen
, int *max
)
986 struct _glxapi_table
*t
;
987 GET_DISPATCH(dpy
, t
);
990 return (*t
->QueryMaxSwapBarriersSGIX
)(dpy
, screen
, max
);
995 /*** GLX_SUN_get_transparent_index ***/
998 glXGetTransparentIndexSUN(Display
*dpy
, Window overlay
, Window underlay
, long *pTransparent
)
1000 struct _glxapi_table
*t
;
1001 GET_DISPATCH(dpy
, t
);
1004 return (*t
->GetTransparentIndexSUN
)(dpy
, overlay
, underlay
, pTransparent
);
1009 /*** GLX_MESA_copy_sub_buffer ***/
1012 glXCopySubBufferMESA(Display
*dpy
, GLXDrawable drawable
, int x
, int y
, int width
, int height
)
1014 struct _glxapi_table
*t
;
1015 GET_DISPATCH(dpy
, t
);
1018 (t
->CopySubBufferMESA
)(dpy
, drawable
, x
, y
, width
, height
);
1023 /*** GLX_MESA_release_buffers ***/
1026 glXReleaseBuffersMESA(Display
*dpy
, Window w
)
1028 struct _glxapi_table
*t
;
1029 GET_DISPATCH(dpy
, t
);
1032 return (t
->ReleaseBuffersMESA
)(dpy
, w
);
1037 /*** GLX_MESA_pixmap_colormap ***/
1040 glXCreateGLXPixmapMESA(Display
*dpy
, XVisualInfo
*visinfo
, Pixmap pixmap
, Colormap cmap
)
1042 struct _glxapi_table
*t
;
1043 GET_DISPATCH(dpy
, t
);
1046 return (t
->CreateGLXPixmapMESA
)(dpy
, visinfo
, pixmap
, cmap
);
1051 /*** GLX_MESA_set_3dfx_mode ***/
1054 glXSet3DfxModeMESA(int mode
)
1056 struct _glxapi_table
*t
;
1057 Display
*dpy
= glXGetCurrentDisplay();
1058 GET_DISPATCH(dpy
, t
);
1061 return (t
->Set3DfxModeMESA
)(mode
);
1066 /*** GLX_NV_vertex_array_range ***/
1069 glXAllocateMemoryNV( GLsizei size
,
1070 GLfloat readFrequency
,
1071 GLfloat writeFrequency
,
1074 struct _glxapi_table
*t
;
1075 Display
*dpy
= glXGetCurrentDisplay();
1076 GET_DISPATCH(dpy
, t
);
1079 return (t
->AllocateMemoryNV
)(size
, readFrequency
, writeFrequency
, priority
);
1084 glXFreeMemoryNV( GLvoid
*pointer
)
1086 struct _glxapi_table
*t
;
1087 Display
*dpy
= glXGetCurrentDisplay();
1088 GET_DISPATCH(dpy
, t
);
1091 (t
->FreeMemoryNV
)(pointer
);
1097 /*** GLX_MESA_agp_offset */
1100 glXGetAGPOffsetMESA( const GLvoid
*pointer
)
1102 struct _glxapi_table
*t
;
1103 Display
*dpy
= glXGetCurrentDisplay();
1104 GET_DISPATCH(dpy
, t
);
1107 return (t
->GetAGPOffsetMESA
)(pointer
);
1111 /*** GLX_MESA_allocate_memory */
1114 glXAllocateMemoryMESA(Display
*dpy
, int scrn
, size_t size
,
1115 float readfreq
, float writefreq
, float priority
)
1122 glXFreeMemoryMESA(Display
*dpy
, int scrn
, void *pointer
)
1129 glXGetMemoryOffsetMESA(Display
*dpy
, int scrn
, const void *pointer
)
1137 /**********************************************************************/
1138 /* GLX API management functions */
1139 /**********************************************************************/
1143 _glxapi_get_version(void)
1150 * Return array of extension strings.
1153 _glxapi_get_extensions(void)
1155 static const char *extensions
[] = {
1156 #ifdef GLX_EXT_import_context
1157 "GLX_EXT_import_context",
1159 #ifdef GLX_SGI_video_sync
1160 "GLX_SGI_video_sync",
1162 #ifdef GLX_MESA_copy_sub_buffer
1163 "GLX_MESA_copy_sub_buffer",
1165 #ifdef GLX_MESA_release_buffers
1166 "GLX_MESA_release_buffers",
1168 #ifdef GLX_MESA_pixmap_colormap
1169 "GLX_MESA_pixmap_colormap",
1171 #ifdef GLX_MESA_set_3dfx_mode
1172 "GLX_MESA_set_3dfx_mode",
1174 #ifdef GLX_SGIX_fbconfig
1175 "GLX_SGIX_fbconfig",
1177 #ifdef GLX_SGIX_pbuffer
1187 * Return size of the GLX dispatch table, in entries, not bytes.
1190 _glxapi_get_dispatch_table_size(void)
1192 return sizeof(struct _glxapi_table
) / sizeof(void *);
1197 generic_no_op_func(void)
1204 * Initialize all functions in given dispatch table to be no-ops
1207 _glxapi_set_no_op_table(struct _glxapi_table
*t
)
1209 typedef int (*nop_func
)(void);
1210 nop_func
*dispatch
= (nop_func
*) t
;
1211 GLuint n
= _glxapi_get_dispatch_table_size();
1213 for (i
= 0; i
< n
; i
++) {
1214 dispatch
[i
] = generic_no_op_func
;
1219 struct name_address_pair
{
1221 __GLXextFuncPtr Address
;
1224 static struct name_address_pair GLX_functions
[] = {
1225 /*** GLX_VERSION_1_0 ***/
1226 { "glXChooseVisual", (__GLXextFuncPtr
) glXChooseVisual
},
1227 { "glXCopyContext", (__GLXextFuncPtr
) glXCopyContext
},
1228 { "glXCreateContext", (__GLXextFuncPtr
) glXCreateContext
},
1229 { "glXCreateGLXPixmap", (__GLXextFuncPtr
) glXCreateGLXPixmap
},
1230 { "glXDestroyContext", (__GLXextFuncPtr
) glXDestroyContext
},
1231 { "glXDestroyGLXPixmap", (__GLXextFuncPtr
) glXDestroyGLXPixmap
},
1232 { "glXGetConfig", (__GLXextFuncPtr
) glXGetConfig
},
1233 { "glXGetCurrentContext", (__GLXextFuncPtr
) glXGetCurrentContext
},
1234 { "glXGetCurrentDrawable", (__GLXextFuncPtr
) glXGetCurrentDrawable
},
1235 { "glXIsDirect", (__GLXextFuncPtr
) glXIsDirect
},
1236 { "glXMakeCurrent", (__GLXextFuncPtr
) glXMakeCurrent
},
1237 { "glXQueryExtension", (__GLXextFuncPtr
) glXQueryExtension
},
1238 { "glXQueryVersion", (__GLXextFuncPtr
) glXQueryVersion
},
1239 { "glXSwapBuffers", (__GLXextFuncPtr
) glXSwapBuffers
},
1240 { "glXUseXFont", (__GLXextFuncPtr
) glXUseXFont
},
1241 { "glXWaitGL", (__GLXextFuncPtr
) glXWaitGL
},
1242 { "glXWaitX", (__GLXextFuncPtr
) glXWaitX
},
1244 /*** GLX_VERSION_1_1 ***/
1245 { "glXGetClientString", (__GLXextFuncPtr
) glXGetClientString
},
1246 { "glXQueryExtensionsString", (__GLXextFuncPtr
) glXQueryExtensionsString
},
1247 { "glXQueryServerString", (__GLXextFuncPtr
) glXQueryServerString
},
1249 /*** GLX_VERSION_1_2 ***/
1250 { "glXGetCurrentDisplay", (__GLXextFuncPtr
) glXGetCurrentDisplay
},
1252 /*** GLX_VERSION_1_3 ***/
1253 { "glXChooseFBConfig", (__GLXextFuncPtr
) glXChooseFBConfig
},
1254 { "glXCreateNewContext", (__GLXextFuncPtr
) glXCreateNewContext
},
1255 { "glXCreatePbuffer", (__GLXextFuncPtr
) glXCreatePbuffer
},
1256 { "glXCreatePixmap", (__GLXextFuncPtr
) glXCreatePixmap
},
1257 { "glXCreateWindow", (__GLXextFuncPtr
) glXCreateWindow
},
1258 { "glXDestroyPbuffer", (__GLXextFuncPtr
) glXDestroyPbuffer
},
1259 { "glXDestroyPixmap", (__GLXextFuncPtr
) glXDestroyPixmap
},
1260 { "glXDestroyWindow", (__GLXextFuncPtr
) glXDestroyWindow
},
1261 { "glXGetCurrentReadDrawable", (__GLXextFuncPtr
) glXGetCurrentReadDrawable
},
1262 { "glXGetFBConfigAttrib", (__GLXextFuncPtr
) glXGetFBConfigAttrib
},
1263 { "glXGetFBConfigs", (__GLXextFuncPtr
) glXGetFBConfigs
},
1264 { "glXGetSelectedEvent", (__GLXextFuncPtr
) glXGetSelectedEvent
},
1265 { "glXGetVisualFromFBConfig", (__GLXextFuncPtr
) glXGetVisualFromFBConfig
},
1266 { "glXMakeContextCurrent", (__GLXextFuncPtr
) glXMakeContextCurrent
},
1267 { "glXQueryContext", (__GLXextFuncPtr
) glXQueryContext
},
1268 { "glXQueryDrawable", (__GLXextFuncPtr
) glXQueryDrawable
},
1269 { "glXSelectEvent", (__GLXextFuncPtr
) glXSelectEvent
},
1271 /*** GLX_VERSION_1_4 ***/
1272 { "glXGetProcAddress", (__GLXextFuncPtr
) glXGetProcAddress
},
1274 /*** GLX_SGI_swap_control ***/
1275 { "glXSwapIntervalSGI", (__GLXextFuncPtr
) glXSwapIntervalSGI
},
1277 /*** GLX_SGI_video_sync ***/
1278 { "glXGetVideoSyncSGI", (__GLXextFuncPtr
) glXGetVideoSyncSGI
},
1279 { "glXWaitVideoSyncSGI", (__GLXextFuncPtr
) glXWaitVideoSyncSGI
},
1281 /*** GLX_SGI_make_current_read ***/
1282 { "glXMakeCurrentReadSGI", (__GLXextFuncPtr
) glXMakeCurrentReadSGI
},
1283 { "glXGetCurrentReadDrawableSGI", (__GLXextFuncPtr
) glXGetCurrentReadDrawableSGI
},
1285 /*** GLX_SGIX_video_source ***/
1287 { "glXCreateGLXVideoSourceSGIX", (__GLXextFuncPtr
) glXCreateGLXVideoSourceSGIX
},
1288 { "glXDestroyGLXVideoSourceSGIX", (__GLXextFuncPtr
) glXDestroyGLXVideoSourceSGIX
},
1291 /*** GLX_EXT_import_context ***/
1292 { "glXFreeContextEXT", (__GLXextFuncPtr
) glXFreeContextEXT
},
1293 { "glXGetContextIDEXT", (__GLXextFuncPtr
) glXGetContextIDEXT
},
1294 { "glXGetCurrentDisplayEXT", (__GLXextFuncPtr
) glXGetCurrentDisplayEXT
},
1295 { "glXImportContextEXT", (__GLXextFuncPtr
) glXImportContextEXT
},
1296 { "glXQueryContextInfoEXT", (__GLXextFuncPtr
) glXQueryContextInfoEXT
},
1298 /*** GLX_SGIX_fbconfig ***/
1299 { "glXGetFBConfigAttribSGIX", (__GLXextFuncPtr
) glXGetFBConfigAttribSGIX
},
1300 { "glXChooseFBConfigSGIX", (__GLXextFuncPtr
) glXChooseFBConfigSGIX
},
1301 { "glXCreateGLXPixmapWithConfigSGIX", (__GLXextFuncPtr
) glXCreateGLXPixmapWithConfigSGIX
},
1302 { "glXCreateContextWithConfigSGIX", (__GLXextFuncPtr
) glXCreateContextWithConfigSGIX
},
1303 { "glXGetVisualFromFBConfigSGIX", (__GLXextFuncPtr
) glXGetVisualFromFBConfigSGIX
},
1304 { "glXGetFBConfigFromVisualSGIX", (__GLXextFuncPtr
) glXGetFBConfigFromVisualSGIX
},
1306 /*** GLX_SGIX_pbuffer ***/
1307 { "glXCreateGLXPbufferSGIX", (__GLXextFuncPtr
) glXCreateGLXPbufferSGIX
},
1308 { "glXDestroyGLXPbufferSGIX", (__GLXextFuncPtr
) glXDestroyGLXPbufferSGIX
},
1309 { "glXQueryGLXPbufferSGIX", (__GLXextFuncPtr
) glXQueryGLXPbufferSGIX
},
1310 { "glXSelectEventSGIX", (__GLXextFuncPtr
) glXSelectEventSGIX
},
1311 { "glXGetSelectedEventSGIX", (__GLXextFuncPtr
) glXGetSelectedEventSGIX
},
1313 /*** GLX_SGI_cushion ***/
1314 { "glXCushionSGI", (__GLXextFuncPtr
) glXCushionSGI
},
1316 /*** GLX_SGIX_video_resize ***/
1317 { "glXBindChannelToWindowSGIX", (__GLXextFuncPtr
) glXBindChannelToWindowSGIX
},
1318 { "glXChannelRectSGIX", (__GLXextFuncPtr
) glXChannelRectSGIX
},
1319 { "glXQueryChannelRectSGIX", (__GLXextFuncPtr
) glXQueryChannelRectSGIX
},
1320 { "glXQueryChannelDeltasSGIX", (__GLXextFuncPtr
) glXQueryChannelDeltasSGIX
},
1321 { "glXChannelRectSyncSGIX", (__GLXextFuncPtr
) glXChannelRectSyncSGIX
},
1323 /*** GLX_SGIX_dmbuffer **/
1324 #if defined(_DM_BUFFER_H_)
1325 { "glXAssociateDMPbufferSGIX", (__GLXextFuncPtr
) glXAssociateDMPbufferSGIX
},
1328 /*** GLX_SGIX_swap_group ***/
1329 { "glXJoinSwapGroupSGIX", (__GLXextFuncPtr
) glXJoinSwapGroupSGIX
},
1331 /*** GLX_SGIX_swap_barrier ***/
1332 { "glXBindSwapBarrierSGIX", (__GLXextFuncPtr
) glXBindSwapBarrierSGIX
},
1333 { "glXQueryMaxSwapBarriersSGIX", (__GLXextFuncPtr
) glXQueryMaxSwapBarriersSGIX
},
1335 /*** GLX_SUN_get_transparent_index ***/
1336 { "glXGetTransparentIndexSUN", (__GLXextFuncPtr
) glXGetTransparentIndexSUN
},
1338 /*** GLX_MESA_copy_sub_buffer ***/
1339 { "glXCopySubBufferMESA", (__GLXextFuncPtr
) glXCopySubBufferMESA
},
1341 /*** GLX_MESA_pixmap_colormap ***/
1342 { "glXCreateGLXPixmapMESA", (__GLXextFuncPtr
) glXCreateGLXPixmapMESA
},
1344 /*** GLX_MESA_release_buffers ***/
1345 { "glXReleaseBuffersMESA", (__GLXextFuncPtr
) glXReleaseBuffersMESA
},
1347 /*** GLX_MESA_set_3dfx_mode ***/
1348 { "glXSet3DfxModeMESA", (__GLXextFuncPtr
) glXSet3DfxModeMESA
},
1350 /*** GLX_ARB_get_proc_address ***/
1351 { "glXGetProcAddressARB", (__GLXextFuncPtr
) glXGetProcAddressARB
},
1353 /*** GLX_NV_vertex_array_range ***/
1354 { "glXAllocateMemoryNV", (__GLXextFuncPtr
) glXAllocateMemoryNV
},
1355 { "glXFreeMemoryNV", (__GLXextFuncPtr
) glXFreeMemoryNV
},
1357 /*** GLX_MESA_agp_offset ***/
1358 { "glXGetAGPOffsetMESA", (__GLXextFuncPtr
) glXGetAGPOffsetMESA
},
1360 /*** GLX_MESA_allocate_memory ***/
1361 { "glXAllocateMemoryMESA", (__GLXextFuncPtr
) glXAllocateMemoryMESA
},
1362 { "glXFreeMemoryMESA", (__GLXextFuncPtr
) glXFreeMemoryMESA
},
1363 { "glXGetMemoryOffsetMESA", (__GLXextFuncPtr
) glXGetMemoryOffsetMESA
},
1365 { NULL
, NULL
} /* end of list */
1371 * Return address of named glX function, or NULL if not found.
1374 _glxapi_get_proc_address(const char *funcName
)
1377 for (i
= 0; GLX_functions
[i
].Name
; i
++) {
1378 if (strcmp(GLX_functions
[i
].Name
, funcName
) == 0)
1379 return GLX_functions
[i
].Address
;
1387 * This function does not get dispatched through the dispatch table
1388 * since it's really a "meta" function.
1391 glXGetProcAddressARB(const GLubyte
*procName
)
1395 f
= _glxapi_get_proc_address((const char *) procName
);
1400 f
= (__GLXextFuncPtr
) _glapi_get_proc_address((const char *) procName
);
1406 void (*glXGetProcAddress(const GLubyte
*procName
))()
1408 return glXGetProcAddressARB(procName
);