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 ***/
382 /* declare here to avoid including xmesa.h */
383 extern Display
*XMesaGetCurrentDisplay(void);
386 glXGetCurrentDisplay(void)
388 return XMesaGetCurrentDisplay();
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 "GLX_EXT_import_context",
1109 "GLX_SGI_video_sync",
1110 "GLX_MESA_copy_sub_buffer",
1111 "GLX_MESA_release_buffers",
1112 "GLX_MESA_pixmap_colormap",
1113 "GLX_MESA_set_3dfx_mode",
1114 "GLX_SGIX_fbconfig",
1116 "GLX_EXT_texture_from_pixmap",
1117 "GLX_INTEL_swap_event",
1125 * Return size of the GLX dispatch table, in entries, not bytes.
1128 _glxapi_get_dispatch_table_size(void)
1130 return sizeof(struct _glxapi_table
) / sizeof(void *);
1135 generic_no_op_func(void)
1142 * Initialize all functions in given dispatch table to be no-ops
1145 _glxapi_set_no_op_table(struct _glxapi_table
*t
)
1147 typedef int (*nop_func
)(void);
1148 nop_func
*dispatch
= (nop_func
*) t
;
1149 GLuint n
= _glxapi_get_dispatch_table_size();
1151 for (i
= 0; i
< n
; i
++) {
1152 dispatch
[i
] = generic_no_op_func
;
1157 struct name_address_pair
{
1159 __GLXextFuncPtr Address
;
1162 static struct name_address_pair GLX_functions
[] = {
1163 /*** GLX_VERSION_1_0 ***/
1164 { "glXChooseVisual", (__GLXextFuncPtr
) glXChooseVisual
},
1165 { "glXCopyContext", (__GLXextFuncPtr
) glXCopyContext
},
1166 { "glXCreateContext", (__GLXextFuncPtr
) glXCreateContext
},
1167 { "glXCreateGLXPixmap", (__GLXextFuncPtr
) glXCreateGLXPixmap
},
1168 { "glXDestroyContext", (__GLXextFuncPtr
) glXDestroyContext
},
1169 { "glXDestroyGLXPixmap", (__GLXextFuncPtr
) glXDestroyGLXPixmap
},
1170 { "glXGetConfig", (__GLXextFuncPtr
) glXGetConfig
},
1171 { "glXGetCurrentContext", (__GLXextFuncPtr
) glXGetCurrentContext
},
1172 { "glXGetCurrentDrawable", (__GLXextFuncPtr
) glXGetCurrentDrawable
},
1173 { "glXIsDirect", (__GLXextFuncPtr
) glXIsDirect
},
1174 { "glXMakeCurrent", (__GLXextFuncPtr
) glXMakeCurrent
},
1175 { "glXQueryExtension", (__GLXextFuncPtr
) glXQueryExtension
},
1176 { "glXQueryVersion", (__GLXextFuncPtr
) glXQueryVersion
},
1177 { "glXSwapBuffers", (__GLXextFuncPtr
) glXSwapBuffers
},
1178 { "glXUseXFont", (__GLXextFuncPtr
) glXUseXFont
},
1179 { "glXWaitGL", (__GLXextFuncPtr
) glXWaitGL
},
1180 { "glXWaitX", (__GLXextFuncPtr
) glXWaitX
},
1182 /*** GLX_VERSION_1_1 ***/
1183 { "glXGetClientString", (__GLXextFuncPtr
) glXGetClientString
},
1184 { "glXQueryExtensionsString", (__GLXextFuncPtr
) glXQueryExtensionsString
},
1185 { "glXQueryServerString", (__GLXextFuncPtr
) glXQueryServerString
},
1187 /*** GLX_VERSION_1_2 ***/
1188 { "glXGetCurrentDisplay", (__GLXextFuncPtr
) glXGetCurrentDisplay
},
1190 /*** GLX_VERSION_1_3 ***/
1191 { "glXChooseFBConfig", (__GLXextFuncPtr
) glXChooseFBConfig
},
1192 { "glXCreateNewContext", (__GLXextFuncPtr
) glXCreateNewContext
},
1193 { "glXCreatePbuffer", (__GLXextFuncPtr
) glXCreatePbuffer
},
1194 { "glXCreatePixmap", (__GLXextFuncPtr
) glXCreatePixmap
},
1195 { "glXCreateWindow", (__GLXextFuncPtr
) glXCreateWindow
},
1196 { "glXDestroyPbuffer", (__GLXextFuncPtr
) glXDestroyPbuffer
},
1197 { "glXDestroyPixmap", (__GLXextFuncPtr
) glXDestroyPixmap
},
1198 { "glXDestroyWindow", (__GLXextFuncPtr
) glXDestroyWindow
},
1199 { "glXGetCurrentReadDrawable", (__GLXextFuncPtr
) glXGetCurrentReadDrawable
},
1200 { "glXGetFBConfigAttrib", (__GLXextFuncPtr
) glXGetFBConfigAttrib
},
1201 { "glXGetFBConfigs", (__GLXextFuncPtr
) glXGetFBConfigs
},
1202 { "glXGetSelectedEvent", (__GLXextFuncPtr
) glXGetSelectedEvent
},
1203 { "glXGetVisualFromFBConfig", (__GLXextFuncPtr
) glXGetVisualFromFBConfig
},
1204 { "glXMakeContextCurrent", (__GLXextFuncPtr
) glXMakeContextCurrent
},
1205 { "glXQueryContext", (__GLXextFuncPtr
) glXQueryContext
},
1206 { "glXQueryDrawable", (__GLXextFuncPtr
) glXQueryDrawable
},
1207 { "glXSelectEvent", (__GLXextFuncPtr
) glXSelectEvent
},
1209 /*** GLX_VERSION_1_4 ***/
1210 { "glXGetProcAddress", (__GLXextFuncPtr
) glXGetProcAddress
},
1212 /*** GLX_SGI_swap_control ***/
1213 { "glXSwapIntervalSGI", (__GLXextFuncPtr
) glXSwapIntervalSGI
},
1215 /*** GLX_SGI_video_sync ***/
1216 { "glXGetVideoSyncSGI", (__GLXextFuncPtr
) glXGetVideoSyncSGI
},
1217 { "glXWaitVideoSyncSGI", (__GLXextFuncPtr
) glXWaitVideoSyncSGI
},
1219 /*** GLX_SGI_make_current_read ***/
1220 { "glXMakeCurrentReadSGI", (__GLXextFuncPtr
) glXMakeCurrentReadSGI
},
1221 { "glXGetCurrentReadDrawableSGI", (__GLXextFuncPtr
) glXGetCurrentReadDrawableSGI
},
1223 /*** GLX_SGIX_video_source ***/
1225 { "glXCreateGLXVideoSourceSGIX", (__GLXextFuncPtr
) glXCreateGLXVideoSourceSGIX
},
1226 { "glXDestroyGLXVideoSourceSGIX", (__GLXextFuncPtr
) glXDestroyGLXVideoSourceSGIX
},
1229 /*** GLX_EXT_import_context ***/
1230 { "glXFreeContextEXT", (__GLXextFuncPtr
) glXFreeContextEXT
},
1231 { "glXGetContextIDEXT", (__GLXextFuncPtr
) glXGetContextIDEXT
},
1232 { "glXGetCurrentDisplayEXT", (__GLXextFuncPtr
) glXGetCurrentDisplayEXT
},
1233 { "glXImportContextEXT", (__GLXextFuncPtr
) glXImportContextEXT
},
1234 { "glXQueryContextInfoEXT", (__GLXextFuncPtr
) glXQueryContextInfoEXT
},
1236 /*** GLX_SGIX_fbconfig ***/
1237 { "glXGetFBConfigAttribSGIX", (__GLXextFuncPtr
) glXGetFBConfigAttribSGIX
},
1238 { "glXChooseFBConfigSGIX", (__GLXextFuncPtr
) glXChooseFBConfigSGIX
},
1239 { "glXCreateGLXPixmapWithConfigSGIX", (__GLXextFuncPtr
) glXCreateGLXPixmapWithConfigSGIX
},
1240 { "glXCreateContextWithConfigSGIX", (__GLXextFuncPtr
) glXCreateContextWithConfigSGIX
},
1241 { "glXGetVisualFromFBConfigSGIX", (__GLXextFuncPtr
) glXGetVisualFromFBConfigSGIX
},
1242 { "glXGetFBConfigFromVisualSGIX", (__GLXextFuncPtr
) glXGetFBConfigFromVisualSGIX
},
1244 /*** GLX_SGIX_pbuffer ***/
1245 { "glXCreateGLXPbufferSGIX", (__GLXextFuncPtr
) glXCreateGLXPbufferSGIX
},
1246 { "glXDestroyGLXPbufferSGIX", (__GLXextFuncPtr
) glXDestroyGLXPbufferSGIX
},
1247 { "glXQueryGLXPbufferSGIX", (__GLXextFuncPtr
) glXQueryGLXPbufferSGIX
},
1248 { "glXSelectEventSGIX", (__GLXextFuncPtr
) glXSelectEventSGIX
},
1249 { "glXGetSelectedEventSGIX", (__GLXextFuncPtr
) glXGetSelectedEventSGIX
},
1251 /*** GLX_SGI_cushion ***/
1252 { "glXCushionSGI", (__GLXextFuncPtr
) glXCushionSGI
},
1254 /*** GLX_SGIX_video_resize ***/
1255 { "glXBindChannelToWindowSGIX", (__GLXextFuncPtr
) glXBindChannelToWindowSGIX
},
1256 { "glXChannelRectSGIX", (__GLXextFuncPtr
) glXChannelRectSGIX
},
1257 { "glXQueryChannelRectSGIX", (__GLXextFuncPtr
) glXQueryChannelRectSGIX
},
1258 { "glXQueryChannelDeltasSGIX", (__GLXextFuncPtr
) glXQueryChannelDeltasSGIX
},
1259 { "glXChannelRectSyncSGIX", (__GLXextFuncPtr
) glXChannelRectSyncSGIX
},
1261 /*** GLX_SGIX_dmbuffer **/
1262 #if defined(_DM_BUFFER_H_)
1263 { "glXAssociateDMPbufferSGIX", (__GLXextFuncPtr
) glXAssociateDMPbufferSGIX
},
1266 /*** GLX_SGIX_swap_group ***/
1267 { "glXJoinSwapGroupSGIX", (__GLXextFuncPtr
) glXJoinSwapGroupSGIX
},
1269 /*** GLX_SGIX_swap_barrier ***/
1270 { "glXBindSwapBarrierSGIX", (__GLXextFuncPtr
) glXBindSwapBarrierSGIX
},
1271 { "glXQueryMaxSwapBarriersSGIX", (__GLXextFuncPtr
) glXQueryMaxSwapBarriersSGIX
},
1273 /*** GLX_SUN_get_transparent_index ***/
1274 { "glXGetTransparentIndexSUN", (__GLXextFuncPtr
) glXGetTransparentIndexSUN
},
1276 /*** GLX_MESA_copy_sub_buffer ***/
1277 { "glXCopySubBufferMESA", (__GLXextFuncPtr
) glXCopySubBufferMESA
},
1279 /*** GLX_MESA_pixmap_colormap ***/
1280 { "glXCreateGLXPixmapMESA", (__GLXextFuncPtr
) glXCreateGLXPixmapMESA
},
1282 /*** GLX_MESA_release_buffers ***/
1283 { "glXReleaseBuffersMESA", (__GLXextFuncPtr
) glXReleaseBuffersMESA
},
1285 /*** GLX_MESA_set_3dfx_mode ***/
1286 { "glXSet3DfxModeMESA", (__GLXextFuncPtr
) glXSet3DfxModeMESA
},
1288 /*** GLX_ARB_get_proc_address ***/
1289 { "glXGetProcAddressARB", (__GLXextFuncPtr
) glXGetProcAddressARB
},
1291 /*** GLX_NV_vertex_array_range ***/
1292 { "glXAllocateMemoryNV", (__GLXextFuncPtr
) glXAllocateMemoryNV
},
1293 { "glXFreeMemoryNV", (__GLXextFuncPtr
) glXFreeMemoryNV
},
1295 /*** GLX_MESA_agp_offset ***/
1296 { "glXGetAGPOffsetMESA", (__GLXextFuncPtr
) glXGetAGPOffsetMESA
},
1298 /*** GLX_EXT_texture_from_pixmap ***/
1299 { "glXBindTexImageEXT", (__GLXextFuncPtr
) glXBindTexImageEXT
},
1300 { "glXReleaseTexImageEXT", (__GLXextFuncPtr
) glXReleaseTexImageEXT
},
1302 /*** GLX_ARB_create_context ***/
1303 { "glXCreateContextAttribsARB", (__GLXextFuncPtr
) glXCreateContextAttribsARB
},
1305 { NULL
, NULL
} /* end of list */
1311 * Return address of named glX function, or NULL if not found.
1314 _glxapi_get_proc_address(const char *funcName
)
1317 for (i
= 0; GLX_functions
[i
].Name
; i
++) {
1319 /* skip the "m" prefix on the name */
1320 if (strcmp(GLX_functions
[i
].Name
, funcName
+1) == 0)
1322 if (strcmp(GLX_functions
[i
].Name
, funcName
) == 0)
1324 return GLX_functions
[i
].Address
;
1332 * This function does not get dispatched through the dispatch table
1333 * since it's really a "meta" function.
1335 __GLXextFuncPtr PUBLIC
1336 glXGetProcAddressARB(const GLubyte
*procName
)
1340 f
= _glxapi_get_proc_address((const char *) procName
);
1345 f
= (__GLXextFuncPtr
) _glapi_get_proc_address((const char *) procName
);
1352 (*glXGetProcAddress(const GLubyte
*procName
))()
1354 return glXGetProcAddressARB(procName
);
1359 * Added in GLX_ARB_create_context.
1362 glXCreateContextAttribsARB(Display
*dpy
, GLXFBConfig config
,
1363 GLXContext share_context
, Bool direct
,
1364 const int *attrib_list
)
1366 struct _glxapi_table
*t
;
1367 GET_DISPATCH(dpy
, t
);
1370 return t
->CreateContextAttribs(dpy
, config
, share_context
, direct
,