2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2007 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.
37 #include "main/glheader.h"
38 #include "glapi/glapi.h"
41 #include "pipe/p_thread.h"
44 struct display_dispatch
{
46 struct _glxapi_table
*Table
;
47 struct display_dispatch
*Next
;
50 static struct display_dispatch
*DispatchList
= NULL
;
53 /* Display -> Dispatch caching */
54 static Display
*prevDisplay
= NULL
;
55 static struct _glxapi_table
*prevTable
= NULL
;
58 static struct _glxapi_table
*
59 get_dispatch(Display
*dpy
)
64 /* search list of display/dispatch pairs for this display */
66 const struct display_dispatch
*d
= DispatchList
;
71 return d
->Table
; /* done! */
77 /* A new display, determine if we should use real GLX
78 * or Mesa's pseudo-GLX.
81 struct _glxapi_table
*t
= _mesa_GetGLXDispatchTable();
84 struct display_dispatch
*d
;
85 d
= (struct display_dispatch
*) malloc(sizeof(struct display_dispatch
));
89 /* insert at head of list */
90 d
->Next
= DispatchList
;
100 /* If we get here that means we can't use real GLX on this display
101 * and the Mesa pseudo-GLX software renderer wasn't compiled in.
102 * Or, we ran out of memory!
108 /* Don't use the GET_DISPATCH defined in glthread.h */
111 #define GET_DISPATCH(DPY, TABLE) \
112 if (DPY == prevDisplay) { \
119 TABLE = get_dispatch(DPY); \
126 * GLX API current context.
132 SetCurrentContext(GLXContext c
)
134 pipe_tsd_set(&ContextTSD
, c
);
139 * GLX API entrypoints
142 /*** GLX_VERSION_1_0 ***/
145 glXChooseVisual(Display
*dpy
, int screen
, int *list
)
147 struct _glxapi_table
*t
;
148 GET_DISPATCH(dpy
, t
);
151 return (t
->ChooseVisual
)(dpy
, screen
, list
);
156 glXCopyContext(Display
*dpy
, GLXContext src
, GLXContext dst
, unsigned long mask
)
158 struct _glxapi_table
*t
;
159 GET_DISPATCH(dpy
, t
);
162 (t
->CopyContext
)(dpy
, src
, dst
, mask
);
167 glXCreateContext(Display
*dpy
, XVisualInfo
*visinfo
, GLXContext shareList
, Bool direct
)
169 struct _glxapi_table
*t
;
170 GET_DISPATCH(dpy
, t
);
173 return (t
->CreateContext
)(dpy
, visinfo
, shareList
, direct
);
178 glXCreateGLXPixmap(Display
*dpy
, XVisualInfo
*visinfo
, Pixmap pixmap
)
180 struct _glxapi_table
*t
;
181 GET_DISPATCH(dpy
, t
);
184 return (t
->CreateGLXPixmap
)(dpy
, visinfo
, pixmap
);
189 glXDestroyContext(Display
*dpy
, GLXContext ctx
)
191 struct _glxapi_table
*t
;
192 GET_DISPATCH(dpy
, t
);
195 if (glXGetCurrentContext() == ctx
)
196 SetCurrentContext(NULL
);
197 (t
->DestroyContext
)(dpy
, ctx
);
202 glXDestroyGLXPixmap(Display
*dpy
, GLXPixmap pixmap
)
204 struct _glxapi_table
*t
;
205 GET_DISPATCH(dpy
, t
);
208 (t
->DestroyGLXPixmap
)(dpy
, pixmap
);
213 glXGetConfig(Display
*dpy
, XVisualInfo
*visinfo
, int attrib
, int *value
)
215 struct _glxapi_table
*t
;
216 GET_DISPATCH(dpy
, t
);
218 return GLX_NO_EXTENSION
;
219 return (t
->GetConfig
)(dpy
, visinfo
, attrib
, value
);
224 glXGetCurrentContext(void)
226 return (GLXContext
) pipe_tsd_get(&ContextTSD
);
231 glXGetCurrentDrawable(void)
233 __GLXcontext
*gc
= (__GLXcontext
*) glXGetCurrentContext();
234 return gc
? gc
->currentDrawable
: 0;
239 glXIsDirect(Display
*dpy
, GLXContext ctx
)
241 struct _glxapi_table
*t
;
242 GET_DISPATCH(dpy
, t
);
245 return (t
->IsDirect
)(dpy
, ctx
);
250 glXMakeCurrent(Display
*dpy
, GLXDrawable drawable
, GLXContext ctx
)
253 struct _glxapi_table
*t
;
254 GET_DISPATCH(dpy
, t
);
258 b
= (*t
->MakeCurrent
)(dpy
, drawable
, ctx
);
260 SetCurrentContext(ctx
);
267 glXQueryExtension(Display
*dpy
, int *errorb
, int *event
)
269 struct _glxapi_table
*t
;
270 GET_DISPATCH(dpy
, t
);
273 return (t
->QueryExtension
)(dpy
, errorb
, event
);
278 glXQueryVersion(Display
*dpy
, int *maj
, int *min
)
280 struct _glxapi_table
*t
;
281 GET_DISPATCH(dpy
, t
);
284 return (t
->QueryVersion
)(dpy
, maj
, min
);
289 glXSwapBuffers(Display
*dpy
, GLXDrawable drawable
)
291 struct _glxapi_table
*t
;
292 GET_DISPATCH(dpy
, t
);
295 (t
->SwapBuffers
)(dpy
, drawable
);
300 glXUseXFont(Font font
, int first
, int count
, int listBase
)
302 struct _glxapi_table
*t
;
303 Display
*dpy
= glXGetCurrentDisplay();
304 GET_DISPATCH(dpy
, t
);
307 (t
->UseXFont
)(font
, first
, count
, listBase
);
314 struct _glxapi_table
*t
;
315 Display
*dpy
= glXGetCurrentDisplay();
316 GET_DISPATCH(dpy
, t
);
326 struct _glxapi_table
*t
;
327 Display
*dpy
= glXGetCurrentDisplay();
328 GET_DISPATCH(dpy
, t
);
336 /*** GLX_VERSION_1_1 ***/
339 glXGetClientString(Display
*dpy
, int name
)
341 struct _glxapi_table
*t
;
342 GET_DISPATCH(dpy
, t
);
345 return (t
->GetClientString
)(dpy
, name
);
350 glXQueryExtensionsString(Display
*dpy
, int screen
)
352 struct _glxapi_table
*t
;
353 GET_DISPATCH(dpy
, t
);
356 return (t
->QueryExtensionsString
)(dpy
, screen
);
361 glXQueryServerString(Display
*dpy
, int screen
, int name
)
363 struct _glxapi_table
*t
;
364 GET_DISPATCH(dpy
, t
);
367 return (t
->QueryServerString
)(dpy
, screen
, name
);
371 /*** GLX_VERSION_1_2 ***/
374 glXGetCurrentDisplay(void)
376 /* Same code as in libGL's glxext.c */
377 __GLXcontext
*gc
= (__GLXcontext
*) glXGetCurrentContext();
378 if (NULL
== gc
) return NULL
;
379 return gc
->currentDpy
;
384 /*** GLX_VERSION_1_3 ***/
387 glXChooseFBConfig(Display
*dpy
, int screen
, const int *attribList
, int *nitems
)
389 struct _glxapi_table
*t
;
390 GET_DISPATCH(dpy
, t
);
393 return (t
->ChooseFBConfig
)(dpy
, screen
, attribList
, nitems
);
398 glXCreateNewContext(Display
*dpy
, GLXFBConfig config
, int renderType
, GLXContext shareList
, Bool direct
)
400 struct _glxapi_table
*t
;
401 GET_DISPATCH(dpy
, t
);
404 return (t
->CreateNewContext
)(dpy
, config
, renderType
, shareList
, direct
);
409 glXCreatePbuffer(Display
*dpy
, GLXFBConfig config
, const int *attribList
)
411 struct _glxapi_table
*t
;
412 GET_DISPATCH(dpy
, t
);
415 return (t
->CreatePbuffer
)(dpy
, config
, attribList
);
420 glXCreatePixmap(Display
*dpy
, GLXFBConfig config
, Pixmap pixmap
, const int *attribList
)
422 struct _glxapi_table
*t
;
423 GET_DISPATCH(dpy
, t
);
426 return (t
->CreatePixmap
)(dpy
, config
, pixmap
, attribList
);
431 glXCreateWindow(Display
*dpy
, GLXFBConfig config
, Window win
, const int *attribList
)
433 struct _glxapi_table
*t
;
434 GET_DISPATCH(dpy
, t
);
437 return (t
->CreateWindow
)(dpy
, config
, win
, attribList
);
442 glXDestroyPbuffer(Display
*dpy
, GLXPbuffer pbuf
)
444 struct _glxapi_table
*t
;
445 GET_DISPATCH(dpy
, t
);
448 (t
->DestroyPbuffer
)(dpy
, pbuf
);
453 glXDestroyPixmap(Display
*dpy
, GLXPixmap pixmap
)
455 struct _glxapi_table
*t
;
456 GET_DISPATCH(dpy
, t
);
459 (t
->DestroyPixmap
)(dpy
, pixmap
);
464 glXDestroyWindow(Display
*dpy
, GLXWindow window
)
466 struct _glxapi_table
*t
;
467 GET_DISPATCH(dpy
, t
);
470 (t
->DestroyWindow
)(dpy
, window
);
475 glXGetCurrentReadDrawable(void)
477 __GLXcontext
*gc
= (__GLXcontext
*) glXGetCurrentContext();
478 return gc
? gc
->currentReadable
: 0;
483 glXGetFBConfigAttrib(Display
*dpy
, GLXFBConfig config
, int attribute
, int *value
)
485 struct _glxapi_table
*t
;
486 GET_DISPATCH(dpy
, t
);
488 return GLX_NO_EXTENSION
;
489 return (t
->GetFBConfigAttrib
)(dpy
, config
, attribute
, value
);
494 glXGetFBConfigs(Display
*dpy
, int screen
, int *nelements
)
496 struct _glxapi_table
*t
;
497 GET_DISPATCH(dpy
, t
);
500 return (t
->GetFBConfigs
)(dpy
, screen
, nelements
);
504 glXGetSelectedEvent(Display
*dpy
, GLXDrawable drawable
, unsigned long *mask
)
506 struct _glxapi_table
*t
;
507 GET_DISPATCH(dpy
, t
);
510 (t
->GetSelectedEvent
)(dpy
, drawable
, mask
);
515 glXGetVisualFromFBConfig(Display
*dpy
, GLXFBConfig config
)
517 struct _glxapi_table
*t
;
518 GET_DISPATCH(dpy
, t
);
521 return (t
->GetVisualFromFBConfig
)(dpy
, config
);
526 glXMakeContextCurrent(Display
*dpy
, GLXDrawable draw
, GLXDrawable read
, GLXContext ctx
)
529 struct _glxapi_table
*t
;
530 GET_DISPATCH(dpy
, t
);
533 b
= (t
->MakeContextCurrent
)(dpy
, draw
, read
, ctx
);
535 SetCurrentContext(ctx
);
542 glXQueryContext(Display
*dpy
, GLXContext ctx
, int attribute
, int *value
)
544 struct _glxapi_table
*t
;
545 GET_DISPATCH(dpy
, t
);
548 return 0; /* XXX correct? */
549 return (t
->QueryContext
)(dpy
, ctx
, attribute
, value
);
554 glXQueryDrawable(Display
*dpy
, GLXDrawable draw
, int attribute
, unsigned int *value
)
556 struct _glxapi_table
*t
;
557 GET_DISPATCH(dpy
, t
);
560 (t
->QueryDrawable
)(dpy
, draw
, attribute
, value
);
565 glXSelectEvent(Display
*dpy
, GLXDrawable drawable
, unsigned long mask
)
567 struct _glxapi_table
*t
;
568 GET_DISPATCH(dpy
, t
);
571 (t
->SelectEvent
)(dpy
, drawable
, mask
);
576 /*** GLX_SGI_swap_control ***/
579 glXSwapIntervalSGI(int interval
)
581 struct _glxapi_table
*t
;
582 Display
*dpy
= glXGetCurrentDisplay();
583 GET_DISPATCH(dpy
, t
);
586 return (t
->SwapIntervalSGI
)(interval
);
591 /*** GLX_SGI_video_sync ***/
594 glXGetVideoSyncSGI(unsigned int *count
)
596 struct _glxapi_table
*t
;
597 Display
*dpy
= glXGetCurrentDisplay();
598 GET_DISPATCH(dpy
, t
);
599 if (!t
|| !glXGetCurrentContext())
600 return GLX_BAD_CONTEXT
;
601 return (t
->GetVideoSyncSGI
)(count
);
605 glXWaitVideoSyncSGI(int divisor
, int remainder
, unsigned int *count
)
607 struct _glxapi_table
*t
;
608 Display
*dpy
= glXGetCurrentDisplay();
609 GET_DISPATCH(dpy
, t
);
610 if (!t
|| !glXGetCurrentContext())
611 return GLX_BAD_CONTEXT
;
612 return (t
->WaitVideoSyncSGI
)(divisor
, remainder
, count
);
617 /*** GLX_SGI_make_current_read ***/
620 glXMakeCurrentReadSGI(Display
*dpy
, GLXDrawable draw
, GLXDrawable read
, GLXContext ctx
)
622 struct _glxapi_table
*t
;
623 GET_DISPATCH(dpy
, t
);
626 return (t
->MakeCurrentReadSGI
)(dpy
, draw
, read
, ctx
);
630 glXGetCurrentReadDrawableSGI(void)
632 return glXGetCurrentReadDrawable();
638 GLXVideoSourceSGIX PUBLIC
639 glXCreateGLXVideoSourceSGIX(Display
*dpy
, int screen
, VLServer server
, VLPath path
, int nodeClass
, VLNode drainNode
)
641 struct _glxapi_table
*t
;
642 GET_DISPATCH(dpy
, t
);
645 return (t
->CreateGLXVideoSourceSGIX
)(dpy
, screen
, server
, path
, nodeClass
, drainNode
);
649 glXDestroyGLXVideoSourceSGIX(Display
*dpy
, GLXVideoSourceSGIX src
)
651 struct _glxapi_table
*t
;
652 GET_DISPATCH(dpy
, t
);
655 return (t
->DestroyGLXVideoSourceSGIX
)(dpy
, src
);
661 /*** GLX_EXT_import_context ***/
664 glXFreeContextEXT(Display
*dpy
, GLXContext context
)
666 struct _glxapi_table
*t
;
667 GET_DISPATCH(dpy
, t
);
670 (t
->FreeContextEXT
)(dpy
, context
);
674 glXGetContextIDEXT(const GLXContext context
)
676 return ((__GLXcontext
*) context
)->xid
;
680 glXGetCurrentDisplayEXT(void)
682 return glXGetCurrentDisplay();
686 glXImportContextEXT(Display
*dpy
, GLXContextID contextID
)
688 struct _glxapi_table
*t
;
689 GET_DISPATCH(dpy
, t
);
692 return (t
->ImportContextEXT
)(dpy
, contextID
);
696 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 ***/
710 glXGetFBConfigAttribSGIX(Display
*dpy
, GLXFBConfigSGIX config
, int attribute
, int *value
)
712 struct _glxapi_table
*t
;
713 GET_DISPATCH(dpy
, t
);
716 return (t
->GetFBConfigAttribSGIX
)(dpy
, config
, attribute
, value
);
719 GLXFBConfigSGIX PUBLIC
*
720 glXChooseFBConfigSGIX(Display
*dpy
, int screen
, int *attrib_list
, int *nelements
)
722 struct _glxapi_table
*t
;
723 GET_DISPATCH(dpy
, t
);
726 return (t
->ChooseFBConfigSGIX
)(dpy
, screen
, attrib_list
, nelements
);
730 glXCreateGLXPixmapWithConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
, Pixmap pixmap
)
732 struct _glxapi_table
*t
;
733 GET_DISPATCH(dpy
, t
);
736 return (t
->CreateGLXPixmapWithConfigSGIX
)(dpy
, config
, pixmap
);
740 glXCreateContextWithConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
, int render_type
, GLXContext share_list
, Bool direct
)
742 struct _glxapi_table
*t
;
743 GET_DISPATCH(dpy
, t
);
746 return (t
->CreateContextWithConfigSGIX
)(dpy
, config
, render_type
, share_list
, direct
);
750 glXGetVisualFromFBConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
)
752 struct _glxapi_table
*t
;
753 GET_DISPATCH(dpy
, t
);
756 return (t
->GetVisualFromFBConfigSGIX
)(dpy
, config
);
759 GLXFBConfigSGIX PUBLIC
760 glXGetFBConfigFromVisualSGIX(Display
*dpy
, XVisualInfo
*vis
)
762 struct _glxapi_table
*t
;
763 GET_DISPATCH(dpy
, t
);
766 return (t
->GetFBConfigFromVisualSGIX
)(dpy
, vis
);
771 /*** GLX_SGIX_pbuffer ***/
773 GLXPbufferSGIX PUBLIC
774 glXCreateGLXPbufferSGIX(Display
*dpy
, GLXFBConfigSGIX config
, unsigned int width
, unsigned int height
, int *attrib_list
)
776 struct _glxapi_table
*t
;
777 GET_DISPATCH(dpy
, t
);
780 return (t
->CreateGLXPbufferSGIX
)(dpy
, config
, width
, height
, attrib_list
);
784 glXDestroyGLXPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuf
)
786 struct _glxapi_table
*t
;
787 GET_DISPATCH(dpy
, t
);
790 (t
->DestroyGLXPbufferSGIX
)(dpy
, pbuf
);
794 glXQueryGLXPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuf
, int attribute
, unsigned int *value
)
796 struct _glxapi_table
*t
;
797 GET_DISPATCH(dpy
, t
);
800 return (t
->QueryGLXPbufferSGIX
)(dpy
, pbuf
, attribute
, value
);
804 glXSelectEventSGIX(Display
*dpy
, GLXDrawable drawable
, unsigned long mask
)
806 struct _glxapi_table
*t
;
807 GET_DISPATCH(dpy
, t
);
810 (t
->SelectEventSGIX
)(dpy
, drawable
, mask
);
814 glXGetSelectedEventSGIX(Display
*dpy
, GLXDrawable drawable
, unsigned long *mask
)
816 struct _glxapi_table
*t
;
817 GET_DISPATCH(dpy
, t
);
820 (t
->GetSelectedEventSGIX
)(dpy
, drawable
, mask
);
825 /*** GLX_SGI_cushion ***/
828 glXCushionSGI(Display
*dpy
, Window win
, float cushion
)
830 struct _glxapi_table
*t
;
831 GET_DISPATCH(dpy
, t
);
834 (t
->CushionSGI
)(dpy
, win
, cushion
);
839 /*** GLX_SGIX_video_resize ***/
842 glXBindChannelToWindowSGIX(Display
*dpy
, int screen
, int channel
, Window window
)
844 struct _glxapi_table
*t
;
845 GET_DISPATCH(dpy
, t
);
848 return (t
->BindChannelToWindowSGIX
)(dpy
, screen
, channel
, window
);
852 glXChannelRectSGIX(Display
*dpy
, int screen
, int channel
, int x
, int y
, int w
, int h
)
854 struct _glxapi_table
*t
;
855 GET_DISPATCH(dpy
, t
);
858 return (t
->ChannelRectSGIX
)(dpy
, screen
, channel
, x
, y
, w
, h
);
862 glXQueryChannelRectSGIX(Display
*dpy
, int screen
, int channel
, int *x
, int *y
, int *w
, int *h
)
864 struct _glxapi_table
*t
;
865 GET_DISPATCH(dpy
, t
);
868 return (t
->QueryChannelRectSGIX
)(dpy
, screen
, channel
, x
, y
, w
, h
);
872 glXQueryChannelDeltasSGIX(Display
*dpy
, int screen
, int channel
, int *dx
, int *dy
, int *dw
, int *dh
)
874 struct _glxapi_table
*t
;
875 GET_DISPATCH(dpy
, t
);
878 return (t
->QueryChannelDeltasSGIX
)(dpy
, screen
, channel
, dx
, dy
, dw
, dh
);
882 glXChannelRectSyncSGIX(Display
*dpy
, int screen
, int channel
, GLenum synctype
)
884 struct _glxapi_table
*t
;
885 GET_DISPATCH(dpy
, t
);
888 return (t
->ChannelRectSyncSGIX
)(dpy
, screen
, channel
, synctype
);
893 #if defined(_DM_BUFFER_H_)
896 glXAssociateDMPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuffer
, DMparams
*params
, DMbuffer dmbuffer
)
898 struct _glxapi_table
*t
;
899 GET_DISPATCH(dpy
, t
);
902 return (t
->AssociateDMPbufferSGIX
)(dpy
, pbuffer
, params
, dmbuffer
);
908 /*** GLX_SGIX_swap_group ***/
911 glXJoinSwapGroupSGIX(Display
*dpy
, GLXDrawable drawable
, GLXDrawable member
)
913 struct _glxapi_table
*t
;
914 GET_DISPATCH(dpy
, t
);
917 (*t
->JoinSwapGroupSGIX
)(dpy
, drawable
, member
);
921 /*** GLX_SGIX_swap_barrier ***/
924 glXBindSwapBarrierSGIX(Display
*dpy
, GLXDrawable drawable
, int barrier
)
926 struct _glxapi_table
*t
;
927 GET_DISPATCH(dpy
, t
);
930 (*t
->BindSwapBarrierSGIX
)(dpy
, drawable
, barrier
);
934 glXQueryMaxSwapBarriersSGIX(Display
*dpy
, int screen
, int *max
)
936 struct _glxapi_table
*t
;
937 GET_DISPATCH(dpy
, t
);
940 return (*t
->QueryMaxSwapBarriersSGIX
)(dpy
, screen
, max
);
945 /*** GLX_SUN_get_transparent_index ***/
948 glXGetTransparentIndexSUN(Display
*dpy
, Window overlay
, Window underlay
, long *pTransparent
)
950 struct _glxapi_table
*t
;
951 GET_DISPATCH(dpy
, t
);
954 return (*t
->GetTransparentIndexSUN
)(dpy
, overlay
, underlay
, pTransparent
);
959 /*** GLX_MESA_copy_sub_buffer ***/
962 glXCopySubBufferMESA(Display
*dpy
, GLXDrawable drawable
, int x
, int y
, int width
, int height
)
964 struct _glxapi_table
*t
;
965 GET_DISPATCH(dpy
, t
);
968 (t
->CopySubBufferMESA
)(dpy
, drawable
, x
, y
, width
, height
);
973 /*** GLX_MESA_release_buffers ***/
976 glXReleaseBuffersMESA(Display
*dpy
, Window w
)
978 struct _glxapi_table
*t
;
979 GET_DISPATCH(dpy
, t
);
982 return (t
->ReleaseBuffersMESA
)(dpy
, w
);
987 /*** GLX_MESA_pixmap_colormap ***/
990 glXCreateGLXPixmapMESA(Display
*dpy
, XVisualInfo
*visinfo
, Pixmap pixmap
, Colormap cmap
)
992 struct _glxapi_table
*t
;
993 GET_DISPATCH(dpy
, t
);
996 return (t
->CreateGLXPixmapMESA
)(dpy
, visinfo
, pixmap
, cmap
);
999 /*** GLX_EXT_texture_from_pixmap */
1002 glXBindTexImageEXT(Display
*dpy
, GLXDrawable drawable
, int buffer
,
1003 const int *attrib_list
)
1005 struct _glxapi_table
*t
;
1006 GET_DISPATCH(dpy
, t
);
1008 t
->BindTexImageEXT(dpy
, drawable
, buffer
, attrib_list
);
1012 glXReleaseTexImageEXT(Display
*dpy
, GLXDrawable drawable
, int buffer
)
1014 struct _glxapi_table
*t
;
1015 GET_DISPATCH(dpy
, t
);
1017 t
->ReleaseTexImageEXT(dpy
, drawable
, buffer
);
1021 /**********************************************************************/
1022 /* GLX API management functions */
1023 /**********************************************************************/
1027 _glxapi_get_version(void)
1035 * Return size of the GLX dispatch table, in entries, not bytes.
1038 _glxapi_get_dispatch_table_size(void)
1040 return sizeof(struct _glxapi_table
) / sizeof(void *);
1045 generic_no_op_func(void)
1052 * Initialize all functions in given dispatch table to be no-ops
1055 _glxapi_set_no_op_table(struct _glxapi_table
*t
)
1057 typedef int (*nop_func
)(void);
1058 nop_func
*dispatch
= (nop_func
*) t
;
1059 GLuint n
= _glxapi_get_dispatch_table_size();
1061 for (i
= 0; i
< n
; i
++) {
1062 dispatch
[i
] = generic_no_op_func
;
1067 struct name_address_pair
{
1069 __GLXextFuncPtr Address
;
1072 static struct name_address_pair GLX_functions
[] = {
1073 /*** GLX_VERSION_1_0 ***/
1074 { "glXChooseVisual", (__GLXextFuncPtr
) glXChooseVisual
},
1075 { "glXCopyContext", (__GLXextFuncPtr
) glXCopyContext
},
1076 { "glXCreateContext", (__GLXextFuncPtr
) glXCreateContext
},
1077 { "glXCreateGLXPixmap", (__GLXextFuncPtr
) glXCreateGLXPixmap
},
1078 { "glXDestroyContext", (__GLXextFuncPtr
) glXDestroyContext
},
1079 { "glXDestroyGLXPixmap", (__GLXextFuncPtr
) glXDestroyGLXPixmap
},
1080 { "glXGetConfig", (__GLXextFuncPtr
) glXGetConfig
},
1081 { "glXGetCurrentContext", (__GLXextFuncPtr
) glXGetCurrentContext
},
1082 { "glXGetCurrentDrawable", (__GLXextFuncPtr
) glXGetCurrentDrawable
},
1083 { "glXIsDirect", (__GLXextFuncPtr
) glXIsDirect
},
1084 { "glXMakeCurrent", (__GLXextFuncPtr
) glXMakeCurrent
},
1085 { "glXQueryExtension", (__GLXextFuncPtr
) glXQueryExtension
},
1086 { "glXQueryVersion", (__GLXextFuncPtr
) glXQueryVersion
},
1087 { "glXSwapBuffers", (__GLXextFuncPtr
) glXSwapBuffers
},
1088 { "glXUseXFont", (__GLXextFuncPtr
) glXUseXFont
},
1089 { "glXWaitGL", (__GLXextFuncPtr
) glXWaitGL
},
1090 { "glXWaitX", (__GLXextFuncPtr
) glXWaitX
},
1092 /*** GLX_VERSION_1_1 ***/
1093 { "glXGetClientString", (__GLXextFuncPtr
) glXGetClientString
},
1094 { "glXQueryExtensionsString", (__GLXextFuncPtr
) glXQueryExtensionsString
},
1095 { "glXQueryServerString", (__GLXextFuncPtr
) glXQueryServerString
},
1097 /*** GLX_VERSION_1_2 ***/
1098 { "glXGetCurrentDisplay", (__GLXextFuncPtr
) glXGetCurrentDisplay
},
1100 /*** GLX_VERSION_1_3 ***/
1101 { "glXChooseFBConfig", (__GLXextFuncPtr
) glXChooseFBConfig
},
1102 { "glXCreateNewContext", (__GLXextFuncPtr
) glXCreateNewContext
},
1103 { "glXCreatePbuffer", (__GLXextFuncPtr
) glXCreatePbuffer
},
1104 { "glXCreatePixmap", (__GLXextFuncPtr
) glXCreatePixmap
},
1105 { "glXCreateWindow", (__GLXextFuncPtr
) glXCreateWindow
},
1106 { "glXDestroyPbuffer", (__GLXextFuncPtr
) glXDestroyPbuffer
},
1107 { "glXDestroyPixmap", (__GLXextFuncPtr
) glXDestroyPixmap
},
1108 { "glXDestroyWindow", (__GLXextFuncPtr
) glXDestroyWindow
},
1109 { "glXGetCurrentReadDrawable", (__GLXextFuncPtr
) glXGetCurrentReadDrawable
},
1110 { "glXGetFBConfigAttrib", (__GLXextFuncPtr
) glXGetFBConfigAttrib
},
1111 { "glXGetFBConfigs", (__GLXextFuncPtr
) glXGetFBConfigs
},
1112 { "glXGetSelectedEvent", (__GLXextFuncPtr
) glXGetSelectedEvent
},
1113 { "glXGetVisualFromFBConfig", (__GLXextFuncPtr
) glXGetVisualFromFBConfig
},
1114 { "glXMakeContextCurrent", (__GLXextFuncPtr
) glXMakeContextCurrent
},
1115 { "glXQueryContext", (__GLXextFuncPtr
) glXQueryContext
},
1116 { "glXQueryDrawable", (__GLXextFuncPtr
) glXQueryDrawable
},
1117 { "glXSelectEvent", (__GLXextFuncPtr
) glXSelectEvent
},
1119 /*** GLX_VERSION_1_4 ***/
1120 { "glXGetProcAddress", (__GLXextFuncPtr
) glXGetProcAddress
},
1122 /*** GLX_SGI_swap_control ***/
1123 { "glXSwapIntervalSGI", (__GLXextFuncPtr
) glXSwapIntervalSGI
},
1125 /*** GLX_SGI_video_sync ***/
1126 { "glXGetVideoSyncSGI", (__GLXextFuncPtr
) glXGetVideoSyncSGI
},
1127 { "glXWaitVideoSyncSGI", (__GLXextFuncPtr
) glXWaitVideoSyncSGI
},
1129 /*** GLX_SGI_make_current_read ***/
1130 { "glXMakeCurrentReadSGI", (__GLXextFuncPtr
) glXMakeCurrentReadSGI
},
1131 { "glXGetCurrentReadDrawableSGI", (__GLXextFuncPtr
) glXGetCurrentReadDrawableSGI
},
1133 /*** GLX_SGIX_video_source ***/
1135 { "glXCreateGLXVideoSourceSGIX", (__GLXextFuncPtr
) glXCreateGLXVideoSourceSGIX
},
1136 { "glXDestroyGLXVideoSourceSGIX", (__GLXextFuncPtr
) glXDestroyGLXVideoSourceSGIX
},
1139 /*** GLX_EXT_import_context ***/
1140 { "glXFreeContextEXT", (__GLXextFuncPtr
) glXFreeContextEXT
},
1141 { "glXGetContextIDEXT", (__GLXextFuncPtr
) glXGetContextIDEXT
},
1142 { "glXGetCurrentDisplayEXT", (__GLXextFuncPtr
) glXGetCurrentDisplayEXT
},
1143 { "glXImportContextEXT", (__GLXextFuncPtr
) glXImportContextEXT
},
1144 { "glXQueryContextInfoEXT", (__GLXextFuncPtr
) glXQueryContextInfoEXT
},
1146 /*** GLX_SGIX_fbconfig ***/
1147 { "glXGetFBConfigAttribSGIX", (__GLXextFuncPtr
) glXGetFBConfigAttribSGIX
},
1148 { "glXChooseFBConfigSGIX", (__GLXextFuncPtr
) glXChooseFBConfigSGIX
},
1149 { "glXCreateGLXPixmapWithConfigSGIX", (__GLXextFuncPtr
) glXCreateGLXPixmapWithConfigSGIX
},
1150 { "glXCreateContextWithConfigSGIX", (__GLXextFuncPtr
) glXCreateContextWithConfigSGIX
},
1151 { "glXGetVisualFromFBConfigSGIX", (__GLXextFuncPtr
) glXGetVisualFromFBConfigSGIX
},
1152 { "glXGetFBConfigFromVisualSGIX", (__GLXextFuncPtr
) glXGetFBConfigFromVisualSGIX
},
1154 /*** GLX_SGIX_pbuffer ***/
1155 { "glXCreateGLXPbufferSGIX", (__GLXextFuncPtr
) glXCreateGLXPbufferSGIX
},
1156 { "glXDestroyGLXPbufferSGIX", (__GLXextFuncPtr
) glXDestroyGLXPbufferSGIX
},
1157 { "glXQueryGLXPbufferSGIX", (__GLXextFuncPtr
) glXQueryGLXPbufferSGIX
},
1158 { "glXSelectEventSGIX", (__GLXextFuncPtr
) glXSelectEventSGIX
},
1159 { "glXGetSelectedEventSGIX", (__GLXextFuncPtr
) glXGetSelectedEventSGIX
},
1161 /*** GLX_SGI_cushion ***/
1162 { "glXCushionSGI", (__GLXextFuncPtr
) glXCushionSGI
},
1164 /*** GLX_SGIX_video_resize ***/
1165 { "glXBindChannelToWindowSGIX", (__GLXextFuncPtr
) glXBindChannelToWindowSGIX
},
1166 { "glXChannelRectSGIX", (__GLXextFuncPtr
) glXChannelRectSGIX
},
1167 { "glXQueryChannelRectSGIX", (__GLXextFuncPtr
) glXQueryChannelRectSGIX
},
1168 { "glXQueryChannelDeltasSGIX", (__GLXextFuncPtr
) glXQueryChannelDeltasSGIX
},
1169 { "glXChannelRectSyncSGIX", (__GLXextFuncPtr
) glXChannelRectSyncSGIX
},
1171 /*** GLX_SGIX_dmbuffer **/
1172 #if defined(_DM_BUFFER_H_)
1173 { "glXAssociateDMPbufferSGIX", (__GLXextFuncPtr
) glXAssociateDMPbufferSGIX
},
1176 /*** GLX_SGIX_swap_group ***/
1177 { "glXJoinSwapGroupSGIX", (__GLXextFuncPtr
) glXJoinSwapGroupSGIX
},
1179 /*** GLX_SGIX_swap_barrier ***/
1180 { "glXBindSwapBarrierSGIX", (__GLXextFuncPtr
) glXBindSwapBarrierSGIX
},
1181 { "glXQueryMaxSwapBarriersSGIX", (__GLXextFuncPtr
) glXQueryMaxSwapBarriersSGIX
},
1183 /*** GLX_SUN_get_transparent_index ***/
1184 { "glXGetTransparentIndexSUN", (__GLXextFuncPtr
) glXGetTransparentIndexSUN
},
1186 /*** GLX_MESA_copy_sub_buffer ***/
1187 { "glXCopySubBufferMESA", (__GLXextFuncPtr
) glXCopySubBufferMESA
},
1189 /*** GLX_MESA_pixmap_colormap ***/
1190 { "glXCreateGLXPixmapMESA", (__GLXextFuncPtr
) glXCreateGLXPixmapMESA
},
1192 /*** GLX_MESA_release_buffers ***/
1193 { "glXReleaseBuffersMESA", (__GLXextFuncPtr
) glXReleaseBuffersMESA
},
1195 /*** GLX_ARB_get_proc_address ***/
1196 { "glXGetProcAddressARB", (__GLXextFuncPtr
) glXGetProcAddressARB
},
1198 /*** GLX_EXT_texture_from_pixmap ***/
1199 { "glXBindTexImageEXT", (__GLXextFuncPtr
) glXBindTexImageEXT
},
1200 { "glXReleaseTexImageEXT", (__GLXextFuncPtr
) glXReleaseTexImageEXT
},
1202 { NULL
, NULL
} /* end of list */
1208 * Return address of named glX function, or NULL if not found.
1211 _glxapi_get_proc_address(const char *funcName
)
1214 for (i
= 0; GLX_functions
[i
].Name
; i
++) {
1215 if (strcmp(GLX_functions
[i
].Name
, funcName
) == 0)
1216 return GLX_functions
[i
].Address
;
1224 * This function does not get dispatched through the dispatch table
1225 * since it's really a "meta" function.
1228 glXGetProcAddressARB(const GLubyte
*procName
)
1232 f
= _glxapi_get_proc_address((const char *) procName
);
1237 f
= (__GLXextFuncPtr
) _glapi_get_proc_address((const char *) procName
);
1243 void (*glXGetProcAddress(const GLubyte
*procName
))()
1245 return glXGetProcAddressARB(procName
);