2 * Mesa 3-D graphics library
4 * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 * OTHER DEALINGS IN THE SOFTWARE.
27 * This is the GLX API dispatcher. It uses a dispatch table but that's
28 * not really needed anymore since the table always points to the "fake"
37 #include "main/glheader.h"
38 #include "main/compiler.h"
39 #include "glapi/glapi.h"
43 extern struct _glxapi_table
*_mesa_GetGLXDispatchTable(void);
46 struct display_dispatch
{
48 struct _glxapi_table
*Table
;
49 struct display_dispatch
*Next
;
54 * When GLX_INDIRECT_RENDERING is defined, some symbols are missing in
55 * libglapi.a. We need to define them here.
57 #ifdef GLX_INDIRECT_RENDERING
59 #include "glapi/glapitable.h"
61 #define KEYWORD1 PUBLIC
63 #if defined(USE_MGL_NAMESPACE)
64 #define NAME(func) mgl##func
66 #define NAME(func) gl##func
69 #define DISPATCH(FUNC, ARGS, MESSAGE) \
70 GET_DISPATCH()->FUNC ARGS
72 #define RETURN_DISPATCH(FUNC, ARGS, MESSAGE) \
73 return GET_DISPATCH()->FUNC ARGS
75 /* skip normal ones */
76 #define _GLAPI_SKIP_NORMAL_ENTRY_POINTS
77 #include "glapi/glapitemp.h"
79 #endif /* GLX_INDIRECT_RENDERING */
82 static struct display_dispatch
*DispatchList
= NULL
;
85 /* Display -> Dispatch caching */
86 static Display
*prevDisplay
= NULL
;
87 static struct _glxapi_table
*prevTable
= NULL
;
90 static struct _glxapi_table
*
91 get_dispatch(Display
*dpy
)
96 /* search list of display/dispatch pairs for this display */
98 const struct display_dispatch
*d
= DispatchList
;
102 prevTable
= d
->Table
;
103 return d
->Table
; /* done! */
109 /* Setup the dispatch table */
111 struct _glxapi_table
*t
= _mesa_GetGLXDispatchTable();
114 struct display_dispatch
*d
;
115 d
= malloc(sizeof(struct display_dispatch
));
119 /* insert at head of list */
120 d
->Next
= DispatchList
;
134 /* Don't use the GET_DISPATCH macro */
137 #define GET_DISPATCH(DPY, TABLE) \
138 if (DPY == prevDisplay) { \
145 TABLE = get_dispatch(DPY); \
150 * GLX API entrypoints
153 /*** GLX_VERSION_1_0 ***/
156 glXChooseVisual(Display
*dpy
, int screen
, int *list
)
158 struct _glxapi_table
*t
;
159 GET_DISPATCH(dpy
, t
);
162 return (t
->ChooseVisual
)(dpy
, screen
, list
);
167 glXCopyContext(Display
*dpy
, GLXContext src
, GLXContext dst
, unsigned long mask
)
169 struct _glxapi_table
*t
;
170 GET_DISPATCH(dpy
, t
);
173 (t
->CopyContext
)(dpy
, src
, dst
, mask
);
178 glXCreateContext(Display
*dpy
, XVisualInfo
*visinfo
, GLXContext shareList
, Bool direct
)
180 struct _glxapi_table
*t
;
181 GET_DISPATCH(dpy
, t
);
184 return (t
->CreateContext
)(dpy
, visinfo
, shareList
, direct
);
189 glXCreateGLXPixmap(Display
*dpy
, XVisualInfo
*visinfo
, Pixmap pixmap
)
191 struct _glxapi_table
*t
;
192 GET_DISPATCH(dpy
, t
);
195 return (t
->CreateGLXPixmap
)(dpy
, visinfo
, pixmap
);
200 glXDestroyContext(Display
*dpy
, GLXContext ctx
)
202 struct _glxapi_table
*t
;
203 GET_DISPATCH(dpy
, t
);
206 (t
->DestroyContext
)(dpy
, ctx
);
211 glXDestroyGLXPixmap(Display
*dpy
, GLXPixmap pixmap
)
213 struct _glxapi_table
*t
;
214 GET_DISPATCH(dpy
, t
);
217 (t
->DestroyGLXPixmap
)(dpy
, pixmap
);
222 glXGetConfig(Display
*dpy
, XVisualInfo
*visinfo
, int attrib
, int *value
)
224 struct _glxapi_table
*t
;
225 GET_DISPATCH(dpy
, t
);
227 return GLX_NO_EXTENSION
;
228 return (t
->GetConfig
)(dpy
, visinfo
, attrib
, value
);
232 /* declare here to avoid including xmesa.h */
233 extern void *XMesaGetCurrentContext(void);
236 glXGetCurrentContext(void)
238 return (GLXContext
) XMesaGetCurrentContext();
243 glXGetCurrentDrawable(void)
245 __GLXcontext
*gc
= (__GLXcontext
*) glXGetCurrentContext();
246 return gc
? gc
->currentDrawable
: 0;
251 glXIsDirect(Display
*dpy
, GLXContext ctx
)
253 struct _glxapi_table
*t
;
254 GET_DISPATCH(dpy
, t
);
257 return (t
->IsDirect
)(dpy
, ctx
);
262 glXMakeCurrent(Display
*dpy
, GLXDrawable drawable
, GLXContext ctx
)
265 struct _glxapi_table
*t
;
266 GET_DISPATCH(dpy
, t
);
270 b
= (*t
->MakeCurrent
)(dpy
, drawable
, ctx
);
276 glXQueryExtension(Display
*dpy
, int *errorb
, int *event
)
278 struct _glxapi_table
*t
;
279 GET_DISPATCH(dpy
, t
);
282 return (t
->QueryExtension
)(dpy
, errorb
, event
);
287 glXQueryVersion(Display
*dpy
, int *maj
, int *min
)
289 struct _glxapi_table
*t
;
290 GET_DISPATCH(dpy
, t
);
293 return (t
->QueryVersion
)(dpy
, maj
, min
);
298 glXSwapBuffers(Display
*dpy
, GLXDrawable drawable
)
300 struct _glxapi_table
*t
;
301 GET_DISPATCH(dpy
, t
);
304 (t
->SwapBuffers
)(dpy
, drawable
);
309 glXUseXFont(Font font
, int first
, int count
, int listBase
)
311 struct _glxapi_table
*t
;
312 Display
*dpy
= glXGetCurrentDisplay();
313 GET_DISPATCH(dpy
, t
);
316 (t
->UseXFont
)(font
, first
, count
, listBase
);
323 struct _glxapi_table
*t
;
324 Display
*dpy
= glXGetCurrentDisplay();
325 GET_DISPATCH(dpy
, t
);
335 struct _glxapi_table
*t
;
336 Display
*dpy
= glXGetCurrentDisplay();
337 GET_DISPATCH(dpy
, t
);
345 /*** GLX_VERSION_1_1 ***/
348 glXGetClientString(Display
*dpy
, int name
)
350 struct _glxapi_table
*t
;
351 GET_DISPATCH(dpy
, t
);
354 return (t
->GetClientString
)(dpy
, name
);
359 glXQueryExtensionsString(Display
*dpy
, int screen
)
361 struct _glxapi_table
*t
;
362 GET_DISPATCH(dpy
, t
);
365 return (t
->QueryExtensionsString
)(dpy
, screen
);
370 glXQueryServerString(Display
*dpy
, int screen
, int name
)
372 struct _glxapi_table
*t
;
373 GET_DISPATCH(dpy
, t
);
376 return (t
->QueryServerString
)(dpy
, screen
, name
);
380 /*** GLX_VERSION_1_2 ***/
383 glXGetCurrentDisplay(void)
385 /* Same code as in libGL's glxext.c */
386 __GLXcontext
*gc
= (__GLXcontext
*) glXGetCurrentContext();
387 if (NULL
== gc
) return NULL
;
388 return gc
->currentDpy
;
393 /*** GLX_VERSION_1_3 ***/
396 glXChooseFBConfig(Display
*dpy
, int screen
, const int *attribList
, int *nitems
)
398 struct _glxapi_table
*t
;
399 GET_DISPATCH(dpy
, t
);
402 return (t
->ChooseFBConfig
)(dpy
, screen
, attribList
, nitems
);
407 glXCreateNewContext(Display
*dpy
, GLXFBConfig config
, int renderType
, GLXContext shareList
, Bool direct
)
409 struct _glxapi_table
*t
;
410 GET_DISPATCH(dpy
, t
);
413 return (t
->CreateNewContext
)(dpy
, config
, renderType
, shareList
, direct
);
418 glXCreatePbuffer(Display
*dpy
, GLXFBConfig config
, const int *attribList
)
420 struct _glxapi_table
*t
;
421 GET_DISPATCH(dpy
, t
);
424 return (t
->CreatePbuffer
)(dpy
, config
, attribList
);
429 glXCreatePixmap(Display
*dpy
, GLXFBConfig config
, Pixmap pixmap
, const int *attribList
)
431 struct _glxapi_table
*t
;
432 GET_DISPATCH(dpy
, t
);
435 return (t
->CreatePixmap
)(dpy
, config
, pixmap
, attribList
);
440 glXCreateWindow(Display
*dpy
, GLXFBConfig config
, Window win
, const int *attribList
)
442 struct _glxapi_table
*t
;
443 GET_DISPATCH(dpy
, t
);
446 return (t
->CreateWindow
)(dpy
, config
, win
, attribList
);
451 glXDestroyPbuffer(Display
*dpy
, GLXPbuffer pbuf
)
453 struct _glxapi_table
*t
;
454 GET_DISPATCH(dpy
, t
);
457 (t
->DestroyPbuffer
)(dpy
, pbuf
);
462 glXDestroyPixmap(Display
*dpy
, GLXPixmap pixmap
)
464 struct _glxapi_table
*t
;
465 GET_DISPATCH(dpy
, t
);
468 (t
->DestroyPixmap
)(dpy
, pixmap
);
473 glXDestroyWindow(Display
*dpy
, GLXWindow window
)
475 struct _glxapi_table
*t
;
476 GET_DISPATCH(dpy
, t
);
479 (t
->DestroyWindow
)(dpy
, window
);
484 glXGetCurrentReadDrawable(void)
486 __GLXcontext
*gc
= (__GLXcontext
*) glXGetCurrentContext();
487 return gc
? gc
->currentReadable
: 0;
492 glXGetFBConfigAttrib(Display
*dpy
, GLXFBConfig config
, int attribute
, int *value
)
494 struct _glxapi_table
*t
;
495 GET_DISPATCH(dpy
, t
);
497 return GLX_NO_EXTENSION
;
498 return (t
->GetFBConfigAttrib
)(dpy
, config
, attribute
, value
);
503 glXGetFBConfigs(Display
*dpy
, int screen
, int *nelements
)
505 struct _glxapi_table
*t
;
506 GET_DISPATCH(dpy
, t
);
509 return (t
->GetFBConfigs
)(dpy
, screen
, nelements
);
513 glXGetSelectedEvent(Display
*dpy
, GLXDrawable drawable
, unsigned long *mask
)
515 struct _glxapi_table
*t
;
516 GET_DISPATCH(dpy
, t
);
519 (t
->GetSelectedEvent
)(dpy
, drawable
, mask
);
524 glXGetVisualFromFBConfig(Display
*dpy
, GLXFBConfig config
)
526 struct _glxapi_table
*t
;
527 GET_DISPATCH(dpy
, t
);
530 return (t
->GetVisualFromFBConfig
)(dpy
, config
);
535 glXMakeContextCurrent(Display
*dpy
, GLXDrawable draw
, GLXDrawable read
, GLXContext ctx
)
538 struct _glxapi_table
*t
;
539 GET_DISPATCH(dpy
, t
);
542 b
= (t
->MakeContextCurrent
)(dpy
, draw
, read
, ctx
);
548 glXQueryContext(Display
*dpy
, GLXContext ctx
, int attribute
, int *value
)
550 struct _glxapi_table
*t
;
551 GET_DISPATCH(dpy
, t
);
554 return 0; /* XXX correct? */
555 return (t
->QueryContext
)(dpy
, ctx
, attribute
, value
);
560 glXQueryDrawable(Display
*dpy
, GLXDrawable draw
, int attribute
, unsigned int *value
)
562 struct _glxapi_table
*t
;
563 GET_DISPATCH(dpy
, t
);
566 (t
->QueryDrawable
)(dpy
, draw
, attribute
, value
);
571 glXSelectEvent(Display
*dpy
, GLXDrawable drawable
, unsigned long mask
)
573 struct _glxapi_table
*t
;
574 GET_DISPATCH(dpy
, t
);
577 (t
->SelectEvent
)(dpy
, drawable
, mask
);
582 /*** GLX_SGI_swap_control ***/
585 glXSwapIntervalSGI(int interval
)
587 struct _glxapi_table
*t
;
588 Display
*dpy
= glXGetCurrentDisplay();
589 GET_DISPATCH(dpy
, t
);
592 return (t
->SwapIntervalSGI
)(interval
);
597 /*** GLX_SGI_video_sync ***/
600 glXGetVideoSyncSGI(unsigned int *count
)
602 struct _glxapi_table
*t
;
603 Display
*dpy
= glXGetCurrentDisplay();
604 GET_DISPATCH(dpy
, t
);
605 if (!t
|| !glXGetCurrentContext())
606 return GLX_BAD_CONTEXT
;
607 return (t
->GetVideoSyncSGI
)(count
);
611 glXWaitVideoSyncSGI(int divisor
, int remainder
, unsigned int *count
)
613 struct _glxapi_table
*t
;
614 Display
*dpy
= glXGetCurrentDisplay();
615 GET_DISPATCH(dpy
, t
);
616 if (!t
|| !glXGetCurrentContext())
617 return GLX_BAD_CONTEXT
;
618 return (t
->WaitVideoSyncSGI
)(divisor
, remainder
, count
);
623 /*** GLX_SGI_make_current_read ***/
626 glXMakeCurrentReadSGI(Display
*dpy
, GLXDrawable draw
, GLXDrawable read
, GLXContext ctx
)
628 struct _glxapi_table
*t
;
629 GET_DISPATCH(dpy
, t
);
632 return (t
->MakeCurrentReadSGI
)(dpy
, draw
, read
, ctx
);
636 glXGetCurrentReadDrawableSGI(void)
638 return glXGetCurrentReadDrawable();
644 GLXVideoSourceSGIX PUBLIC
645 glXCreateGLXVideoSourceSGIX(Display
*dpy
, int screen
, VLServer server
, VLPath path
, int nodeClass
, VLNode drainNode
)
647 struct _glxapi_table
*t
;
648 GET_DISPATCH(dpy
, t
);
651 return (t
->CreateGLXVideoSourceSGIX
)(dpy
, screen
, server
, path
, nodeClass
, drainNode
);
655 glXDestroyGLXVideoSourceSGIX(Display
*dpy
, GLXVideoSourceSGIX src
)
657 struct _glxapi_table
*t
;
658 GET_DISPATCH(dpy
, t
);
661 return (t
->DestroyGLXVideoSourceSGIX
)(dpy
, src
);
667 /*** GLX_EXT_import_context ***/
670 glXFreeContextEXT(Display
*dpy
, GLXContext context
)
672 struct _glxapi_table
*t
;
673 GET_DISPATCH(dpy
, t
);
676 (t
->FreeContextEXT
)(dpy
, context
);
680 glXGetContextIDEXT(const GLXContext context
)
682 return ((__GLXcontext
*) context
)->xid
;
686 glXGetCurrentDisplayEXT(void)
688 return glXGetCurrentDisplay();
692 glXImportContextEXT(Display
*dpy
, GLXContextID contextID
)
694 struct _glxapi_table
*t
;
695 GET_DISPATCH(dpy
, t
);
698 return (t
->ImportContextEXT
)(dpy
, contextID
);
702 glXQueryContextInfoEXT(Display
*dpy
, GLXContext context
, int attribute
,int *value
)
704 struct _glxapi_table
*t
;
705 GET_DISPATCH(dpy
, t
);
707 return 0; /* XXX ok? */
708 return (t
->QueryContextInfoEXT
)(dpy
, context
, attribute
, value
);
713 /*** GLX_SGIX_fbconfig ***/
716 glXGetFBConfigAttribSGIX(Display
*dpy
, GLXFBConfigSGIX config
, int attribute
, int *value
)
718 struct _glxapi_table
*t
;
719 GET_DISPATCH(dpy
, t
);
722 return (t
->GetFBConfigAttribSGIX
)(dpy
, config
, attribute
, value
);
725 GLXFBConfigSGIX PUBLIC
*
726 glXChooseFBConfigSGIX(Display
*dpy
, int screen
, int *attrib_list
, int *nelements
)
728 struct _glxapi_table
*t
;
729 GET_DISPATCH(dpy
, t
);
732 return (t
->ChooseFBConfigSGIX
)(dpy
, screen
, attrib_list
, nelements
);
736 glXCreateGLXPixmapWithConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
, Pixmap pixmap
)
738 struct _glxapi_table
*t
;
739 GET_DISPATCH(dpy
, t
);
742 return (t
->CreateGLXPixmapWithConfigSGIX
)(dpy
, config
, pixmap
);
746 glXCreateContextWithConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
, int render_type
, GLXContext share_list
, Bool direct
)
748 struct _glxapi_table
*t
;
749 GET_DISPATCH(dpy
, t
);
752 return (t
->CreateContextWithConfigSGIX
)(dpy
, config
, render_type
, share_list
, direct
);
756 glXGetVisualFromFBConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
)
758 struct _glxapi_table
*t
;
759 GET_DISPATCH(dpy
, t
);
762 return (t
->GetVisualFromFBConfigSGIX
)(dpy
, config
);
765 GLXFBConfigSGIX PUBLIC
766 glXGetFBConfigFromVisualSGIX(Display
*dpy
, XVisualInfo
*vis
)
768 struct _glxapi_table
*t
;
769 GET_DISPATCH(dpy
, t
);
772 return (t
->GetFBConfigFromVisualSGIX
)(dpy
, vis
);
777 /*** GLX_SGIX_pbuffer ***/
779 GLXPbufferSGIX PUBLIC
780 glXCreateGLXPbufferSGIX(Display
*dpy
, GLXFBConfigSGIX config
, unsigned int width
, unsigned int height
, int *attrib_list
)
782 struct _glxapi_table
*t
;
783 GET_DISPATCH(dpy
, t
);
786 return (t
->CreateGLXPbufferSGIX
)(dpy
, config
, width
, height
, attrib_list
);
790 glXDestroyGLXPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuf
)
792 struct _glxapi_table
*t
;
793 GET_DISPATCH(dpy
, t
);
796 (t
->DestroyGLXPbufferSGIX
)(dpy
, pbuf
);
800 glXQueryGLXPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuf
, int attribute
, unsigned int *value
)
802 struct _glxapi_table
*t
;
803 GET_DISPATCH(dpy
, t
);
806 return (t
->QueryGLXPbufferSGIX
)(dpy
, pbuf
, attribute
, value
);
810 glXSelectEventSGIX(Display
*dpy
, GLXDrawable drawable
, unsigned long mask
)
812 struct _glxapi_table
*t
;
813 GET_DISPATCH(dpy
, t
);
816 (t
->SelectEventSGIX
)(dpy
, drawable
, mask
);
820 glXGetSelectedEventSGIX(Display
*dpy
, GLXDrawable drawable
, unsigned long *mask
)
822 struct _glxapi_table
*t
;
823 GET_DISPATCH(dpy
, t
);
826 (t
->GetSelectedEventSGIX
)(dpy
, drawable
, mask
);
831 /*** GLX_SGI_cushion ***/
834 glXCushionSGI(Display
*dpy
, Window win
, float cushion
)
836 struct _glxapi_table
*t
;
837 GET_DISPATCH(dpy
, t
);
840 (t
->CushionSGI
)(dpy
, win
, cushion
);
845 /*** GLX_SGIX_video_resize ***/
848 glXBindChannelToWindowSGIX(Display
*dpy
, int screen
, int channel
, Window window
)
850 struct _glxapi_table
*t
;
851 GET_DISPATCH(dpy
, t
);
854 return (t
->BindChannelToWindowSGIX
)(dpy
, screen
, channel
, window
);
858 glXChannelRectSGIX(Display
*dpy
, int screen
, int channel
, int x
, int y
, int w
, int h
)
860 struct _glxapi_table
*t
;
861 GET_DISPATCH(dpy
, t
);
864 return (t
->ChannelRectSGIX
)(dpy
, screen
, channel
, x
, y
, w
, h
);
868 glXQueryChannelRectSGIX(Display
*dpy
, int screen
, int channel
, int *x
, int *y
, int *w
, int *h
)
870 struct _glxapi_table
*t
;
871 GET_DISPATCH(dpy
, t
);
874 return (t
->QueryChannelRectSGIX
)(dpy
, screen
, channel
, x
, y
, w
, h
);
878 glXQueryChannelDeltasSGIX(Display
*dpy
, int screen
, int channel
, int *dx
, int *dy
, int *dw
, int *dh
)
880 struct _glxapi_table
*t
;
881 GET_DISPATCH(dpy
, t
);
884 return (t
->QueryChannelDeltasSGIX
)(dpy
, screen
, channel
, dx
, dy
, dw
, dh
);
888 glXChannelRectSyncSGIX(Display
*dpy
, int screen
, int channel
, GLenum synctype
)
890 struct _glxapi_table
*t
;
891 GET_DISPATCH(dpy
, t
);
894 return (t
->ChannelRectSyncSGIX
)(dpy
, screen
, channel
, synctype
);
899 #if defined(_DM_BUFFER_H_)
902 glXAssociateDMPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuffer
, DMparams
*params
, DMbuffer dmbuffer
)
904 struct _glxapi_table
*t
;
905 GET_DISPATCH(dpy
, t
);
908 return (t
->AssociateDMPbufferSGIX
)(dpy
, pbuffer
, params
, dmbuffer
);
914 /*** GLX_SGIX_swap_group ***/
917 glXJoinSwapGroupSGIX(Display
*dpy
, GLXDrawable drawable
, GLXDrawable member
)
919 struct _glxapi_table
*t
;
920 GET_DISPATCH(dpy
, t
);
923 (*t
->JoinSwapGroupSGIX
)(dpy
, drawable
, member
);
927 /*** GLX_SGIX_swap_barrier ***/
930 glXBindSwapBarrierSGIX(Display
*dpy
, GLXDrawable drawable
, int barrier
)
932 struct _glxapi_table
*t
;
933 GET_DISPATCH(dpy
, t
);
936 (*t
->BindSwapBarrierSGIX
)(dpy
, drawable
, barrier
);
940 glXQueryMaxSwapBarriersSGIX(Display
*dpy
, int screen
, int *max
)
942 struct _glxapi_table
*t
;
943 GET_DISPATCH(dpy
, t
);
946 return (*t
->QueryMaxSwapBarriersSGIX
)(dpy
, screen
, max
);
951 /*** GLX_SUN_get_transparent_index ***/
954 glXGetTransparentIndexSUN(Display
*dpy
, Window overlay
, Window underlay
, long *pTransparent
)
956 struct _glxapi_table
*t
;
957 GET_DISPATCH(dpy
, t
);
960 return (*t
->GetTransparentIndexSUN
)(dpy
, overlay
, underlay
, pTransparent
);
965 /*** GLX_MESA_copy_sub_buffer ***/
968 glXCopySubBufferMESA(Display
*dpy
, GLXDrawable drawable
, int x
, int y
, int width
, int height
)
970 struct _glxapi_table
*t
;
971 GET_DISPATCH(dpy
, t
);
974 (t
->CopySubBufferMESA
)(dpy
, drawable
, x
, y
, width
, height
);
979 /*** GLX_MESA_release_buffers ***/
982 glXReleaseBuffersMESA(Display
*dpy
, Window w
)
984 struct _glxapi_table
*t
;
985 GET_DISPATCH(dpy
, t
);
988 return (t
->ReleaseBuffersMESA
)(dpy
, w
);
993 /*** GLX_MESA_pixmap_colormap ***/
996 glXCreateGLXPixmapMESA(Display
*dpy
, XVisualInfo
*visinfo
, Pixmap pixmap
, Colormap cmap
)
998 struct _glxapi_table
*t
;
999 GET_DISPATCH(dpy
, t
);
1002 return (t
->CreateGLXPixmapMESA
)(dpy
, visinfo
, pixmap
, cmap
);
1007 /*** GLX_MESA_set_3dfx_mode ***/
1010 glXSet3DfxModeMESA(int mode
)
1012 struct _glxapi_table
*t
;
1013 Display
*dpy
= glXGetCurrentDisplay();
1014 GET_DISPATCH(dpy
, t
);
1017 return (t
->Set3DfxModeMESA
)(mode
);
1022 /*** GLX_NV_vertex_array_range ***/
1025 glXAllocateMemoryNV( GLsizei size
,
1026 GLfloat readFrequency
,
1027 GLfloat writeFrequency
,
1030 struct _glxapi_table
*t
;
1031 Display
*dpy
= glXGetCurrentDisplay();
1032 GET_DISPATCH(dpy
, t
);
1035 return (t
->AllocateMemoryNV
)(size
, readFrequency
, writeFrequency
, priority
);
1040 glXFreeMemoryNV( GLvoid
*pointer
)
1042 struct _glxapi_table
*t
;
1043 Display
*dpy
= glXGetCurrentDisplay();
1044 GET_DISPATCH(dpy
, t
);
1047 (t
->FreeMemoryNV
)(pointer
);
1053 /*** GLX_MESA_agp_offset */
1056 glXGetAGPOffsetMESA( const GLvoid
*pointer
)
1058 struct _glxapi_table
*t
;
1059 Display
*dpy
= glXGetCurrentDisplay();
1060 GET_DISPATCH(dpy
, t
);
1063 return (t
->GetAGPOffsetMESA
)(pointer
);
1067 /*** GLX_EXT_texture_from_pixmap */
1070 glXBindTexImageEXT(Display
*dpy
, GLXDrawable drawable
, int buffer
,
1071 const int *attrib_list
)
1073 struct _glxapi_table
*t
;
1074 GET_DISPATCH(dpy
, t
);
1076 t
->BindTexImageEXT(dpy
, drawable
, buffer
, attrib_list
);
1080 glXReleaseTexImageEXT(Display
*dpy
, GLXDrawable drawable
, int buffer
)
1082 struct _glxapi_table
*t
;
1083 GET_DISPATCH(dpy
, t
);
1085 t
->ReleaseTexImageEXT(dpy
, drawable
, buffer
);
1089 /**********************************************************************/
1090 /* GLX API management functions */
1091 /**********************************************************************/
1095 _glxapi_get_version(void)
1102 * Return array of extension strings.
1105 _glxapi_get_extensions(void)
1107 static const char *extensions
[] = {
1108 #ifdef GLX_EXT_import_context
1109 "GLX_EXT_import_context",
1111 #ifdef GLX_SGI_video_sync
1112 "GLX_SGI_video_sync",
1114 #ifdef GLX_MESA_copy_sub_buffer
1115 "GLX_MESA_copy_sub_buffer",
1117 #ifdef GLX_MESA_release_buffers
1118 "GLX_MESA_release_buffers",
1120 #ifdef GLX_MESA_pixmap_colormap
1121 "GLX_MESA_pixmap_colormap",
1123 #ifdef GLX_MESA_set_3dfx_mode
1124 "GLX_MESA_set_3dfx_mode",
1126 #ifdef GLX_SGIX_fbconfig
1127 "GLX_SGIX_fbconfig",
1129 #ifdef GLX_SGIX_pbuffer
1132 #ifdef GLX_EXT_texture_from_pixmap
1133 "GLX_EXT_texture_from_pixmap",
1135 #ifdef GLX_INTEL_swap_event
1136 "GLX_INTEL_swap_event",
1145 * Return size of the GLX dispatch table, in entries, not bytes.
1148 _glxapi_get_dispatch_table_size(void)
1150 return sizeof(struct _glxapi_table
) / sizeof(void *);
1155 generic_no_op_func(void)
1162 * Initialize all functions in given dispatch table to be no-ops
1165 _glxapi_set_no_op_table(struct _glxapi_table
*t
)
1167 typedef int (*nop_func
)(void);
1168 nop_func
*dispatch
= (nop_func
*) t
;
1169 GLuint n
= _glxapi_get_dispatch_table_size();
1171 for (i
= 0; i
< n
; i
++) {
1172 dispatch
[i
] = generic_no_op_func
;
1177 struct name_address_pair
{
1179 __GLXextFuncPtr Address
;
1182 static struct name_address_pair GLX_functions
[] = {
1183 /*** GLX_VERSION_1_0 ***/
1184 { "glXChooseVisual", (__GLXextFuncPtr
) glXChooseVisual
},
1185 { "glXCopyContext", (__GLXextFuncPtr
) glXCopyContext
},
1186 { "glXCreateContext", (__GLXextFuncPtr
) glXCreateContext
},
1187 { "glXCreateGLXPixmap", (__GLXextFuncPtr
) glXCreateGLXPixmap
},
1188 { "glXDestroyContext", (__GLXextFuncPtr
) glXDestroyContext
},
1189 { "glXDestroyGLXPixmap", (__GLXextFuncPtr
) glXDestroyGLXPixmap
},
1190 { "glXGetConfig", (__GLXextFuncPtr
) glXGetConfig
},
1191 { "glXGetCurrentContext", (__GLXextFuncPtr
) glXGetCurrentContext
},
1192 { "glXGetCurrentDrawable", (__GLXextFuncPtr
) glXGetCurrentDrawable
},
1193 { "glXIsDirect", (__GLXextFuncPtr
) glXIsDirect
},
1194 { "glXMakeCurrent", (__GLXextFuncPtr
) glXMakeCurrent
},
1195 { "glXQueryExtension", (__GLXextFuncPtr
) glXQueryExtension
},
1196 { "glXQueryVersion", (__GLXextFuncPtr
) glXQueryVersion
},
1197 { "glXSwapBuffers", (__GLXextFuncPtr
) glXSwapBuffers
},
1198 { "glXUseXFont", (__GLXextFuncPtr
) glXUseXFont
},
1199 { "glXWaitGL", (__GLXextFuncPtr
) glXWaitGL
},
1200 { "glXWaitX", (__GLXextFuncPtr
) glXWaitX
},
1202 /*** GLX_VERSION_1_1 ***/
1203 { "glXGetClientString", (__GLXextFuncPtr
) glXGetClientString
},
1204 { "glXQueryExtensionsString", (__GLXextFuncPtr
) glXQueryExtensionsString
},
1205 { "glXQueryServerString", (__GLXextFuncPtr
) glXQueryServerString
},
1207 /*** GLX_VERSION_1_2 ***/
1208 { "glXGetCurrentDisplay", (__GLXextFuncPtr
) glXGetCurrentDisplay
},
1210 /*** GLX_VERSION_1_3 ***/
1211 { "glXChooseFBConfig", (__GLXextFuncPtr
) glXChooseFBConfig
},
1212 { "glXCreateNewContext", (__GLXextFuncPtr
) glXCreateNewContext
},
1213 { "glXCreatePbuffer", (__GLXextFuncPtr
) glXCreatePbuffer
},
1214 { "glXCreatePixmap", (__GLXextFuncPtr
) glXCreatePixmap
},
1215 { "glXCreateWindow", (__GLXextFuncPtr
) glXCreateWindow
},
1216 { "glXDestroyPbuffer", (__GLXextFuncPtr
) glXDestroyPbuffer
},
1217 { "glXDestroyPixmap", (__GLXextFuncPtr
) glXDestroyPixmap
},
1218 { "glXDestroyWindow", (__GLXextFuncPtr
) glXDestroyWindow
},
1219 { "glXGetCurrentReadDrawable", (__GLXextFuncPtr
) glXGetCurrentReadDrawable
},
1220 { "glXGetFBConfigAttrib", (__GLXextFuncPtr
) glXGetFBConfigAttrib
},
1221 { "glXGetFBConfigs", (__GLXextFuncPtr
) glXGetFBConfigs
},
1222 { "glXGetSelectedEvent", (__GLXextFuncPtr
) glXGetSelectedEvent
},
1223 { "glXGetVisualFromFBConfig", (__GLXextFuncPtr
) glXGetVisualFromFBConfig
},
1224 { "glXMakeContextCurrent", (__GLXextFuncPtr
) glXMakeContextCurrent
},
1225 { "glXQueryContext", (__GLXextFuncPtr
) glXQueryContext
},
1226 { "glXQueryDrawable", (__GLXextFuncPtr
) glXQueryDrawable
},
1227 { "glXSelectEvent", (__GLXextFuncPtr
) glXSelectEvent
},
1229 /*** GLX_VERSION_1_4 ***/
1230 { "glXGetProcAddress", (__GLXextFuncPtr
) glXGetProcAddress
},
1232 /*** GLX_SGI_swap_control ***/
1233 { "glXSwapIntervalSGI", (__GLXextFuncPtr
) glXSwapIntervalSGI
},
1235 /*** GLX_SGI_video_sync ***/
1236 { "glXGetVideoSyncSGI", (__GLXextFuncPtr
) glXGetVideoSyncSGI
},
1237 { "glXWaitVideoSyncSGI", (__GLXextFuncPtr
) glXWaitVideoSyncSGI
},
1239 /*** GLX_SGI_make_current_read ***/
1240 { "glXMakeCurrentReadSGI", (__GLXextFuncPtr
) glXMakeCurrentReadSGI
},
1241 { "glXGetCurrentReadDrawableSGI", (__GLXextFuncPtr
) glXGetCurrentReadDrawableSGI
},
1243 /*** GLX_SGIX_video_source ***/
1245 { "glXCreateGLXVideoSourceSGIX", (__GLXextFuncPtr
) glXCreateGLXVideoSourceSGIX
},
1246 { "glXDestroyGLXVideoSourceSGIX", (__GLXextFuncPtr
) glXDestroyGLXVideoSourceSGIX
},
1249 /*** GLX_EXT_import_context ***/
1250 { "glXFreeContextEXT", (__GLXextFuncPtr
) glXFreeContextEXT
},
1251 { "glXGetContextIDEXT", (__GLXextFuncPtr
) glXGetContextIDEXT
},
1252 { "glXGetCurrentDisplayEXT", (__GLXextFuncPtr
) glXGetCurrentDisplayEXT
},
1253 { "glXImportContextEXT", (__GLXextFuncPtr
) glXImportContextEXT
},
1254 { "glXQueryContextInfoEXT", (__GLXextFuncPtr
) glXQueryContextInfoEXT
},
1256 /*** GLX_SGIX_fbconfig ***/
1257 { "glXGetFBConfigAttribSGIX", (__GLXextFuncPtr
) glXGetFBConfigAttribSGIX
},
1258 { "glXChooseFBConfigSGIX", (__GLXextFuncPtr
) glXChooseFBConfigSGIX
},
1259 { "glXCreateGLXPixmapWithConfigSGIX", (__GLXextFuncPtr
) glXCreateGLXPixmapWithConfigSGIX
},
1260 { "glXCreateContextWithConfigSGIX", (__GLXextFuncPtr
) glXCreateContextWithConfigSGIX
},
1261 { "glXGetVisualFromFBConfigSGIX", (__GLXextFuncPtr
) glXGetVisualFromFBConfigSGIX
},
1262 { "glXGetFBConfigFromVisualSGIX", (__GLXextFuncPtr
) glXGetFBConfigFromVisualSGIX
},
1264 /*** GLX_SGIX_pbuffer ***/
1265 { "glXCreateGLXPbufferSGIX", (__GLXextFuncPtr
) glXCreateGLXPbufferSGIX
},
1266 { "glXDestroyGLXPbufferSGIX", (__GLXextFuncPtr
) glXDestroyGLXPbufferSGIX
},
1267 { "glXQueryGLXPbufferSGIX", (__GLXextFuncPtr
) glXQueryGLXPbufferSGIX
},
1268 { "glXSelectEventSGIX", (__GLXextFuncPtr
) glXSelectEventSGIX
},
1269 { "glXGetSelectedEventSGIX", (__GLXextFuncPtr
) glXGetSelectedEventSGIX
},
1271 /*** GLX_SGI_cushion ***/
1272 { "glXCushionSGI", (__GLXextFuncPtr
) glXCushionSGI
},
1274 /*** GLX_SGIX_video_resize ***/
1275 { "glXBindChannelToWindowSGIX", (__GLXextFuncPtr
) glXBindChannelToWindowSGIX
},
1276 { "glXChannelRectSGIX", (__GLXextFuncPtr
) glXChannelRectSGIX
},
1277 { "glXQueryChannelRectSGIX", (__GLXextFuncPtr
) glXQueryChannelRectSGIX
},
1278 { "glXQueryChannelDeltasSGIX", (__GLXextFuncPtr
) glXQueryChannelDeltasSGIX
},
1279 { "glXChannelRectSyncSGIX", (__GLXextFuncPtr
) glXChannelRectSyncSGIX
},
1281 /*** GLX_SGIX_dmbuffer **/
1282 #if defined(_DM_BUFFER_H_)
1283 { "glXAssociateDMPbufferSGIX", (__GLXextFuncPtr
) glXAssociateDMPbufferSGIX
},
1286 /*** GLX_SGIX_swap_group ***/
1287 { "glXJoinSwapGroupSGIX", (__GLXextFuncPtr
) glXJoinSwapGroupSGIX
},
1289 /*** GLX_SGIX_swap_barrier ***/
1290 { "glXBindSwapBarrierSGIX", (__GLXextFuncPtr
) glXBindSwapBarrierSGIX
},
1291 { "glXQueryMaxSwapBarriersSGIX", (__GLXextFuncPtr
) glXQueryMaxSwapBarriersSGIX
},
1293 /*** GLX_SUN_get_transparent_index ***/
1294 { "glXGetTransparentIndexSUN", (__GLXextFuncPtr
) glXGetTransparentIndexSUN
},
1296 /*** GLX_MESA_copy_sub_buffer ***/
1297 { "glXCopySubBufferMESA", (__GLXextFuncPtr
) glXCopySubBufferMESA
},
1299 /*** GLX_MESA_pixmap_colormap ***/
1300 { "glXCreateGLXPixmapMESA", (__GLXextFuncPtr
) glXCreateGLXPixmapMESA
},
1302 /*** GLX_MESA_release_buffers ***/
1303 { "glXReleaseBuffersMESA", (__GLXextFuncPtr
) glXReleaseBuffersMESA
},
1305 /*** GLX_MESA_set_3dfx_mode ***/
1306 { "glXSet3DfxModeMESA", (__GLXextFuncPtr
) glXSet3DfxModeMESA
},
1308 /*** GLX_ARB_get_proc_address ***/
1309 { "glXGetProcAddressARB", (__GLXextFuncPtr
) glXGetProcAddressARB
},
1311 /*** GLX_NV_vertex_array_range ***/
1312 { "glXAllocateMemoryNV", (__GLXextFuncPtr
) glXAllocateMemoryNV
},
1313 { "glXFreeMemoryNV", (__GLXextFuncPtr
) glXFreeMemoryNV
},
1315 /*** GLX_MESA_agp_offset ***/
1316 { "glXGetAGPOffsetMESA", (__GLXextFuncPtr
) glXGetAGPOffsetMESA
},
1318 /*** GLX_EXT_texture_from_pixmap ***/
1319 { "glXBindTexImageEXT", (__GLXextFuncPtr
) glXBindTexImageEXT
},
1320 { "glXReleaseTexImageEXT", (__GLXextFuncPtr
) glXReleaseTexImageEXT
},
1322 /*** GLX_ARB_create_context ***/
1323 { "glXCreateContextAttribsARB", (__GLXextFuncPtr
) glXCreateContextAttribsARB
},
1325 { NULL
, NULL
} /* end of list */
1331 * Return address of named glX function, or NULL if not found.
1334 _glxapi_get_proc_address(const char *funcName
)
1337 for (i
= 0; GLX_functions
[i
].Name
; i
++) {
1339 /* skip the "m" prefix on the name */
1340 if (strcmp(GLX_functions
[i
].Name
, funcName
+1) == 0)
1342 if (strcmp(GLX_functions
[i
].Name
, funcName
) == 0)
1344 return GLX_functions
[i
].Address
;
1352 * This function does not get dispatched through the dispatch table
1353 * since it's really a "meta" function.
1355 __GLXextFuncPtr PUBLIC
1356 glXGetProcAddressARB(const GLubyte
*procName
)
1360 f
= _glxapi_get_proc_address((const char *) procName
);
1365 f
= (__GLXextFuncPtr
) _glapi_get_proc_address((const char *) procName
);
1372 (*glXGetProcAddress(const GLubyte
*procName
))()
1374 return glXGetProcAddressARB(procName
);
1379 * Added in GLX_ARB_create_context.
1382 glXCreateContextAttribsARB(Display
*dpy
, GLXFBConfig config
,
1383 GLXContext share_context
, Bool direct
,
1384 const int *attrib_list
)
1386 struct _glxapi_table
*t
;
1387 GET_DISPATCH(dpy
, t
);
1390 return (t
->CreateContextAttribs
)(dpy
, config
, share_context
, direct
,