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 #define NAME(func) gl##func
64 #define DISPATCH(FUNC, ARGS, MESSAGE) \
65 GET_DISPATCH()->FUNC ARGS
67 #define RETURN_DISPATCH(FUNC, ARGS, MESSAGE) \
68 return GET_DISPATCH()->FUNC ARGS
70 /* skip normal ones */
71 #define _GLAPI_SKIP_NORMAL_ENTRY_POINTS
72 #include "glapitemp.h"
74 #endif /* GLX_INDIRECT_RENDERING */
77 static struct display_dispatch
*DispatchList
= NULL
;
80 /* Display -> Dispatch caching */
81 static Display
*prevDisplay
= NULL
;
82 static struct _glxapi_table
*prevTable
= NULL
;
85 static struct _glxapi_table
*
86 get_dispatch(Display
*dpy
)
91 /* search list of display/dispatch pairs for this display */
93 const struct display_dispatch
*d
= DispatchList
;
98 return d
->Table
; /* done! */
104 /* Setup the dispatch table */
106 struct _glxapi_table
*t
= _mesa_GetGLXDispatchTable();
109 struct display_dispatch
*d
;
110 d
= malloc(sizeof(struct display_dispatch
));
114 /* insert at head of list */
115 d
->Next
= DispatchList
;
129 /* Don't use the GET_DISPATCH macro */
132 #define GET_DISPATCH(DPY, TABLE) \
133 if (DPY == prevDisplay) { \
140 TABLE = get_dispatch(DPY); \
145 * GLX API entrypoints
148 /*** GLX_VERSION_1_0 ***/
151 glXChooseVisual(Display
*dpy
, int screen
, int *list
)
153 struct _glxapi_table
*t
;
154 GET_DISPATCH(dpy
, t
);
157 return t
->ChooseVisual(dpy
, screen
, list
);
162 glXCopyContext(Display
*dpy
, GLXContext src
, GLXContext dst
, unsigned long mask
)
164 struct _glxapi_table
*t
;
165 GET_DISPATCH(dpy
, t
);
168 t
->CopyContext(dpy
, src
, dst
, mask
);
173 glXCreateContext(Display
*dpy
, XVisualInfo
*visinfo
, GLXContext shareList
, Bool direct
)
175 struct _glxapi_table
*t
;
176 GET_DISPATCH(dpy
, t
);
179 return t
->CreateContext(dpy
, visinfo
, shareList
, direct
);
184 glXCreateGLXPixmap(Display
*dpy
, XVisualInfo
*visinfo
, Pixmap pixmap
)
186 struct _glxapi_table
*t
;
187 GET_DISPATCH(dpy
, t
);
190 return t
->CreateGLXPixmap(dpy
, visinfo
, pixmap
);
195 glXDestroyContext(Display
*dpy
, GLXContext ctx
)
197 struct _glxapi_table
*t
;
198 GET_DISPATCH(dpy
, t
);
201 t
->DestroyContext(dpy
, ctx
);
206 glXDestroyGLXPixmap(Display
*dpy
, GLXPixmap pixmap
)
208 struct _glxapi_table
*t
;
209 GET_DISPATCH(dpy
, t
);
212 t
->DestroyGLXPixmap(dpy
, pixmap
);
217 glXGetConfig(Display
*dpy
, XVisualInfo
*visinfo
, int attrib
, int *value
)
219 struct _glxapi_table
*t
;
220 GET_DISPATCH(dpy
, t
);
222 return GLX_NO_EXTENSION
;
223 return t
->GetConfig(dpy
, visinfo
, attrib
, value
);
227 /* declare here to avoid including xmesa.h */
228 extern void *XMesaGetCurrentContext(void);
231 glXGetCurrentContext(void)
233 return (GLXContext
) XMesaGetCurrentContext();
238 glXGetCurrentDrawable(void)
240 __GLXcontext
*gc
= (__GLXcontext
*) glXGetCurrentContext();
241 return gc
? gc
->currentDrawable
: 0;
246 glXIsDirect(Display
*dpy
, GLXContext ctx
)
248 struct _glxapi_table
*t
;
249 GET_DISPATCH(dpy
, t
);
252 return t
->IsDirect(dpy
, ctx
);
257 glXMakeCurrent(Display
*dpy
, GLXDrawable drawable
, GLXContext ctx
)
260 struct _glxapi_table
*t
;
261 GET_DISPATCH(dpy
, t
);
265 b
= t
->MakeCurrent(dpy
, drawable
, ctx
);
271 glXQueryExtension(Display
*dpy
, int *errorb
, int *event
)
273 struct _glxapi_table
*t
;
274 GET_DISPATCH(dpy
, t
);
277 return t
->QueryExtension(dpy
, errorb
, event
);
282 glXQueryVersion(Display
*dpy
, int *maj
, int *min
)
284 struct _glxapi_table
*t
;
285 GET_DISPATCH(dpy
, t
);
288 return t
->QueryVersion(dpy
, maj
, min
);
293 glXSwapBuffers(Display
*dpy
, GLXDrawable drawable
)
295 struct _glxapi_table
*t
;
296 GET_DISPATCH(dpy
, t
);
299 t
->SwapBuffers(dpy
, drawable
);
304 glXUseXFont(Font font
, int first
, int count
, int listBase
)
306 struct _glxapi_table
*t
;
307 Display
*dpy
= glXGetCurrentDisplay();
308 GET_DISPATCH(dpy
, t
);
311 t
->UseXFont(font
, first
, count
, listBase
);
318 struct _glxapi_table
*t
;
319 Display
*dpy
= glXGetCurrentDisplay();
320 GET_DISPATCH(dpy
, t
);
330 struct _glxapi_table
*t
;
331 Display
*dpy
= glXGetCurrentDisplay();
332 GET_DISPATCH(dpy
, t
);
340 /*** GLX_VERSION_1_1 ***/
343 glXGetClientString(Display
*dpy
, int name
)
345 struct _glxapi_table
*t
;
346 GET_DISPATCH(dpy
, t
);
349 return t
->GetClientString(dpy
, name
);
354 glXQueryExtensionsString(Display
*dpy
, int screen
)
356 struct _glxapi_table
*t
;
357 GET_DISPATCH(dpy
, t
);
360 return t
->QueryExtensionsString(dpy
, screen
);
365 glXQueryServerString(Display
*dpy
, int screen
, int name
)
367 struct _glxapi_table
*t
;
368 GET_DISPATCH(dpy
, t
);
371 return t
->QueryServerString(dpy
, screen
, name
);
375 /*** GLX_VERSION_1_2 ***/
377 /* declare here to avoid including xmesa.h */
378 extern Display
*XMesaGetCurrentDisplay(void);
381 glXGetCurrentDisplay(void)
383 return XMesaGetCurrentDisplay();
388 /*** GLX_VERSION_1_3 ***/
391 glXChooseFBConfig(Display
*dpy
, int screen
, const int *attribList
, int *nitems
)
393 struct _glxapi_table
*t
;
394 GET_DISPATCH(dpy
, t
);
397 return t
->ChooseFBConfig(dpy
, screen
, attribList
, nitems
);
402 glXCreateNewContext(Display
*dpy
, GLXFBConfig config
, int renderType
, GLXContext shareList
, Bool direct
)
404 struct _glxapi_table
*t
;
405 GET_DISPATCH(dpy
, t
);
408 return t
->CreateNewContext(dpy
, config
, renderType
, shareList
, direct
);
413 glXCreatePbuffer(Display
*dpy
, GLXFBConfig config
, const int *attribList
)
415 struct _glxapi_table
*t
;
416 GET_DISPATCH(dpy
, t
);
419 return t
->CreatePbuffer(dpy
, config
, attribList
);
424 glXCreatePixmap(Display
*dpy
, GLXFBConfig config
, Pixmap pixmap
, const int *attribList
)
426 struct _glxapi_table
*t
;
427 GET_DISPATCH(dpy
, t
);
430 return t
->CreatePixmap(dpy
, config
, pixmap
, attribList
);
435 glXCreateWindow(Display
*dpy
, GLXFBConfig config
, Window win
, const int *attribList
)
437 struct _glxapi_table
*t
;
438 GET_DISPATCH(dpy
, t
);
441 return t
->CreateWindow(dpy
, config
, win
, attribList
);
446 glXDestroyPbuffer(Display
*dpy
, GLXPbuffer pbuf
)
448 struct _glxapi_table
*t
;
449 GET_DISPATCH(dpy
, t
);
452 t
->DestroyPbuffer(dpy
, pbuf
);
457 glXDestroyPixmap(Display
*dpy
, GLXPixmap pixmap
)
459 struct _glxapi_table
*t
;
460 GET_DISPATCH(dpy
, t
);
463 t
->DestroyPixmap(dpy
, pixmap
);
468 glXDestroyWindow(Display
*dpy
, GLXWindow window
)
470 struct _glxapi_table
*t
;
471 GET_DISPATCH(dpy
, t
);
474 t
->DestroyWindow(dpy
, window
);
479 glXGetCurrentReadDrawable(void)
481 __GLXcontext
*gc
= (__GLXcontext
*) glXGetCurrentContext();
482 return gc
? gc
->currentReadable
: 0;
487 glXGetFBConfigAttrib(Display
*dpy
, GLXFBConfig config
, int attribute
, int *value
)
489 struct _glxapi_table
*t
;
490 GET_DISPATCH(dpy
, t
);
492 return GLX_NO_EXTENSION
;
493 return t
->GetFBConfigAttrib(dpy
, config
, attribute
, value
);
498 glXGetFBConfigs(Display
*dpy
, int screen
, int *nelements
)
500 struct _glxapi_table
*t
;
501 GET_DISPATCH(dpy
, t
);
504 return t
->GetFBConfigs(dpy
, screen
, nelements
);
508 glXGetSelectedEvent(Display
*dpy
, GLXDrawable drawable
, unsigned long *mask
)
510 struct _glxapi_table
*t
;
511 GET_DISPATCH(dpy
, t
);
514 t
->GetSelectedEvent(dpy
, drawable
, mask
);
519 glXGetVisualFromFBConfig(Display
*dpy
, GLXFBConfig config
)
521 struct _glxapi_table
*t
;
522 GET_DISPATCH(dpy
, t
);
525 return t
->GetVisualFromFBConfig(dpy
, config
);
530 glXMakeContextCurrent(Display
*dpy
, GLXDrawable draw
, GLXDrawable read
, GLXContext ctx
)
533 struct _glxapi_table
*t
;
534 GET_DISPATCH(dpy
, t
);
537 b
= t
->MakeContextCurrent(dpy
, draw
, read
, ctx
);
543 glXQueryContext(Display
*dpy
, GLXContext ctx
, int attribute
, int *value
)
545 struct _glxapi_table
*t
;
546 GET_DISPATCH(dpy
, t
);
549 return 0; /* XXX correct? */
550 return t
->QueryContext(dpy
, ctx
, attribute
, value
);
555 glXQueryDrawable(Display
*dpy
, GLXDrawable draw
, int attribute
, unsigned int *value
)
557 struct _glxapi_table
*t
;
558 GET_DISPATCH(dpy
, t
);
561 t
->QueryDrawable(dpy
, draw
, attribute
, value
);
566 glXSelectEvent(Display
*dpy
, GLXDrawable drawable
, unsigned long mask
)
568 struct _glxapi_table
*t
;
569 GET_DISPATCH(dpy
, t
);
572 t
->SelectEvent(dpy
, drawable
, mask
);
577 /*** GLX_SGI_swap_control ***/
580 glXSwapIntervalSGI(int interval
)
582 struct _glxapi_table
*t
;
583 Display
*dpy
= glXGetCurrentDisplay();
584 GET_DISPATCH(dpy
, t
);
587 return t
->SwapIntervalSGI(interval
);
592 /*** GLX_SGI_video_sync ***/
595 glXGetVideoSyncSGI(unsigned int *count
)
597 struct _glxapi_table
*t
;
598 Display
*dpy
= glXGetCurrentDisplay();
599 GET_DISPATCH(dpy
, t
);
600 if (!t
|| !glXGetCurrentContext())
601 return GLX_BAD_CONTEXT
;
602 return t
->GetVideoSyncSGI(count
);
606 glXWaitVideoSyncSGI(int divisor
, int remainder
, unsigned int *count
)
608 struct _glxapi_table
*t
;
609 Display
*dpy
= glXGetCurrentDisplay();
610 GET_DISPATCH(dpy
, t
);
611 if (!t
|| !glXGetCurrentContext())
612 return GLX_BAD_CONTEXT
;
613 return t
->WaitVideoSyncSGI(divisor
, remainder
, count
);
618 /*** GLX_SGI_make_current_read ***/
621 glXMakeCurrentReadSGI(Display
*dpy
, GLXDrawable draw
, GLXDrawable read
, GLXContext ctx
)
623 struct _glxapi_table
*t
;
624 GET_DISPATCH(dpy
, t
);
627 return t
->MakeCurrentReadSGI(dpy
, draw
, read
, ctx
);
631 glXGetCurrentReadDrawableSGI(void)
633 return glXGetCurrentReadDrawable();
639 GLXVideoSourceSGIX PUBLIC
640 glXCreateGLXVideoSourceSGIX(Display
*dpy
, int screen
, VLServer server
, VLPath path
, int nodeClass
, VLNode drainNode
)
642 struct _glxapi_table
*t
;
643 GET_DISPATCH(dpy
, t
);
646 return t
->CreateGLXVideoSourceSGIX(dpy
, screen
, server
, path
, nodeClass
, drainNode
);
650 glXDestroyGLXVideoSourceSGIX(Display
*dpy
, GLXVideoSourceSGIX src
)
652 struct _glxapi_table
*t
;
653 GET_DISPATCH(dpy
, t
);
656 return t
->DestroyGLXVideoSourceSGIX(dpy
, src
);
662 /*** GLX_EXT_import_context ***/
665 glXFreeContextEXT(Display
*dpy
, GLXContext context
)
667 struct _glxapi_table
*t
;
668 GET_DISPATCH(dpy
, t
);
671 t
->FreeContextEXT(dpy
, context
);
675 glXGetContextIDEXT(const GLXContext context
)
677 return ((__GLXcontext
*) context
)->xid
;
681 glXGetCurrentDisplayEXT(void)
683 return glXGetCurrentDisplay();
687 glXImportContextEXT(Display
*dpy
, GLXContextID contextID
)
689 struct _glxapi_table
*t
;
690 GET_DISPATCH(dpy
, t
);
693 return t
->ImportContextEXT(dpy
, contextID
);
697 glXQueryContextInfoEXT(Display
*dpy
, GLXContext context
, int attribute
,int *value
)
699 struct _glxapi_table
*t
;
700 GET_DISPATCH(dpy
, t
);
702 return 0; /* XXX ok? */
703 return t
->QueryContextInfoEXT(dpy
, context
, attribute
, value
);
708 /*** GLX_SGIX_fbconfig ***/
711 glXGetFBConfigAttribSGIX(Display
*dpy
, GLXFBConfigSGIX config
, int attribute
, int *value
)
713 struct _glxapi_table
*t
;
714 GET_DISPATCH(dpy
, t
);
717 return t
->GetFBConfigAttribSGIX(dpy
, config
, attribute
, value
);
720 GLXFBConfigSGIX PUBLIC
*
721 glXChooseFBConfigSGIX(Display
*dpy
, int screen
, int *attrib_list
, int *nelements
)
723 struct _glxapi_table
*t
;
724 GET_DISPATCH(dpy
, t
);
727 return t
->ChooseFBConfigSGIX(dpy
, screen
, attrib_list
, nelements
);
731 glXCreateGLXPixmapWithConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
, Pixmap pixmap
)
733 struct _glxapi_table
*t
;
734 GET_DISPATCH(dpy
, t
);
737 return t
->CreateGLXPixmapWithConfigSGIX(dpy
, config
, pixmap
);
741 glXCreateContextWithConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
, int render_type
, GLXContext share_list
, Bool direct
)
743 struct _glxapi_table
*t
;
744 GET_DISPATCH(dpy
, t
);
747 return t
->CreateContextWithConfigSGIX(dpy
, config
, render_type
, share_list
, direct
);
751 glXGetVisualFromFBConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
)
753 struct _glxapi_table
*t
;
754 GET_DISPATCH(dpy
, t
);
757 return t
->GetVisualFromFBConfigSGIX(dpy
, config
);
760 GLXFBConfigSGIX PUBLIC
761 glXGetFBConfigFromVisualSGIX(Display
*dpy
, XVisualInfo
*vis
)
763 struct _glxapi_table
*t
;
764 GET_DISPATCH(dpy
, t
);
767 return t
->GetFBConfigFromVisualSGIX(dpy
, vis
);
772 /*** GLX_SGIX_pbuffer ***/
774 GLXPbufferSGIX PUBLIC
775 glXCreateGLXPbufferSGIX(Display
*dpy
, GLXFBConfigSGIX config
, unsigned int width
, unsigned int height
, int *attrib_list
)
777 struct _glxapi_table
*t
;
778 GET_DISPATCH(dpy
, t
);
781 return t
->CreateGLXPbufferSGIX(dpy
, config
, width
, height
, attrib_list
);
785 glXDestroyGLXPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuf
)
787 struct _glxapi_table
*t
;
788 GET_DISPATCH(dpy
, t
);
791 t
->DestroyGLXPbufferSGIX(dpy
, pbuf
);
795 glXQueryGLXPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuf
, int attribute
, unsigned int *value
)
797 struct _glxapi_table
*t
;
798 GET_DISPATCH(dpy
, t
);
801 t
->QueryGLXPbufferSGIX(dpy
, pbuf
, attribute
, value
);
805 glXSelectEventSGIX(Display
*dpy
, GLXDrawable drawable
, unsigned long mask
)
807 struct _glxapi_table
*t
;
808 GET_DISPATCH(dpy
, t
);
811 t
->SelectEventSGIX(dpy
, drawable
, mask
);
815 glXGetSelectedEventSGIX(Display
*dpy
, GLXDrawable drawable
, unsigned long *mask
)
817 struct _glxapi_table
*t
;
818 GET_DISPATCH(dpy
, t
);
821 t
->GetSelectedEventSGIX(dpy
, drawable
, mask
);
826 /*** GLX_SGI_cushion ***/
829 glXCushionSGI(Display
*dpy
, Window win
, float cushion
)
831 struct _glxapi_table
*t
;
832 GET_DISPATCH(dpy
, t
);
835 t
->CushionSGI(dpy
, win
, cushion
);
840 /*** GLX_SGIX_video_resize ***/
843 glXBindChannelToWindowSGIX(Display
*dpy
, int screen
, int channel
, Window window
)
845 struct _glxapi_table
*t
;
846 GET_DISPATCH(dpy
, t
);
849 return t
->BindChannelToWindowSGIX(dpy
, screen
, channel
, window
);
853 glXChannelRectSGIX(Display
*dpy
, int screen
, int channel
, int x
, int y
, int w
, int h
)
855 struct _glxapi_table
*t
;
856 GET_DISPATCH(dpy
, t
);
859 return t
->ChannelRectSGIX(dpy
, screen
, channel
, x
, y
, w
, h
);
863 glXQueryChannelRectSGIX(Display
*dpy
, int screen
, int channel
, int *x
, int *y
, int *w
, int *h
)
865 struct _glxapi_table
*t
;
866 GET_DISPATCH(dpy
, t
);
869 return t
->QueryChannelRectSGIX(dpy
, screen
, channel
, x
, y
, w
, h
);
873 glXQueryChannelDeltasSGIX(Display
*dpy
, int screen
, int channel
, int *dx
, int *dy
, int *dw
, int *dh
)
875 struct _glxapi_table
*t
;
876 GET_DISPATCH(dpy
, t
);
879 return t
->QueryChannelDeltasSGIX(dpy
, screen
, channel
, dx
, dy
, dw
, dh
);
883 glXChannelRectSyncSGIX(Display
*dpy
, int screen
, int channel
, GLenum synctype
)
885 struct _glxapi_table
*t
;
886 GET_DISPATCH(dpy
, t
);
889 return t
->ChannelRectSyncSGIX(dpy
, screen
, channel
, synctype
);
894 #if defined(_DM_BUFFER_H_)
897 glXAssociateDMPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuffer
, DMparams
*params
, DMbuffer dmbuffer
)
899 struct _glxapi_table
*t
;
900 GET_DISPATCH(dpy
, t
);
903 return t
->AssociateDMPbufferSGIX(dpy
, pbuffer
, params
, dmbuffer
);
909 /*** GLX_SUN_get_transparent_index ***/
912 glXGetTransparentIndexSUN(Display
*dpy
, Window overlay
, Window underlay
, unsigned long *pTransparent
)
914 struct _glxapi_table
*t
;
915 GET_DISPATCH(dpy
, t
);
918 return t
->GetTransparentIndexSUN(dpy
, overlay
, underlay
, pTransparent
);
923 /*** GLX_MESA_copy_sub_buffer ***/
926 glXCopySubBufferMESA(Display
*dpy
, GLXDrawable drawable
, int x
, int y
, int width
, int height
)
928 struct _glxapi_table
*t
;
929 GET_DISPATCH(dpy
, t
);
932 t
->CopySubBufferMESA(dpy
, drawable
, x
, y
, width
, height
);
937 /*** GLX_MESA_release_buffers ***/
940 glXReleaseBuffersMESA(Display
*dpy
, Window w
)
942 struct _glxapi_table
*t
;
943 GET_DISPATCH(dpy
, t
);
946 return t
->ReleaseBuffersMESA(dpy
, w
);
951 /*** GLX_MESA_pixmap_colormap ***/
954 glXCreateGLXPixmapMESA(Display
*dpy
, XVisualInfo
*visinfo
, Pixmap pixmap
, Colormap cmap
)
956 struct _glxapi_table
*t
;
957 GET_DISPATCH(dpy
, t
);
960 return t
->CreateGLXPixmapMESA(dpy
, visinfo
, pixmap
, cmap
);
965 /*** GLX_EXT_texture_from_pixmap */
968 glXBindTexImageEXT(Display
*dpy
, GLXDrawable drawable
, int buffer
,
969 const int *attrib_list
)
971 struct _glxapi_table
*t
;
972 GET_DISPATCH(dpy
, t
);
974 t
->BindTexImageEXT(dpy
, drawable
, buffer
, attrib_list
);
978 glXReleaseTexImageEXT(Display
*dpy
, GLXDrawable drawable
, int buffer
)
980 struct _glxapi_table
*t
;
981 GET_DISPATCH(dpy
, t
);
983 t
->ReleaseTexImageEXT(dpy
, drawable
, buffer
);
987 /**********************************************************************/
988 /* GLX API management functions */
989 /**********************************************************************/
993 _glxapi_get_version(void)
1000 * Return array of extension strings.
1003 _glxapi_get_extensions(void)
1005 static const char *extensions
[] = {
1006 "GLX_EXT_import_context",
1007 "GLX_SGI_video_sync",
1008 "GLX_MESA_copy_sub_buffer",
1009 "GLX_MESA_release_buffers",
1010 "GLX_MESA_pixmap_colormap",
1011 "GLX_SGIX_fbconfig",
1013 "GLX_EXT_texture_from_pixmap",
1014 "GLX_INTEL_swap_event",
1022 * Return size of the GLX dispatch table, in entries, not bytes.
1025 _glxapi_get_dispatch_table_size(void)
1027 return sizeof(struct _glxapi_table
) / sizeof(void *);
1032 generic_no_op_func(void)
1039 * Initialize all functions in given dispatch table to be no-ops
1042 _glxapi_set_no_op_table(struct _glxapi_table
*t
)
1044 typedef int (*nop_func
)(void);
1045 nop_func
*dispatch
= (nop_func
*) t
;
1046 GLuint n
= _glxapi_get_dispatch_table_size();
1048 for (i
= 0; i
< n
; i
++) {
1049 dispatch
[i
] = generic_no_op_func
;
1054 struct name_address_pair
{
1056 __GLXextFuncPtr Address
;
1059 static struct name_address_pair GLX_functions
[] = {
1060 /*** GLX_VERSION_1_0 ***/
1061 { "glXChooseVisual", (__GLXextFuncPtr
) glXChooseVisual
},
1062 { "glXCopyContext", (__GLXextFuncPtr
) glXCopyContext
},
1063 { "glXCreateContext", (__GLXextFuncPtr
) glXCreateContext
},
1064 { "glXCreateGLXPixmap", (__GLXextFuncPtr
) glXCreateGLXPixmap
},
1065 { "glXDestroyContext", (__GLXextFuncPtr
) glXDestroyContext
},
1066 { "glXDestroyGLXPixmap", (__GLXextFuncPtr
) glXDestroyGLXPixmap
},
1067 { "glXGetConfig", (__GLXextFuncPtr
) glXGetConfig
},
1068 { "glXGetCurrentContext", (__GLXextFuncPtr
) glXGetCurrentContext
},
1069 { "glXGetCurrentDrawable", (__GLXextFuncPtr
) glXGetCurrentDrawable
},
1070 { "glXIsDirect", (__GLXextFuncPtr
) glXIsDirect
},
1071 { "glXMakeCurrent", (__GLXextFuncPtr
) glXMakeCurrent
},
1072 { "glXQueryExtension", (__GLXextFuncPtr
) glXQueryExtension
},
1073 { "glXQueryVersion", (__GLXextFuncPtr
) glXQueryVersion
},
1074 { "glXSwapBuffers", (__GLXextFuncPtr
) glXSwapBuffers
},
1075 { "glXUseXFont", (__GLXextFuncPtr
) glXUseXFont
},
1076 { "glXWaitGL", (__GLXextFuncPtr
) glXWaitGL
},
1077 { "glXWaitX", (__GLXextFuncPtr
) glXWaitX
},
1079 /*** GLX_VERSION_1_1 ***/
1080 { "glXGetClientString", (__GLXextFuncPtr
) glXGetClientString
},
1081 { "glXQueryExtensionsString", (__GLXextFuncPtr
) glXQueryExtensionsString
},
1082 { "glXQueryServerString", (__GLXextFuncPtr
) glXQueryServerString
},
1084 /*** GLX_VERSION_1_2 ***/
1085 { "glXGetCurrentDisplay", (__GLXextFuncPtr
) glXGetCurrentDisplay
},
1087 /*** GLX_VERSION_1_3 ***/
1088 { "glXChooseFBConfig", (__GLXextFuncPtr
) glXChooseFBConfig
},
1089 { "glXCreateNewContext", (__GLXextFuncPtr
) glXCreateNewContext
},
1090 { "glXCreatePbuffer", (__GLXextFuncPtr
) glXCreatePbuffer
},
1091 { "glXCreatePixmap", (__GLXextFuncPtr
) glXCreatePixmap
},
1092 { "glXCreateWindow", (__GLXextFuncPtr
) glXCreateWindow
},
1093 { "glXDestroyPbuffer", (__GLXextFuncPtr
) glXDestroyPbuffer
},
1094 { "glXDestroyPixmap", (__GLXextFuncPtr
) glXDestroyPixmap
},
1095 { "glXDestroyWindow", (__GLXextFuncPtr
) glXDestroyWindow
},
1096 { "glXGetCurrentReadDrawable", (__GLXextFuncPtr
) glXGetCurrentReadDrawable
},
1097 { "glXGetFBConfigAttrib", (__GLXextFuncPtr
) glXGetFBConfigAttrib
},
1098 { "glXGetFBConfigs", (__GLXextFuncPtr
) glXGetFBConfigs
},
1099 { "glXGetSelectedEvent", (__GLXextFuncPtr
) glXGetSelectedEvent
},
1100 { "glXGetVisualFromFBConfig", (__GLXextFuncPtr
) glXGetVisualFromFBConfig
},
1101 { "glXMakeContextCurrent", (__GLXextFuncPtr
) glXMakeContextCurrent
},
1102 { "glXQueryContext", (__GLXextFuncPtr
) glXQueryContext
},
1103 { "glXQueryDrawable", (__GLXextFuncPtr
) glXQueryDrawable
},
1104 { "glXSelectEvent", (__GLXextFuncPtr
) glXSelectEvent
},
1106 /*** GLX_VERSION_1_4 ***/
1107 { "glXGetProcAddress", (__GLXextFuncPtr
) glXGetProcAddress
},
1109 /*** GLX_SGI_swap_control ***/
1110 { "glXSwapIntervalSGI", (__GLXextFuncPtr
) glXSwapIntervalSGI
},
1112 /*** GLX_SGI_video_sync ***/
1113 { "glXGetVideoSyncSGI", (__GLXextFuncPtr
) glXGetVideoSyncSGI
},
1114 { "glXWaitVideoSyncSGI", (__GLXextFuncPtr
) glXWaitVideoSyncSGI
},
1116 /*** GLX_SGI_make_current_read ***/
1117 { "glXMakeCurrentReadSGI", (__GLXextFuncPtr
) glXMakeCurrentReadSGI
},
1118 { "glXGetCurrentReadDrawableSGI", (__GLXextFuncPtr
) glXGetCurrentReadDrawableSGI
},
1120 /*** GLX_SGIX_video_source ***/
1122 { "glXCreateGLXVideoSourceSGIX", (__GLXextFuncPtr
) glXCreateGLXVideoSourceSGIX
},
1123 { "glXDestroyGLXVideoSourceSGIX", (__GLXextFuncPtr
) glXDestroyGLXVideoSourceSGIX
},
1126 /*** GLX_EXT_import_context ***/
1127 { "glXFreeContextEXT", (__GLXextFuncPtr
) glXFreeContextEXT
},
1128 { "glXGetContextIDEXT", (__GLXextFuncPtr
) glXGetContextIDEXT
},
1129 { "glXGetCurrentDisplayEXT", (__GLXextFuncPtr
) glXGetCurrentDisplayEXT
},
1130 { "glXImportContextEXT", (__GLXextFuncPtr
) glXImportContextEXT
},
1131 { "glXQueryContextInfoEXT", (__GLXextFuncPtr
) glXQueryContextInfoEXT
},
1133 /*** GLX_SGIX_fbconfig ***/
1134 { "glXGetFBConfigAttribSGIX", (__GLXextFuncPtr
) glXGetFBConfigAttribSGIX
},
1135 { "glXChooseFBConfigSGIX", (__GLXextFuncPtr
) glXChooseFBConfigSGIX
},
1136 { "glXCreateGLXPixmapWithConfigSGIX", (__GLXextFuncPtr
) glXCreateGLXPixmapWithConfigSGIX
},
1137 { "glXCreateContextWithConfigSGIX", (__GLXextFuncPtr
) glXCreateContextWithConfigSGIX
},
1138 { "glXGetVisualFromFBConfigSGIX", (__GLXextFuncPtr
) glXGetVisualFromFBConfigSGIX
},
1139 { "glXGetFBConfigFromVisualSGIX", (__GLXextFuncPtr
) glXGetFBConfigFromVisualSGIX
},
1141 /*** GLX_SGIX_pbuffer ***/
1142 { "glXCreateGLXPbufferSGIX", (__GLXextFuncPtr
) glXCreateGLXPbufferSGIX
},
1143 { "glXDestroyGLXPbufferSGIX", (__GLXextFuncPtr
) glXDestroyGLXPbufferSGIX
},
1144 { "glXQueryGLXPbufferSGIX", (__GLXextFuncPtr
) glXQueryGLXPbufferSGIX
},
1145 { "glXSelectEventSGIX", (__GLXextFuncPtr
) glXSelectEventSGIX
},
1146 { "glXGetSelectedEventSGIX", (__GLXextFuncPtr
) glXGetSelectedEventSGIX
},
1148 /*** GLX_SGI_cushion ***/
1149 { "glXCushionSGI", (__GLXextFuncPtr
) glXCushionSGI
},
1151 /*** GLX_SGIX_video_resize ***/
1152 { "glXBindChannelToWindowSGIX", (__GLXextFuncPtr
) glXBindChannelToWindowSGIX
},
1153 { "glXChannelRectSGIX", (__GLXextFuncPtr
) glXChannelRectSGIX
},
1154 { "glXQueryChannelRectSGIX", (__GLXextFuncPtr
) glXQueryChannelRectSGIX
},
1155 { "glXQueryChannelDeltasSGIX", (__GLXextFuncPtr
) glXQueryChannelDeltasSGIX
},
1156 { "glXChannelRectSyncSGIX", (__GLXextFuncPtr
) glXChannelRectSyncSGIX
},
1158 /*** GLX_SGIX_dmbuffer **/
1159 #if defined(_DM_BUFFER_H_)
1160 { "glXAssociateDMPbufferSGIX", (__GLXextFuncPtr
) glXAssociateDMPbufferSGIX
},
1163 /*** GLX_SUN_get_transparent_index ***/
1164 { "glXGetTransparentIndexSUN", (__GLXextFuncPtr
) glXGetTransparentIndexSUN
},
1166 /*** GLX_MESA_copy_sub_buffer ***/
1167 { "glXCopySubBufferMESA", (__GLXextFuncPtr
) glXCopySubBufferMESA
},
1169 /*** GLX_MESA_pixmap_colormap ***/
1170 { "glXCreateGLXPixmapMESA", (__GLXextFuncPtr
) glXCreateGLXPixmapMESA
},
1172 /*** GLX_MESA_release_buffers ***/
1173 { "glXReleaseBuffersMESA", (__GLXextFuncPtr
) glXReleaseBuffersMESA
},
1175 /*** GLX_ARB_get_proc_address ***/
1176 { "glXGetProcAddressARB", (__GLXextFuncPtr
) glXGetProcAddressARB
},
1178 /*** GLX_EXT_texture_from_pixmap ***/
1179 { "glXBindTexImageEXT", (__GLXextFuncPtr
) glXBindTexImageEXT
},
1180 { "glXReleaseTexImageEXT", (__GLXextFuncPtr
) glXReleaseTexImageEXT
},
1182 /*** GLX_ARB_create_context ***/
1183 { "glXCreateContextAttribsARB", (__GLXextFuncPtr
) glXCreateContextAttribsARB
},
1185 { NULL
, NULL
} /* end of list */
1191 * Return address of named glX function, or NULL if not found.
1194 _glxapi_get_proc_address(const char *funcName
)
1197 for (i
= 0; GLX_functions
[i
].Name
; i
++) {
1199 /* skip the "m" prefix on the name */
1200 if (strcmp(GLX_functions
[i
].Name
, funcName
+1) == 0)
1202 if (strcmp(GLX_functions
[i
].Name
, funcName
) == 0)
1204 return GLX_functions
[i
].Address
;
1212 * This function does not get dispatched through the dispatch table
1213 * since it's really a "meta" function.
1215 __GLXextFuncPtr PUBLIC
1216 glXGetProcAddressARB(const GLubyte
*procName
)
1220 f
= _glxapi_get_proc_address((const char *) procName
);
1225 f
= (__GLXextFuncPtr
) _glapi_get_proc_address((const char *) procName
);
1232 (*glXGetProcAddress(const GLubyte
*procName
))()
1234 return glXGetProcAddressARB(procName
);
1239 * Added in GLX_ARB_create_context.
1242 glXCreateContextAttribsARB(Display
*dpy
, GLXFBConfig config
,
1243 GLXContext share_context
, Bool direct
,
1244 const int *attrib_list
)
1246 struct _glxapi_table
*t
;
1247 GET_DISPATCH(dpy
, t
);
1250 return t
->CreateContextAttribs(dpy
, config
, share_context
, direct
,