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 "glapi/glapi.h"
42 extern struct _glxapi_table
*_mesa_GetGLXDispatchTable(void);
45 struct display_dispatch
{
47 struct _glxapi_table
*Table
;
48 struct display_dispatch
*Next
;
53 * When GLX_INDIRECT_RENDERING is defined, some symbols are missing in
54 * libglapi.a. We need to define them here.
56 #ifdef GLX_INDIRECT_RENDERING
58 #include "glapi/glapitable.h"
60 #define KEYWORD1 PUBLIC
62 #if defined(USE_MGL_NAMESPACE)
63 #define NAME(func) mgl##func
65 #define NAME(func) gl##func
68 #define DISPATCH(FUNC, ARGS, MESSAGE) \
69 GET_DISPATCH()->FUNC ARGS
71 #define RETURN_DISPATCH(FUNC, ARGS, MESSAGE) \
72 return GET_DISPATCH()->FUNC ARGS
74 /* skip normal ones */
75 #define _GLAPI_SKIP_NORMAL_ENTRY_POINTS
76 #include "glapi/glapitemp.h"
78 #endif /* GLX_INDIRECT_RENDERING */
81 static struct display_dispatch
*DispatchList
= NULL
;
84 /* Display -> Dispatch caching */
85 static Display
*prevDisplay
= NULL
;
86 static struct _glxapi_table
*prevTable
= NULL
;
89 static struct _glxapi_table
*
90 get_dispatch(Display
*dpy
)
95 /* search list of display/dispatch pairs for this display */
97 const struct display_dispatch
*d
= DispatchList
;
101 prevTable
= d
->Table
;
102 return d
->Table
; /* done! */
108 /* Setup the dispatch table */
110 struct _glxapi_table
*t
= _mesa_GetGLXDispatchTable();
113 struct display_dispatch
*d
;
114 d
= malloc(sizeof(struct display_dispatch
));
118 /* insert at head of list */
119 d
->Next
= DispatchList
;
133 /* Don't use the GET_DISPATCH macro */
136 #define GET_DISPATCH(DPY, TABLE) \
137 if (DPY == prevDisplay) { \
144 TABLE = get_dispatch(DPY); \
149 * GLX API entrypoints
152 /*** GLX_VERSION_1_0 ***/
155 glXChooseVisual(Display
*dpy
, int screen
, int *list
)
157 struct _glxapi_table
*t
;
158 GET_DISPATCH(dpy
, t
);
161 return t
->ChooseVisual(dpy
, screen
, list
);
166 glXCopyContext(Display
*dpy
, GLXContext src
, GLXContext dst
, unsigned long mask
)
168 struct _glxapi_table
*t
;
169 GET_DISPATCH(dpy
, t
);
172 t
->CopyContext(dpy
, src
, dst
, mask
);
177 glXCreateContext(Display
*dpy
, XVisualInfo
*visinfo
, GLXContext shareList
, Bool direct
)
179 struct _glxapi_table
*t
;
180 GET_DISPATCH(dpy
, t
);
183 return t
->CreateContext(dpy
, visinfo
, shareList
, direct
);
188 glXCreateGLXPixmap(Display
*dpy
, XVisualInfo
*visinfo
, Pixmap pixmap
)
190 struct _glxapi_table
*t
;
191 GET_DISPATCH(dpy
, t
);
194 return t
->CreateGLXPixmap(dpy
, visinfo
, pixmap
);
199 glXDestroyContext(Display
*dpy
, GLXContext ctx
)
201 struct _glxapi_table
*t
;
202 GET_DISPATCH(dpy
, t
);
205 t
->DestroyContext(dpy
, ctx
);
210 glXDestroyGLXPixmap(Display
*dpy
, GLXPixmap pixmap
)
212 struct _glxapi_table
*t
;
213 GET_DISPATCH(dpy
, t
);
216 t
->DestroyGLXPixmap(dpy
, pixmap
);
221 glXGetConfig(Display
*dpy
, XVisualInfo
*visinfo
, int attrib
, int *value
)
223 struct _glxapi_table
*t
;
224 GET_DISPATCH(dpy
, t
);
226 return GLX_NO_EXTENSION
;
227 return t
->GetConfig(dpy
, visinfo
, attrib
, value
);
231 /* declare here to avoid including xmesa.h */
232 extern void *XMesaGetCurrentContext(void);
235 glXGetCurrentContext(void)
237 return (GLXContext
) XMesaGetCurrentContext();
242 glXGetCurrentDrawable(void)
244 __GLXcontext
*gc
= (__GLXcontext
*) glXGetCurrentContext();
245 return gc
? gc
->currentDrawable
: 0;
250 glXIsDirect(Display
*dpy
, GLXContext ctx
)
252 struct _glxapi_table
*t
;
253 GET_DISPATCH(dpy
, t
);
256 return t
->IsDirect(dpy
, ctx
);
261 glXMakeCurrent(Display
*dpy
, GLXDrawable drawable
, GLXContext ctx
)
264 struct _glxapi_table
*t
;
265 GET_DISPATCH(dpy
, t
);
269 b
= t
->MakeCurrent(dpy
, drawable
, ctx
);
275 glXQueryExtension(Display
*dpy
, int *errorb
, int *event
)
277 struct _glxapi_table
*t
;
278 GET_DISPATCH(dpy
, t
);
281 return t
->QueryExtension(dpy
, errorb
, event
);
286 glXQueryVersion(Display
*dpy
, int *maj
, int *min
)
288 struct _glxapi_table
*t
;
289 GET_DISPATCH(dpy
, t
);
292 return t
->QueryVersion(dpy
, maj
, min
);
297 glXSwapBuffers(Display
*dpy
, GLXDrawable drawable
)
299 struct _glxapi_table
*t
;
300 GET_DISPATCH(dpy
, t
);
303 t
->SwapBuffers(dpy
, drawable
);
308 glXUseXFont(Font font
, int first
, int count
, int listBase
)
310 struct _glxapi_table
*t
;
311 Display
*dpy
= glXGetCurrentDisplay();
312 GET_DISPATCH(dpy
, t
);
315 t
->UseXFont(font
, first
, count
, listBase
);
322 struct _glxapi_table
*t
;
323 Display
*dpy
= glXGetCurrentDisplay();
324 GET_DISPATCH(dpy
, t
);
334 struct _glxapi_table
*t
;
335 Display
*dpy
= glXGetCurrentDisplay();
336 GET_DISPATCH(dpy
, t
);
344 /*** GLX_VERSION_1_1 ***/
347 glXGetClientString(Display
*dpy
, int name
)
349 struct _glxapi_table
*t
;
350 GET_DISPATCH(dpy
, t
);
353 return t
->GetClientString(dpy
, name
);
358 glXQueryExtensionsString(Display
*dpy
, int screen
)
360 struct _glxapi_table
*t
;
361 GET_DISPATCH(dpy
, t
);
364 return t
->QueryExtensionsString(dpy
, screen
);
369 glXQueryServerString(Display
*dpy
, int screen
, int name
)
371 struct _glxapi_table
*t
;
372 GET_DISPATCH(dpy
, t
);
375 return t
->QueryServerString(dpy
, screen
, name
);
379 /*** GLX_VERSION_1_2 ***/
381 /* declare here to avoid including xmesa.h */
382 extern Display
*XMesaGetCurrentDisplay(void);
385 glXGetCurrentDisplay(void)
387 return XMesaGetCurrentDisplay();
392 /*** GLX_VERSION_1_3 ***/
395 glXChooseFBConfig(Display
*dpy
, int screen
, const int *attribList
, int *nitems
)
397 struct _glxapi_table
*t
;
398 GET_DISPATCH(dpy
, t
);
401 return t
->ChooseFBConfig(dpy
, screen
, attribList
, nitems
);
406 glXCreateNewContext(Display
*dpy
, GLXFBConfig config
, int renderType
, GLXContext shareList
, Bool direct
)
408 struct _glxapi_table
*t
;
409 GET_DISPATCH(dpy
, t
);
412 return t
->CreateNewContext(dpy
, config
, renderType
, shareList
, direct
);
417 glXCreatePbuffer(Display
*dpy
, GLXFBConfig config
, const int *attribList
)
419 struct _glxapi_table
*t
;
420 GET_DISPATCH(dpy
, t
);
423 return t
->CreatePbuffer(dpy
, config
, attribList
);
428 glXCreatePixmap(Display
*dpy
, GLXFBConfig config
, Pixmap pixmap
, const int *attribList
)
430 struct _glxapi_table
*t
;
431 GET_DISPATCH(dpy
, t
);
434 return t
->CreatePixmap(dpy
, config
, pixmap
, attribList
);
439 glXCreateWindow(Display
*dpy
, GLXFBConfig config
, Window win
, const int *attribList
)
441 struct _glxapi_table
*t
;
442 GET_DISPATCH(dpy
, t
);
445 return t
->CreateWindow(dpy
, config
, win
, attribList
);
450 glXDestroyPbuffer(Display
*dpy
, GLXPbuffer pbuf
)
452 struct _glxapi_table
*t
;
453 GET_DISPATCH(dpy
, t
);
456 t
->DestroyPbuffer(dpy
, pbuf
);
461 glXDestroyPixmap(Display
*dpy
, GLXPixmap pixmap
)
463 struct _glxapi_table
*t
;
464 GET_DISPATCH(dpy
, t
);
467 t
->DestroyPixmap(dpy
, pixmap
);
472 glXDestroyWindow(Display
*dpy
, GLXWindow window
)
474 struct _glxapi_table
*t
;
475 GET_DISPATCH(dpy
, t
);
478 t
->DestroyWindow(dpy
, window
);
483 glXGetCurrentReadDrawable(void)
485 __GLXcontext
*gc
= (__GLXcontext
*) glXGetCurrentContext();
486 return gc
? gc
->currentReadable
: 0;
491 glXGetFBConfigAttrib(Display
*dpy
, GLXFBConfig config
, int attribute
, int *value
)
493 struct _glxapi_table
*t
;
494 GET_DISPATCH(dpy
, t
);
496 return GLX_NO_EXTENSION
;
497 return t
->GetFBConfigAttrib(dpy
, config
, attribute
, value
);
502 glXGetFBConfigs(Display
*dpy
, int screen
, int *nelements
)
504 struct _glxapi_table
*t
;
505 GET_DISPATCH(dpy
, t
);
508 return t
->GetFBConfigs(dpy
, screen
, nelements
);
512 glXGetSelectedEvent(Display
*dpy
, GLXDrawable drawable
, unsigned long *mask
)
514 struct _glxapi_table
*t
;
515 GET_DISPATCH(dpy
, t
);
518 t
->GetSelectedEvent(dpy
, drawable
, mask
);
523 glXGetVisualFromFBConfig(Display
*dpy
, GLXFBConfig config
)
525 struct _glxapi_table
*t
;
526 GET_DISPATCH(dpy
, t
);
529 return t
->GetVisualFromFBConfig(dpy
, config
);
534 glXMakeContextCurrent(Display
*dpy
, GLXDrawable draw
, GLXDrawable read
, GLXContext ctx
)
537 struct _glxapi_table
*t
;
538 GET_DISPATCH(dpy
, t
);
541 b
= t
->MakeContextCurrent(dpy
, draw
, read
, ctx
);
547 glXQueryContext(Display
*dpy
, GLXContext ctx
, int attribute
, int *value
)
549 struct _glxapi_table
*t
;
550 GET_DISPATCH(dpy
, t
);
553 return 0; /* XXX correct? */
554 return t
->QueryContext(dpy
, ctx
, attribute
, value
);
559 glXQueryDrawable(Display
*dpy
, GLXDrawable draw
, int attribute
, unsigned int *value
)
561 struct _glxapi_table
*t
;
562 GET_DISPATCH(dpy
, t
);
565 t
->QueryDrawable(dpy
, draw
, attribute
, value
);
570 glXSelectEvent(Display
*dpy
, GLXDrawable drawable
, unsigned long mask
)
572 struct _glxapi_table
*t
;
573 GET_DISPATCH(dpy
, t
);
576 t
->SelectEvent(dpy
, drawable
, mask
);
581 /*** GLX_SGI_swap_control ***/
584 glXSwapIntervalSGI(int interval
)
586 struct _glxapi_table
*t
;
587 Display
*dpy
= glXGetCurrentDisplay();
588 GET_DISPATCH(dpy
, t
);
591 return t
->SwapIntervalSGI(interval
);
596 /*** GLX_SGI_video_sync ***/
599 glXGetVideoSyncSGI(unsigned int *count
)
601 struct _glxapi_table
*t
;
602 Display
*dpy
= glXGetCurrentDisplay();
603 GET_DISPATCH(dpy
, t
);
604 if (!t
|| !glXGetCurrentContext())
605 return GLX_BAD_CONTEXT
;
606 return t
->GetVideoSyncSGI(count
);
610 glXWaitVideoSyncSGI(int divisor
, int remainder
, unsigned int *count
)
612 struct _glxapi_table
*t
;
613 Display
*dpy
= glXGetCurrentDisplay();
614 GET_DISPATCH(dpy
, t
);
615 if (!t
|| !glXGetCurrentContext())
616 return GLX_BAD_CONTEXT
;
617 return t
->WaitVideoSyncSGI(divisor
, remainder
, count
);
622 /*** GLX_SGI_make_current_read ***/
625 glXMakeCurrentReadSGI(Display
*dpy
, GLXDrawable draw
, GLXDrawable read
, GLXContext ctx
)
627 struct _glxapi_table
*t
;
628 GET_DISPATCH(dpy
, t
);
631 return t
->MakeCurrentReadSGI(dpy
, draw
, read
, ctx
);
635 glXGetCurrentReadDrawableSGI(void)
637 return glXGetCurrentReadDrawable();
643 GLXVideoSourceSGIX PUBLIC
644 glXCreateGLXVideoSourceSGIX(Display
*dpy
, int screen
, VLServer server
, VLPath path
, int nodeClass
, VLNode drainNode
)
646 struct _glxapi_table
*t
;
647 GET_DISPATCH(dpy
, t
);
650 return t
->CreateGLXVideoSourceSGIX(dpy
, screen
, server
, path
, nodeClass
, drainNode
);
654 glXDestroyGLXVideoSourceSGIX(Display
*dpy
, GLXVideoSourceSGIX src
)
656 struct _glxapi_table
*t
;
657 GET_DISPATCH(dpy
, t
);
660 return t
->DestroyGLXVideoSourceSGIX(dpy
, src
);
666 /*** GLX_EXT_import_context ***/
669 glXFreeContextEXT(Display
*dpy
, GLXContext context
)
671 struct _glxapi_table
*t
;
672 GET_DISPATCH(dpy
, t
);
675 t
->FreeContextEXT(dpy
, context
);
679 glXGetContextIDEXT(const GLXContext context
)
681 return ((__GLXcontext
*) context
)->xid
;
685 glXGetCurrentDisplayEXT(void)
687 return glXGetCurrentDisplay();
691 glXImportContextEXT(Display
*dpy
, GLXContextID contextID
)
693 struct _glxapi_table
*t
;
694 GET_DISPATCH(dpy
, t
);
697 return t
->ImportContextEXT(dpy
, contextID
);
701 glXQueryContextInfoEXT(Display
*dpy
, GLXContext context
, int attribute
,int *value
)
703 struct _glxapi_table
*t
;
704 GET_DISPATCH(dpy
, t
);
706 return 0; /* XXX ok? */
707 return t
->QueryContextInfoEXT(dpy
, context
, attribute
, value
);
712 /*** GLX_SGIX_fbconfig ***/
715 glXGetFBConfigAttribSGIX(Display
*dpy
, GLXFBConfigSGIX config
, int attribute
, int *value
)
717 struct _glxapi_table
*t
;
718 GET_DISPATCH(dpy
, t
);
721 return t
->GetFBConfigAttribSGIX(dpy
, config
, attribute
, value
);
724 GLXFBConfigSGIX PUBLIC
*
725 glXChooseFBConfigSGIX(Display
*dpy
, int screen
, int *attrib_list
, int *nelements
)
727 struct _glxapi_table
*t
;
728 GET_DISPATCH(dpy
, t
);
731 return t
->ChooseFBConfigSGIX(dpy
, screen
, attrib_list
, nelements
);
735 glXCreateGLXPixmapWithConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
, Pixmap pixmap
)
737 struct _glxapi_table
*t
;
738 GET_DISPATCH(dpy
, t
);
741 return t
->CreateGLXPixmapWithConfigSGIX(dpy
, config
, pixmap
);
745 glXCreateContextWithConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
, int render_type
, GLXContext share_list
, Bool direct
)
747 struct _glxapi_table
*t
;
748 GET_DISPATCH(dpy
, t
);
751 return t
->CreateContextWithConfigSGIX(dpy
, config
, render_type
, share_list
, direct
);
755 glXGetVisualFromFBConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
)
757 struct _glxapi_table
*t
;
758 GET_DISPATCH(dpy
, t
);
761 return t
->GetVisualFromFBConfigSGIX(dpy
, config
);
764 GLXFBConfigSGIX PUBLIC
765 glXGetFBConfigFromVisualSGIX(Display
*dpy
, XVisualInfo
*vis
)
767 struct _glxapi_table
*t
;
768 GET_DISPATCH(dpy
, t
);
771 return t
->GetFBConfigFromVisualSGIX(dpy
, vis
);
776 /*** GLX_SGIX_pbuffer ***/
778 GLXPbufferSGIX PUBLIC
779 glXCreateGLXPbufferSGIX(Display
*dpy
, GLXFBConfigSGIX config
, unsigned int width
, unsigned int height
, int *attrib_list
)
781 struct _glxapi_table
*t
;
782 GET_DISPATCH(dpy
, t
);
785 return t
->CreateGLXPbufferSGIX(dpy
, config
, width
, height
, attrib_list
);
789 glXDestroyGLXPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuf
)
791 struct _glxapi_table
*t
;
792 GET_DISPATCH(dpy
, t
);
795 t
->DestroyGLXPbufferSGIX(dpy
, pbuf
);
799 glXQueryGLXPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuf
, int attribute
, unsigned int *value
)
801 struct _glxapi_table
*t
;
802 GET_DISPATCH(dpy
, t
);
805 return t
->QueryGLXPbufferSGIX(dpy
, pbuf
, attribute
, value
);
809 glXSelectEventSGIX(Display
*dpy
, GLXDrawable drawable
, unsigned long mask
)
811 struct _glxapi_table
*t
;
812 GET_DISPATCH(dpy
, t
);
815 t
->SelectEventSGIX(dpy
, drawable
, mask
);
819 glXGetSelectedEventSGIX(Display
*dpy
, GLXDrawable drawable
, unsigned long *mask
)
821 struct _glxapi_table
*t
;
822 GET_DISPATCH(dpy
, t
);
825 t
->GetSelectedEventSGIX(dpy
, drawable
, mask
);
830 /*** GLX_SGI_cushion ***/
833 glXCushionSGI(Display
*dpy
, Window win
, float cushion
)
835 struct _glxapi_table
*t
;
836 GET_DISPATCH(dpy
, t
);
839 t
->CushionSGI(dpy
, win
, cushion
);
844 /*** GLX_SGIX_video_resize ***/
847 glXBindChannelToWindowSGIX(Display
*dpy
, int screen
, int channel
, Window window
)
849 struct _glxapi_table
*t
;
850 GET_DISPATCH(dpy
, t
);
853 return t
->BindChannelToWindowSGIX(dpy
, screen
, channel
, window
);
857 glXChannelRectSGIX(Display
*dpy
, int screen
, int channel
, int x
, int y
, int w
, int h
)
859 struct _glxapi_table
*t
;
860 GET_DISPATCH(dpy
, t
);
863 return t
->ChannelRectSGIX(dpy
, screen
, channel
, x
, y
, w
, h
);
867 glXQueryChannelRectSGIX(Display
*dpy
, int screen
, int channel
, int *x
, int *y
, int *w
, int *h
)
869 struct _glxapi_table
*t
;
870 GET_DISPATCH(dpy
, t
);
873 return t
->QueryChannelRectSGIX(dpy
, screen
, channel
, x
, y
, w
, h
);
877 glXQueryChannelDeltasSGIX(Display
*dpy
, int screen
, int channel
, int *dx
, int *dy
, int *dw
, int *dh
)
879 struct _glxapi_table
*t
;
880 GET_DISPATCH(dpy
, t
);
883 return t
->QueryChannelDeltasSGIX(dpy
, screen
, channel
, dx
, dy
, dw
, dh
);
887 glXChannelRectSyncSGIX(Display
*dpy
, int screen
, int channel
, GLenum synctype
)
889 struct _glxapi_table
*t
;
890 GET_DISPATCH(dpy
, t
);
893 return t
->ChannelRectSyncSGIX(dpy
, screen
, channel
, synctype
);
898 #if defined(_DM_BUFFER_H_)
901 glXAssociateDMPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuffer
, DMparams
*params
, DMbuffer dmbuffer
)
903 struct _glxapi_table
*t
;
904 GET_DISPATCH(dpy
, t
);
907 return t
->AssociateDMPbufferSGIX(dpy
, pbuffer
, params
, dmbuffer
);
913 /*** GLX_SGIX_swap_group ***/
916 glXJoinSwapGroupSGIX(Display
*dpy
, GLXDrawable drawable
, GLXDrawable member
)
918 struct _glxapi_table
*t
;
919 GET_DISPATCH(dpy
, t
);
922 t
->JoinSwapGroupSGIX(dpy
, drawable
, member
);
926 /*** GLX_SUN_get_transparent_index ***/
929 glXGetTransparentIndexSUN(Display
*dpy
, Window overlay
, Window underlay
, long *pTransparent
)
931 struct _glxapi_table
*t
;
932 GET_DISPATCH(dpy
, t
);
935 return t
->GetTransparentIndexSUN(dpy
, overlay
, underlay
, pTransparent
);
940 /*** GLX_MESA_copy_sub_buffer ***/
943 glXCopySubBufferMESA(Display
*dpy
, GLXDrawable drawable
, int x
, int y
, int width
, int height
)
945 struct _glxapi_table
*t
;
946 GET_DISPATCH(dpy
, t
);
949 t
->CopySubBufferMESA(dpy
, drawable
, x
, y
, width
, height
);
954 /*** GLX_MESA_release_buffers ***/
957 glXReleaseBuffersMESA(Display
*dpy
, Window w
)
959 struct _glxapi_table
*t
;
960 GET_DISPATCH(dpy
, t
);
963 return t
->ReleaseBuffersMESA(dpy
, w
);
968 /*** GLX_MESA_pixmap_colormap ***/
971 glXCreateGLXPixmapMESA(Display
*dpy
, XVisualInfo
*visinfo
, Pixmap pixmap
, Colormap cmap
)
973 struct _glxapi_table
*t
;
974 GET_DISPATCH(dpy
, t
);
977 return t
->CreateGLXPixmapMESA(dpy
, visinfo
, pixmap
, cmap
);
982 /*** GLX_EXT_texture_from_pixmap */
985 glXBindTexImageEXT(Display
*dpy
, GLXDrawable drawable
, int buffer
,
986 const int *attrib_list
)
988 struct _glxapi_table
*t
;
989 GET_DISPATCH(dpy
, t
);
991 t
->BindTexImageEXT(dpy
, drawable
, buffer
, attrib_list
);
995 glXReleaseTexImageEXT(Display
*dpy
, GLXDrawable drawable
, int buffer
)
997 struct _glxapi_table
*t
;
998 GET_DISPATCH(dpy
, t
);
1000 t
->ReleaseTexImageEXT(dpy
, drawable
, buffer
);
1004 /**********************************************************************/
1005 /* GLX API management functions */
1006 /**********************************************************************/
1010 _glxapi_get_version(void)
1017 * Return array of extension strings.
1020 _glxapi_get_extensions(void)
1022 static const char *extensions
[] = {
1023 "GLX_EXT_import_context",
1024 "GLX_SGI_video_sync",
1025 "GLX_MESA_copy_sub_buffer",
1026 "GLX_MESA_release_buffers",
1027 "GLX_MESA_pixmap_colormap",
1028 "GLX_SGIX_fbconfig",
1030 "GLX_EXT_texture_from_pixmap",
1031 "GLX_INTEL_swap_event",
1039 * Return size of the GLX dispatch table, in entries, not bytes.
1042 _glxapi_get_dispatch_table_size(void)
1044 return sizeof(struct _glxapi_table
) / sizeof(void *);
1049 generic_no_op_func(void)
1056 * Initialize all functions in given dispatch table to be no-ops
1059 _glxapi_set_no_op_table(struct _glxapi_table
*t
)
1061 typedef int (*nop_func
)(void);
1062 nop_func
*dispatch
= (nop_func
*) t
;
1063 GLuint n
= _glxapi_get_dispatch_table_size();
1065 for (i
= 0; i
< n
; i
++) {
1066 dispatch
[i
] = generic_no_op_func
;
1071 struct name_address_pair
{
1073 __GLXextFuncPtr Address
;
1076 static struct name_address_pair GLX_functions
[] = {
1077 /*** GLX_VERSION_1_0 ***/
1078 { "glXChooseVisual", (__GLXextFuncPtr
) glXChooseVisual
},
1079 { "glXCopyContext", (__GLXextFuncPtr
) glXCopyContext
},
1080 { "glXCreateContext", (__GLXextFuncPtr
) glXCreateContext
},
1081 { "glXCreateGLXPixmap", (__GLXextFuncPtr
) glXCreateGLXPixmap
},
1082 { "glXDestroyContext", (__GLXextFuncPtr
) glXDestroyContext
},
1083 { "glXDestroyGLXPixmap", (__GLXextFuncPtr
) glXDestroyGLXPixmap
},
1084 { "glXGetConfig", (__GLXextFuncPtr
) glXGetConfig
},
1085 { "glXGetCurrentContext", (__GLXextFuncPtr
) glXGetCurrentContext
},
1086 { "glXGetCurrentDrawable", (__GLXextFuncPtr
) glXGetCurrentDrawable
},
1087 { "glXIsDirect", (__GLXextFuncPtr
) glXIsDirect
},
1088 { "glXMakeCurrent", (__GLXextFuncPtr
) glXMakeCurrent
},
1089 { "glXQueryExtension", (__GLXextFuncPtr
) glXQueryExtension
},
1090 { "glXQueryVersion", (__GLXextFuncPtr
) glXQueryVersion
},
1091 { "glXSwapBuffers", (__GLXextFuncPtr
) glXSwapBuffers
},
1092 { "glXUseXFont", (__GLXextFuncPtr
) glXUseXFont
},
1093 { "glXWaitGL", (__GLXextFuncPtr
) glXWaitGL
},
1094 { "glXWaitX", (__GLXextFuncPtr
) glXWaitX
},
1096 /*** GLX_VERSION_1_1 ***/
1097 { "glXGetClientString", (__GLXextFuncPtr
) glXGetClientString
},
1098 { "glXQueryExtensionsString", (__GLXextFuncPtr
) glXQueryExtensionsString
},
1099 { "glXQueryServerString", (__GLXextFuncPtr
) glXQueryServerString
},
1101 /*** GLX_VERSION_1_2 ***/
1102 { "glXGetCurrentDisplay", (__GLXextFuncPtr
) glXGetCurrentDisplay
},
1104 /*** GLX_VERSION_1_3 ***/
1105 { "glXChooseFBConfig", (__GLXextFuncPtr
) glXChooseFBConfig
},
1106 { "glXCreateNewContext", (__GLXextFuncPtr
) glXCreateNewContext
},
1107 { "glXCreatePbuffer", (__GLXextFuncPtr
) glXCreatePbuffer
},
1108 { "glXCreatePixmap", (__GLXextFuncPtr
) glXCreatePixmap
},
1109 { "glXCreateWindow", (__GLXextFuncPtr
) glXCreateWindow
},
1110 { "glXDestroyPbuffer", (__GLXextFuncPtr
) glXDestroyPbuffer
},
1111 { "glXDestroyPixmap", (__GLXextFuncPtr
) glXDestroyPixmap
},
1112 { "glXDestroyWindow", (__GLXextFuncPtr
) glXDestroyWindow
},
1113 { "glXGetCurrentReadDrawable", (__GLXextFuncPtr
) glXGetCurrentReadDrawable
},
1114 { "glXGetFBConfigAttrib", (__GLXextFuncPtr
) glXGetFBConfigAttrib
},
1115 { "glXGetFBConfigs", (__GLXextFuncPtr
) glXGetFBConfigs
},
1116 { "glXGetSelectedEvent", (__GLXextFuncPtr
) glXGetSelectedEvent
},
1117 { "glXGetVisualFromFBConfig", (__GLXextFuncPtr
) glXGetVisualFromFBConfig
},
1118 { "glXMakeContextCurrent", (__GLXextFuncPtr
) glXMakeContextCurrent
},
1119 { "glXQueryContext", (__GLXextFuncPtr
) glXQueryContext
},
1120 { "glXQueryDrawable", (__GLXextFuncPtr
) glXQueryDrawable
},
1121 { "glXSelectEvent", (__GLXextFuncPtr
) glXSelectEvent
},
1123 /*** GLX_VERSION_1_4 ***/
1124 { "glXGetProcAddress", (__GLXextFuncPtr
) glXGetProcAddress
},
1126 /*** GLX_SGI_swap_control ***/
1127 { "glXSwapIntervalSGI", (__GLXextFuncPtr
) glXSwapIntervalSGI
},
1129 /*** GLX_SGI_video_sync ***/
1130 { "glXGetVideoSyncSGI", (__GLXextFuncPtr
) glXGetVideoSyncSGI
},
1131 { "glXWaitVideoSyncSGI", (__GLXextFuncPtr
) glXWaitVideoSyncSGI
},
1133 /*** GLX_SGI_make_current_read ***/
1134 { "glXMakeCurrentReadSGI", (__GLXextFuncPtr
) glXMakeCurrentReadSGI
},
1135 { "glXGetCurrentReadDrawableSGI", (__GLXextFuncPtr
) glXGetCurrentReadDrawableSGI
},
1137 /*** GLX_SGIX_video_source ***/
1139 { "glXCreateGLXVideoSourceSGIX", (__GLXextFuncPtr
) glXCreateGLXVideoSourceSGIX
},
1140 { "glXDestroyGLXVideoSourceSGIX", (__GLXextFuncPtr
) glXDestroyGLXVideoSourceSGIX
},
1143 /*** GLX_EXT_import_context ***/
1144 { "glXFreeContextEXT", (__GLXextFuncPtr
) glXFreeContextEXT
},
1145 { "glXGetContextIDEXT", (__GLXextFuncPtr
) glXGetContextIDEXT
},
1146 { "glXGetCurrentDisplayEXT", (__GLXextFuncPtr
) glXGetCurrentDisplayEXT
},
1147 { "glXImportContextEXT", (__GLXextFuncPtr
) glXImportContextEXT
},
1148 { "glXQueryContextInfoEXT", (__GLXextFuncPtr
) glXQueryContextInfoEXT
},
1150 /*** GLX_SGIX_fbconfig ***/
1151 { "glXGetFBConfigAttribSGIX", (__GLXextFuncPtr
) glXGetFBConfigAttribSGIX
},
1152 { "glXChooseFBConfigSGIX", (__GLXextFuncPtr
) glXChooseFBConfigSGIX
},
1153 { "glXCreateGLXPixmapWithConfigSGIX", (__GLXextFuncPtr
) glXCreateGLXPixmapWithConfigSGIX
},
1154 { "glXCreateContextWithConfigSGIX", (__GLXextFuncPtr
) glXCreateContextWithConfigSGIX
},
1155 { "glXGetVisualFromFBConfigSGIX", (__GLXextFuncPtr
) glXGetVisualFromFBConfigSGIX
},
1156 { "glXGetFBConfigFromVisualSGIX", (__GLXextFuncPtr
) glXGetFBConfigFromVisualSGIX
},
1158 /*** GLX_SGIX_pbuffer ***/
1159 { "glXCreateGLXPbufferSGIX", (__GLXextFuncPtr
) glXCreateGLXPbufferSGIX
},
1160 { "glXDestroyGLXPbufferSGIX", (__GLXextFuncPtr
) glXDestroyGLXPbufferSGIX
},
1161 { "glXQueryGLXPbufferSGIX", (__GLXextFuncPtr
) glXQueryGLXPbufferSGIX
},
1162 { "glXSelectEventSGIX", (__GLXextFuncPtr
) glXSelectEventSGIX
},
1163 { "glXGetSelectedEventSGIX", (__GLXextFuncPtr
) glXGetSelectedEventSGIX
},
1165 /*** GLX_SGI_cushion ***/
1166 { "glXCushionSGI", (__GLXextFuncPtr
) glXCushionSGI
},
1168 /*** GLX_SGIX_video_resize ***/
1169 { "glXBindChannelToWindowSGIX", (__GLXextFuncPtr
) glXBindChannelToWindowSGIX
},
1170 { "glXChannelRectSGIX", (__GLXextFuncPtr
) glXChannelRectSGIX
},
1171 { "glXQueryChannelRectSGIX", (__GLXextFuncPtr
) glXQueryChannelRectSGIX
},
1172 { "glXQueryChannelDeltasSGIX", (__GLXextFuncPtr
) glXQueryChannelDeltasSGIX
},
1173 { "glXChannelRectSyncSGIX", (__GLXextFuncPtr
) glXChannelRectSyncSGIX
},
1175 /*** GLX_SGIX_dmbuffer **/
1176 #if defined(_DM_BUFFER_H_)
1177 { "glXAssociateDMPbufferSGIX", (__GLXextFuncPtr
) glXAssociateDMPbufferSGIX
},
1180 /*** GLX_SGIX_swap_group ***/
1181 { "glXJoinSwapGroupSGIX", (__GLXextFuncPtr
) glXJoinSwapGroupSGIX
},
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 /*** GLX_ARB_create_context ***/
1203 { "glXCreateContextAttribsARB", (__GLXextFuncPtr
) glXCreateContextAttribsARB
},
1205 { NULL
, NULL
} /* end of list */
1211 * Return address of named glX function, or NULL if not found.
1214 _glxapi_get_proc_address(const char *funcName
)
1217 for (i
= 0; GLX_functions
[i
].Name
; i
++) {
1219 /* skip the "m" prefix on the name */
1220 if (strcmp(GLX_functions
[i
].Name
, funcName
+1) == 0)
1222 if (strcmp(GLX_functions
[i
].Name
, funcName
) == 0)
1224 return GLX_functions
[i
].Address
;
1232 * This function does not get dispatched through the dispatch table
1233 * since it's really a "meta" function.
1235 __GLXextFuncPtr PUBLIC
1236 glXGetProcAddressARB(const GLubyte
*procName
)
1240 f
= _glxapi_get_proc_address((const char *) procName
);
1245 f
= (__GLXextFuncPtr
) _glapi_get_proc_address((const char *) procName
);
1252 (*glXGetProcAddress(const GLubyte
*procName
))()
1254 return glXGetProcAddressARB(procName
);
1259 * Added in GLX_ARB_create_context.
1262 glXCreateContextAttribsARB(Display
*dpy
, GLXFBConfig config
,
1263 GLXContext share_context
, Bool direct
,
1264 const int *attrib_list
)
1266 struct _glxapi_table
*t
;
1267 GET_DISPATCH(dpy
, t
);
1270 return t
->CreateContextAttribs(dpy
, config
, share_context
, direct
,