2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 * This is the GLX API dispatcher. Calls to the glX* functions are
28 * either routed to the real GLX encoders or to Mesa's pseudo-GLX functions.
29 * See the glxapi.h file for more details.
37 #include "main/glheader.h"
38 #include "main/compiler.h"
39 #include "glapi/glapi.h"
43 extern struct _glxapi_table
*_real_GetGLXDispatchTable(void);
44 extern struct _glxapi_table
*_mesa_GetGLXDispatchTable(void);
47 struct display_dispatch
{
49 struct _glxapi_table
*Table
;
50 struct display_dispatch
*Next
;
55 * When GLX_INDIRECT_RENDERING is defined, some symbols are missing in
56 * libglapi.a. We need to define them here.
58 #ifdef GLX_INDIRECT_RENDERING
60 #include "glapi/glapitable.h"
61 #include "glapi/glapidispatch.h"
63 #define KEYWORD1 PUBLIC
65 #if defined(USE_MGL_NAMESPACE)
66 #define NAME(func) mgl##func
68 #define NAME(func) gl##func
71 #define DISPATCH(FUNC, ARGS, MESSAGE) \
72 CALL_ ## FUNC(GET_DISPATCH(), ARGS);
74 #define RETURN_DISPATCH(FUNC, ARGS, MESSAGE) \
75 return CALL_ ## FUNC(GET_DISPATCH(), ARGS);
77 /* skip normal ones */
78 #define _GLAPI_SKIP_NORMAL_ENTRY_POINTS
79 #include "glapi/glapitemp.h"
81 #endif /* GLX_INDIRECT_RENDERING */
84 static struct display_dispatch
*DispatchList
= NULL
;
87 /* Display -> Dispatch caching */
88 static Display
*prevDisplay
= NULL
;
89 static struct _glxapi_table
*prevTable
= NULL
;
92 static struct _glxapi_table
*
93 get_dispatch(Display
*dpy
)
98 /* search list of display/dispatch pairs for this display */
100 const struct display_dispatch
*d
= DispatchList
;
104 prevTable
= d
->Table
;
105 return d
->Table
; /* done! */
111 /* A new display, determine if we should use real GLX
112 * or Mesa's pseudo-GLX.
115 struct _glxapi_table
*t
= _mesa_GetGLXDispatchTable();
118 struct display_dispatch
*d
;
119 d
= (struct display_dispatch
*) malloc(sizeof(struct display_dispatch
));
123 /* insert at head of list */
124 d
->Next
= DispatchList
;
134 /* If we get here that means we can't use real GLX on this display
135 * and the Mesa pseudo-GLX software renderer wasn't compiled in.
136 * Or, we ran out of memory!
142 /* Don't use the GET_DISPATCH defined in glthread.h */
145 #define GET_DISPATCH(DPY, TABLE) \
146 if (DPY == prevDisplay) { \
153 TABLE = get_dispatch(DPY); \
160 * GLX API current context.
162 #if defined(GLX_USE_TLS)
163 PUBLIC __thread
void * CurrentContext
164 __attribute__((tls_model("initial-exec")));
165 #elif defined(THREADS)
166 static _glthread_TSD ContextTSD
; /**< Per-thread context pointer */
168 static GLXContext CurrentContext
= 0;
173 SetCurrentContext(GLXContext c
)
175 #if defined(GLX_USE_TLS)
177 #elif defined(THREADS)
178 _glthread_SetTSD(&ContextTSD
, c
);
186 * GLX API entrypoints
189 /*** GLX_VERSION_1_0 ***/
192 glXChooseVisual(Display
*dpy
, int screen
, int *list
)
194 struct _glxapi_table
*t
;
195 GET_DISPATCH(dpy
, t
);
198 return (t
->ChooseVisual
)(dpy
, screen
, list
);
203 glXCopyContext(Display
*dpy
, GLXContext src
, GLXContext dst
, unsigned long mask
)
205 struct _glxapi_table
*t
;
206 GET_DISPATCH(dpy
, t
);
209 (t
->CopyContext
)(dpy
, src
, dst
, mask
);
214 glXCreateContext(Display
*dpy
, XVisualInfo
*visinfo
, GLXContext shareList
, Bool direct
)
216 struct _glxapi_table
*t
;
217 GET_DISPATCH(dpy
, t
);
220 return (t
->CreateContext
)(dpy
, visinfo
, shareList
, direct
);
225 glXCreateGLXPixmap(Display
*dpy
, XVisualInfo
*visinfo
, Pixmap pixmap
)
227 struct _glxapi_table
*t
;
228 GET_DISPATCH(dpy
, t
);
231 return (t
->CreateGLXPixmap
)(dpy
, visinfo
, pixmap
);
236 glXDestroyContext(Display
*dpy
, GLXContext ctx
)
238 struct _glxapi_table
*t
;
239 GET_DISPATCH(dpy
, t
);
242 if (glXGetCurrentContext() == ctx
)
243 SetCurrentContext(NULL
);
244 (t
->DestroyContext
)(dpy
, ctx
);
249 glXDestroyGLXPixmap(Display
*dpy
, GLXPixmap pixmap
)
251 struct _glxapi_table
*t
;
252 GET_DISPATCH(dpy
, t
);
255 (t
->DestroyGLXPixmap
)(dpy
, pixmap
);
260 glXGetConfig(Display
*dpy
, XVisualInfo
*visinfo
, int attrib
, int *value
)
262 struct _glxapi_table
*t
;
263 GET_DISPATCH(dpy
, t
);
265 return GLX_NO_EXTENSION
;
266 return (t
->GetConfig
)(dpy
, visinfo
, attrib
, value
);
271 glXGetCurrentContext(void)
273 #if defined(GLX_USE_TLS)
274 return CurrentContext
;
275 #elif defined(THREADS)
276 return (GLXContext
) _glthread_GetTSD(&ContextTSD
);
278 return CurrentContext
;
284 glXGetCurrentDrawable(void)
286 __GLXcontext
*gc
= (__GLXcontext
*) glXGetCurrentContext();
287 return gc
? gc
->currentDrawable
: 0;
292 glXIsDirect(Display
*dpy
, GLXContext ctx
)
294 struct _glxapi_table
*t
;
295 GET_DISPATCH(dpy
, t
);
298 return (t
->IsDirect
)(dpy
, ctx
);
303 glXMakeCurrent(Display
*dpy
, GLXDrawable drawable
, GLXContext ctx
)
306 struct _glxapi_table
*t
;
307 GET_DISPATCH(dpy
, t
);
311 b
= (*t
->MakeCurrent
)(dpy
, drawable
, ctx
);
313 SetCurrentContext(ctx
);
320 glXQueryExtension(Display
*dpy
, int *errorb
, int *event
)
322 struct _glxapi_table
*t
;
323 GET_DISPATCH(dpy
, t
);
326 return (t
->QueryExtension
)(dpy
, errorb
, event
);
331 glXQueryVersion(Display
*dpy
, int *maj
, int *min
)
333 struct _glxapi_table
*t
;
334 GET_DISPATCH(dpy
, t
);
337 return (t
->QueryVersion
)(dpy
, maj
, min
);
342 glXSwapBuffers(Display
*dpy
, GLXDrawable drawable
)
344 struct _glxapi_table
*t
;
345 GET_DISPATCH(dpy
, t
);
348 (t
->SwapBuffers
)(dpy
, drawable
);
353 glXUseXFont(Font font
, int first
, int count
, int listBase
)
355 struct _glxapi_table
*t
;
356 Display
*dpy
= glXGetCurrentDisplay();
357 GET_DISPATCH(dpy
, t
);
360 (t
->UseXFont
)(font
, first
, count
, listBase
);
367 struct _glxapi_table
*t
;
368 Display
*dpy
= glXGetCurrentDisplay();
369 GET_DISPATCH(dpy
, t
);
379 struct _glxapi_table
*t
;
380 Display
*dpy
= glXGetCurrentDisplay();
381 GET_DISPATCH(dpy
, t
);
389 /*** GLX_VERSION_1_1 ***/
392 glXGetClientString(Display
*dpy
, int name
)
394 struct _glxapi_table
*t
;
395 GET_DISPATCH(dpy
, t
);
398 return (t
->GetClientString
)(dpy
, name
);
403 glXQueryExtensionsString(Display
*dpy
, int screen
)
405 struct _glxapi_table
*t
;
406 GET_DISPATCH(dpy
, t
);
409 return (t
->QueryExtensionsString
)(dpy
, screen
);
414 glXQueryServerString(Display
*dpy
, int screen
, int name
)
416 struct _glxapi_table
*t
;
417 GET_DISPATCH(dpy
, t
);
420 return (t
->QueryServerString
)(dpy
, screen
, name
);
424 /*** GLX_VERSION_1_2 ***/
427 glXGetCurrentDisplay(void)
429 /* Same code as in libGL's glxext.c */
430 __GLXcontext
*gc
= (__GLXcontext
*) glXGetCurrentContext();
431 if (NULL
== gc
) return NULL
;
432 return gc
->currentDpy
;
437 /*** GLX_VERSION_1_3 ***/
440 glXChooseFBConfig(Display
*dpy
, int screen
, const int *attribList
, int *nitems
)
442 struct _glxapi_table
*t
;
443 GET_DISPATCH(dpy
, t
);
446 return (t
->ChooseFBConfig
)(dpy
, screen
, attribList
, nitems
);
451 glXCreateNewContext(Display
*dpy
, GLXFBConfig config
, int renderType
, GLXContext shareList
, Bool direct
)
453 struct _glxapi_table
*t
;
454 GET_DISPATCH(dpy
, t
);
457 return (t
->CreateNewContext
)(dpy
, config
, renderType
, shareList
, direct
);
462 glXCreatePbuffer(Display
*dpy
, GLXFBConfig config
, const int *attribList
)
464 struct _glxapi_table
*t
;
465 GET_DISPATCH(dpy
, t
);
468 return (t
->CreatePbuffer
)(dpy
, config
, attribList
);
473 glXCreatePixmap(Display
*dpy
, GLXFBConfig config
, Pixmap pixmap
, const int *attribList
)
475 struct _glxapi_table
*t
;
476 GET_DISPATCH(dpy
, t
);
479 return (t
->CreatePixmap
)(dpy
, config
, pixmap
, attribList
);
484 glXCreateWindow(Display
*dpy
, GLXFBConfig config
, Window win
, const int *attribList
)
486 struct _glxapi_table
*t
;
487 GET_DISPATCH(dpy
, t
);
490 return (t
->CreateWindow
)(dpy
, config
, win
, attribList
);
495 glXDestroyPbuffer(Display
*dpy
, GLXPbuffer pbuf
)
497 struct _glxapi_table
*t
;
498 GET_DISPATCH(dpy
, t
);
501 (t
->DestroyPbuffer
)(dpy
, pbuf
);
506 glXDestroyPixmap(Display
*dpy
, GLXPixmap pixmap
)
508 struct _glxapi_table
*t
;
509 GET_DISPATCH(dpy
, t
);
512 (t
->DestroyPixmap
)(dpy
, pixmap
);
517 glXDestroyWindow(Display
*dpy
, GLXWindow window
)
519 struct _glxapi_table
*t
;
520 GET_DISPATCH(dpy
, t
);
523 (t
->DestroyWindow
)(dpy
, window
);
528 glXGetCurrentReadDrawable(void)
530 __GLXcontext
*gc
= (__GLXcontext
*) glXGetCurrentContext();
531 return gc
? gc
->currentReadable
: 0;
536 glXGetFBConfigAttrib(Display
*dpy
, GLXFBConfig config
, int attribute
, int *value
)
538 struct _glxapi_table
*t
;
539 GET_DISPATCH(dpy
, t
);
541 return GLX_NO_EXTENSION
;
542 return (t
->GetFBConfigAttrib
)(dpy
, config
, attribute
, value
);
547 glXGetFBConfigs(Display
*dpy
, int screen
, int *nelements
)
549 struct _glxapi_table
*t
;
550 GET_DISPATCH(dpy
, t
);
553 return (t
->GetFBConfigs
)(dpy
, screen
, nelements
);
557 glXGetSelectedEvent(Display
*dpy
, GLXDrawable drawable
, unsigned long *mask
)
559 struct _glxapi_table
*t
;
560 GET_DISPATCH(dpy
, t
);
563 (t
->GetSelectedEvent
)(dpy
, drawable
, mask
);
568 glXGetVisualFromFBConfig(Display
*dpy
, GLXFBConfig config
)
570 struct _glxapi_table
*t
;
571 GET_DISPATCH(dpy
, t
);
574 return (t
->GetVisualFromFBConfig
)(dpy
, config
);
579 glXMakeContextCurrent(Display
*dpy
, GLXDrawable draw
, GLXDrawable read
, GLXContext ctx
)
582 struct _glxapi_table
*t
;
583 GET_DISPATCH(dpy
, t
);
586 b
= (t
->MakeContextCurrent
)(dpy
, draw
, read
, ctx
);
588 SetCurrentContext(ctx
);
595 glXQueryContext(Display
*dpy
, GLXContext ctx
, int attribute
, int *value
)
597 struct _glxapi_table
*t
;
598 GET_DISPATCH(dpy
, t
);
601 return 0; /* XXX correct? */
602 return (t
->QueryContext
)(dpy
, ctx
, attribute
, value
);
607 glXQueryDrawable(Display
*dpy
, GLXDrawable draw
, int attribute
, unsigned int *value
)
609 struct _glxapi_table
*t
;
610 GET_DISPATCH(dpy
, t
);
613 (t
->QueryDrawable
)(dpy
, draw
, attribute
, value
);
618 glXSelectEvent(Display
*dpy
, GLXDrawable drawable
, unsigned long mask
)
620 struct _glxapi_table
*t
;
621 GET_DISPATCH(dpy
, t
);
624 (t
->SelectEvent
)(dpy
, drawable
, mask
);
629 /*** GLX_SGI_swap_control ***/
632 glXSwapIntervalSGI(int interval
)
634 struct _glxapi_table
*t
;
635 Display
*dpy
= glXGetCurrentDisplay();
636 GET_DISPATCH(dpy
, t
);
639 return (t
->SwapIntervalSGI
)(interval
);
644 /*** GLX_SGI_video_sync ***/
647 glXGetVideoSyncSGI(unsigned int *count
)
649 struct _glxapi_table
*t
;
650 Display
*dpy
= glXGetCurrentDisplay();
651 GET_DISPATCH(dpy
, t
);
652 if (!t
|| !glXGetCurrentContext())
653 return GLX_BAD_CONTEXT
;
654 return (t
->GetVideoSyncSGI
)(count
);
658 glXWaitVideoSyncSGI(int divisor
, int remainder
, unsigned int *count
)
660 struct _glxapi_table
*t
;
661 Display
*dpy
= glXGetCurrentDisplay();
662 GET_DISPATCH(dpy
, t
);
663 if (!t
|| !glXGetCurrentContext())
664 return GLX_BAD_CONTEXT
;
665 return (t
->WaitVideoSyncSGI
)(divisor
, remainder
, count
);
670 /*** GLX_SGI_make_current_read ***/
673 glXMakeCurrentReadSGI(Display
*dpy
, GLXDrawable draw
, GLXDrawable read
, GLXContext ctx
)
675 struct _glxapi_table
*t
;
676 GET_DISPATCH(dpy
, t
);
679 return (t
->MakeCurrentReadSGI
)(dpy
, draw
, read
, ctx
);
683 glXGetCurrentReadDrawableSGI(void)
685 return glXGetCurrentReadDrawable();
691 GLXVideoSourceSGIX PUBLIC
692 glXCreateGLXVideoSourceSGIX(Display
*dpy
, int screen
, VLServer server
, VLPath path
, int nodeClass
, VLNode drainNode
)
694 struct _glxapi_table
*t
;
695 GET_DISPATCH(dpy
, t
);
698 return (t
->CreateGLXVideoSourceSGIX
)(dpy
, screen
, server
, path
, nodeClass
, drainNode
);
702 glXDestroyGLXVideoSourceSGIX(Display
*dpy
, GLXVideoSourceSGIX src
)
704 struct _glxapi_table
*t
;
705 GET_DISPATCH(dpy
, t
);
708 return (t
->DestroyGLXVideoSourceSGIX
)(dpy
, src
);
714 /*** GLX_EXT_import_context ***/
717 glXFreeContextEXT(Display
*dpy
, GLXContext context
)
719 struct _glxapi_table
*t
;
720 GET_DISPATCH(dpy
, t
);
723 (t
->FreeContextEXT
)(dpy
, context
);
727 glXGetContextIDEXT(const GLXContext context
)
729 return ((__GLXcontext
*) context
)->xid
;
733 glXGetCurrentDisplayEXT(void)
735 return glXGetCurrentDisplay();
739 glXImportContextEXT(Display
*dpy
, GLXContextID contextID
)
741 struct _glxapi_table
*t
;
742 GET_DISPATCH(dpy
, t
);
745 return (t
->ImportContextEXT
)(dpy
, contextID
);
749 glXQueryContextInfoEXT(Display
*dpy
, GLXContext context
, int attribute
,int *value
)
751 struct _glxapi_table
*t
;
752 GET_DISPATCH(dpy
, t
);
754 return 0; /* XXX ok? */
755 return (t
->QueryContextInfoEXT
)(dpy
, context
, attribute
, value
);
760 /*** GLX_SGIX_fbconfig ***/
763 glXGetFBConfigAttribSGIX(Display
*dpy
, GLXFBConfigSGIX config
, int attribute
, int *value
)
765 struct _glxapi_table
*t
;
766 GET_DISPATCH(dpy
, t
);
769 return (t
->GetFBConfigAttribSGIX
)(dpy
, config
, attribute
, value
);
772 GLXFBConfigSGIX PUBLIC
*
773 glXChooseFBConfigSGIX(Display
*dpy
, int screen
, int *attrib_list
, int *nelements
)
775 struct _glxapi_table
*t
;
776 GET_DISPATCH(dpy
, t
);
779 return (t
->ChooseFBConfigSGIX
)(dpy
, screen
, attrib_list
, nelements
);
783 glXCreateGLXPixmapWithConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
, Pixmap pixmap
)
785 struct _glxapi_table
*t
;
786 GET_DISPATCH(dpy
, t
);
789 return (t
->CreateGLXPixmapWithConfigSGIX
)(dpy
, config
, pixmap
);
793 glXCreateContextWithConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
, int render_type
, GLXContext share_list
, Bool direct
)
795 struct _glxapi_table
*t
;
796 GET_DISPATCH(dpy
, t
);
799 return (t
->CreateContextWithConfigSGIX
)(dpy
, config
, render_type
, share_list
, direct
);
803 glXGetVisualFromFBConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
)
805 struct _glxapi_table
*t
;
806 GET_DISPATCH(dpy
, t
);
809 return (t
->GetVisualFromFBConfigSGIX
)(dpy
, config
);
812 GLXFBConfigSGIX PUBLIC
813 glXGetFBConfigFromVisualSGIX(Display
*dpy
, XVisualInfo
*vis
)
815 struct _glxapi_table
*t
;
816 GET_DISPATCH(dpy
, t
);
819 return (t
->GetFBConfigFromVisualSGIX
)(dpy
, vis
);
824 /*** GLX_SGIX_pbuffer ***/
826 GLXPbufferSGIX PUBLIC
827 glXCreateGLXPbufferSGIX(Display
*dpy
, GLXFBConfigSGIX config
, unsigned int width
, unsigned int height
, int *attrib_list
)
829 struct _glxapi_table
*t
;
830 GET_DISPATCH(dpy
, t
);
833 return (t
->CreateGLXPbufferSGIX
)(dpy
, config
, width
, height
, attrib_list
);
837 glXDestroyGLXPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuf
)
839 struct _glxapi_table
*t
;
840 GET_DISPATCH(dpy
, t
);
843 (t
->DestroyGLXPbufferSGIX
)(dpy
, pbuf
);
847 glXQueryGLXPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuf
, int attribute
, unsigned int *value
)
849 struct _glxapi_table
*t
;
850 GET_DISPATCH(dpy
, t
);
853 return (t
->QueryGLXPbufferSGIX
)(dpy
, pbuf
, attribute
, value
);
857 glXSelectEventSGIX(Display
*dpy
, GLXDrawable drawable
, unsigned long mask
)
859 struct _glxapi_table
*t
;
860 GET_DISPATCH(dpy
, t
);
863 (t
->SelectEventSGIX
)(dpy
, drawable
, mask
);
867 glXGetSelectedEventSGIX(Display
*dpy
, GLXDrawable drawable
, unsigned long *mask
)
869 struct _glxapi_table
*t
;
870 GET_DISPATCH(dpy
, t
);
873 (t
->GetSelectedEventSGIX
)(dpy
, drawable
, mask
);
878 /*** GLX_SGI_cushion ***/
881 glXCushionSGI(Display
*dpy
, Window win
, float cushion
)
883 struct _glxapi_table
*t
;
884 GET_DISPATCH(dpy
, t
);
887 (t
->CushionSGI
)(dpy
, win
, cushion
);
892 /*** GLX_SGIX_video_resize ***/
895 glXBindChannelToWindowSGIX(Display
*dpy
, int screen
, int channel
, Window window
)
897 struct _glxapi_table
*t
;
898 GET_DISPATCH(dpy
, t
);
901 return (t
->BindChannelToWindowSGIX
)(dpy
, screen
, channel
, window
);
905 glXChannelRectSGIX(Display
*dpy
, int screen
, int channel
, int x
, int y
, int w
, int h
)
907 struct _glxapi_table
*t
;
908 GET_DISPATCH(dpy
, t
);
911 return (t
->ChannelRectSGIX
)(dpy
, screen
, channel
, x
, y
, w
, h
);
915 glXQueryChannelRectSGIX(Display
*dpy
, int screen
, int channel
, int *x
, int *y
, int *w
, int *h
)
917 struct _glxapi_table
*t
;
918 GET_DISPATCH(dpy
, t
);
921 return (t
->QueryChannelRectSGIX
)(dpy
, screen
, channel
, x
, y
, w
, h
);
925 glXQueryChannelDeltasSGIX(Display
*dpy
, int screen
, int channel
, int *dx
, int *dy
, int *dw
, int *dh
)
927 struct _glxapi_table
*t
;
928 GET_DISPATCH(dpy
, t
);
931 return (t
->QueryChannelDeltasSGIX
)(dpy
, screen
, channel
, dx
, dy
, dw
, dh
);
935 glXChannelRectSyncSGIX(Display
*dpy
, int screen
, int channel
, GLenum synctype
)
937 struct _glxapi_table
*t
;
938 GET_DISPATCH(dpy
, t
);
941 return (t
->ChannelRectSyncSGIX
)(dpy
, screen
, channel
, synctype
);
946 #if defined(_DM_BUFFER_H_)
949 glXAssociateDMPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuffer
, DMparams
*params
, DMbuffer dmbuffer
)
951 struct _glxapi_table
*t
;
952 GET_DISPATCH(dpy
, t
);
955 return (t
->AssociateDMPbufferSGIX
)(dpy
, pbuffer
, params
, dmbuffer
);
961 /*** GLX_SGIX_swap_group ***/
964 glXJoinSwapGroupSGIX(Display
*dpy
, GLXDrawable drawable
, GLXDrawable member
)
966 struct _glxapi_table
*t
;
967 GET_DISPATCH(dpy
, t
);
970 (*t
->JoinSwapGroupSGIX
)(dpy
, drawable
, member
);
974 /*** GLX_SGIX_swap_barrier ***/
977 glXBindSwapBarrierSGIX(Display
*dpy
, GLXDrawable drawable
, int barrier
)
979 struct _glxapi_table
*t
;
980 GET_DISPATCH(dpy
, t
);
983 (*t
->BindSwapBarrierSGIX
)(dpy
, drawable
, barrier
);
987 glXQueryMaxSwapBarriersSGIX(Display
*dpy
, int screen
, int *max
)
989 struct _glxapi_table
*t
;
990 GET_DISPATCH(dpy
, t
);
993 return (*t
->QueryMaxSwapBarriersSGIX
)(dpy
, screen
, max
);
998 /*** GLX_SUN_get_transparent_index ***/
1001 glXGetTransparentIndexSUN(Display
*dpy
, Window overlay
, Window underlay
, long *pTransparent
)
1003 struct _glxapi_table
*t
;
1004 GET_DISPATCH(dpy
, t
);
1007 return (*t
->GetTransparentIndexSUN
)(dpy
, overlay
, underlay
, pTransparent
);
1012 /*** GLX_MESA_copy_sub_buffer ***/
1015 glXCopySubBufferMESA(Display
*dpy
, GLXDrawable drawable
, int x
, int y
, int width
, int height
)
1017 struct _glxapi_table
*t
;
1018 GET_DISPATCH(dpy
, t
);
1021 (t
->CopySubBufferMESA
)(dpy
, drawable
, x
, y
, width
, height
);
1026 /*** GLX_MESA_release_buffers ***/
1029 glXReleaseBuffersMESA(Display
*dpy
, Window w
)
1031 struct _glxapi_table
*t
;
1032 GET_DISPATCH(dpy
, t
);
1035 return (t
->ReleaseBuffersMESA
)(dpy
, w
);
1040 /*** GLX_MESA_pixmap_colormap ***/
1043 glXCreateGLXPixmapMESA(Display
*dpy
, XVisualInfo
*visinfo
, Pixmap pixmap
, Colormap cmap
)
1045 struct _glxapi_table
*t
;
1046 GET_DISPATCH(dpy
, t
);
1049 return (t
->CreateGLXPixmapMESA
)(dpy
, visinfo
, pixmap
, cmap
);
1054 /*** GLX_MESA_set_3dfx_mode ***/
1057 glXSet3DfxModeMESA(int mode
)
1059 struct _glxapi_table
*t
;
1060 Display
*dpy
= glXGetCurrentDisplay();
1061 GET_DISPATCH(dpy
, t
);
1064 return (t
->Set3DfxModeMESA
)(mode
);
1069 /*** GLX_NV_vertex_array_range ***/
1072 glXAllocateMemoryNV( GLsizei size
,
1073 GLfloat readFrequency
,
1074 GLfloat writeFrequency
,
1077 struct _glxapi_table
*t
;
1078 Display
*dpy
= glXGetCurrentDisplay();
1079 GET_DISPATCH(dpy
, t
);
1082 return (t
->AllocateMemoryNV
)(size
, readFrequency
, writeFrequency
, priority
);
1087 glXFreeMemoryNV( GLvoid
*pointer
)
1089 struct _glxapi_table
*t
;
1090 Display
*dpy
= glXGetCurrentDisplay();
1091 GET_DISPATCH(dpy
, t
);
1094 (t
->FreeMemoryNV
)(pointer
);
1100 /*** GLX_MESA_agp_offset */
1103 glXGetAGPOffsetMESA( const GLvoid
*pointer
)
1105 struct _glxapi_table
*t
;
1106 Display
*dpy
= glXGetCurrentDisplay();
1107 GET_DISPATCH(dpy
, t
);
1110 return (t
->GetAGPOffsetMESA
)(pointer
);
1114 /*** GLX_MESA_allocate_memory */
1117 glXAllocateMemoryMESA(Display
*dpy
, int scrn
, size_t size
,
1118 float readfreq
, float writefreq
, float priority
)
1125 glXFreeMemoryMESA(Display
*dpy
, int scrn
, void *pointer
)
1132 glXGetMemoryOffsetMESA(Display
*dpy
, int scrn
, const void *pointer
)
1139 /*** GLX_EXT_texture_from_pixmap */
1142 glXBindTexImageEXT(Display
*dpy
, GLXDrawable drawable
, int buffer
,
1143 const int *attrib_list
)
1145 struct _glxapi_table
*t
;
1146 GET_DISPATCH(dpy
, t
);
1148 t
->BindTexImageEXT(dpy
, drawable
, buffer
, attrib_list
);
1152 glXReleaseTexImageEXT(Display
*dpy
, GLXDrawable drawable
, int buffer
)
1154 struct _glxapi_table
*t
;
1155 GET_DISPATCH(dpy
, t
);
1157 t
->ReleaseTexImageEXT(dpy
, drawable
, buffer
);
1161 /**********************************************************************/
1162 /* GLX API management functions */
1163 /**********************************************************************/
1167 _glxapi_get_version(void)
1174 * Return array of extension strings.
1177 _glxapi_get_extensions(void)
1179 static const char *extensions
[] = {
1180 #ifdef GLX_EXT_import_context
1181 "GLX_EXT_import_context",
1183 #ifdef GLX_SGI_video_sync
1184 "GLX_SGI_video_sync",
1186 #ifdef GLX_MESA_copy_sub_buffer
1187 "GLX_MESA_copy_sub_buffer",
1189 #ifdef GLX_MESA_release_buffers
1190 "GLX_MESA_release_buffers",
1192 #ifdef GLX_MESA_pixmap_colormap
1193 "GLX_MESA_pixmap_colormap",
1195 #ifdef GLX_MESA_set_3dfx_mode
1196 "GLX_MESA_set_3dfx_mode",
1198 #ifdef GLX_SGIX_fbconfig
1199 "GLX_SGIX_fbconfig",
1201 #ifdef GLX_SGIX_pbuffer
1204 #ifdef GLX_EXT_texture_from_pixmap
1205 "GLX_EXT_texture_from_pixmap",
1207 #ifdef GLX_INTEL_swap_event
1208 "GLX_INTEL_swap_event",
1217 * Return size of the GLX dispatch table, in entries, not bytes.
1220 _glxapi_get_dispatch_table_size(void)
1222 return sizeof(struct _glxapi_table
) / sizeof(void *);
1227 generic_no_op_func(void)
1234 * Initialize all functions in given dispatch table to be no-ops
1237 _glxapi_set_no_op_table(struct _glxapi_table
*t
)
1239 typedef int (*nop_func
)(void);
1240 nop_func
*dispatch
= (nop_func
*) t
;
1241 GLuint n
= _glxapi_get_dispatch_table_size();
1243 for (i
= 0; i
< n
; i
++) {
1244 dispatch
[i
] = generic_no_op_func
;
1249 struct name_address_pair
{
1251 __GLXextFuncPtr Address
;
1254 static struct name_address_pair GLX_functions
[] = {
1255 /*** GLX_VERSION_1_0 ***/
1256 { "glXChooseVisual", (__GLXextFuncPtr
) glXChooseVisual
},
1257 { "glXCopyContext", (__GLXextFuncPtr
) glXCopyContext
},
1258 { "glXCreateContext", (__GLXextFuncPtr
) glXCreateContext
},
1259 { "glXCreateGLXPixmap", (__GLXextFuncPtr
) glXCreateGLXPixmap
},
1260 { "glXDestroyContext", (__GLXextFuncPtr
) glXDestroyContext
},
1261 { "glXDestroyGLXPixmap", (__GLXextFuncPtr
) glXDestroyGLXPixmap
},
1262 { "glXGetConfig", (__GLXextFuncPtr
) glXGetConfig
},
1263 { "glXGetCurrentContext", (__GLXextFuncPtr
) glXGetCurrentContext
},
1264 { "glXGetCurrentDrawable", (__GLXextFuncPtr
) glXGetCurrentDrawable
},
1265 { "glXIsDirect", (__GLXextFuncPtr
) glXIsDirect
},
1266 { "glXMakeCurrent", (__GLXextFuncPtr
) glXMakeCurrent
},
1267 { "glXQueryExtension", (__GLXextFuncPtr
) glXQueryExtension
},
1268 { "glXQueryVersion", (__GLXextFuncPtr
) glXQueryVersion
},
1269 { "glXSwapBuffers", (__GLXextFuncPtr
) glXSwapBuffers
},
1270 { "glXUseXFont", (__GLXextFuncPtr
) glXUseXFont
},
1271 { "glXWaitGL", (__GLXextFuncPtr
) glXWaitGL
},
1272 { "glXWaitX", (__GLXextFuncPtr
) glXWaitX
},
1274 /*** GLX_VERSION_1_1 ***/
1275 { "glXGetClientString", (__GLXextFuncPtr
) glXGetClientString
},
1276 { "glXQueryExtensionsString", (__GLXextFuncPtr
) glXQueryExtensionsString
},
1277 { "glXQueryServerString", (__GLXextFuncPtr
) glXQueryServerString
},
1279 /*** GLX_VERSION_1_2 ***/
1280 { "glXGetCurrentDisplay", (__GLXextFuncPtr
) glXGetCurrentDisplay
},
1282 /*** GLX_VERSION_1_3 ***/
1283 { "glXChooseFBConfig", (__GLXextFuncPtr
) glXChooseFBConfig
},
1284 { "glXCreateNewContext", (__GLXextFuncPtr
) glXCreateNewContext
},
1285 { "glXCreatePbuffer", (__GLXextFuncPtr
) glXCreatePbuffer
},
1286 { "glXCreatePixmap", (__GLXextFuncPtr
) glXCreatePixmap
},
1287 { "glXCreateWindow", (__GLXextFuncPtr
) glXCreateWindow
},
1288 { "glXDestroyPbuffer", (__GLXextFuncPtr
) glXDestroyPbuffer
},
1289 { "glXDestroyPixmap", (__GLXextFuncPtr
) glXDestroyPixmap
},
1290 { "glXDestroyWindow", (__GLXextFuncPtr
) glXDestroyWindow
},
1291 { "glXGetCurrentReadDrawable", (__GLXextFuncPtr
) glXGetCurrentReadDrawable
},
1292 { "glXGetFBConfigAttrib", (__GLXextFuncPtr
) glXGetFBConfigAttrib
},
1293 { "glXGetFBConfigs", (__GLXextFuncPtr
) glXGetFBConfigs
},
1294 { "glXGetSelectedEvent", (__GLXextFuncPtr
) glXGetSelectedEvent
},
1295 { "glXGetVisualFromFBConfig", (__GLXextFuncPtr
) glXGetVisualFromFBConfig
},
1296 { "glXMakeContextCurrent", (__GLXextFuncPtr
) glXMakeContextCurrent
},
1297 { "glXQueryContext", (__GLXextFuncPtr
) glXQueryContext
},
1298 { "glXQueryDrawable", (__GLXextFuncPtr
) glXQueryDrawable
},
1299 { "glXSelectEvent", (__GLXextFuncPtr
) glXSelectEvent
},
1301 /*** GLX_VERSION_1_4 ***/
1302 { "glXGetProcAddress", (__GLXextFuncPtr
) glXGetProcAddress
},
1304 /*** GLX_SGI_swap_control ***/
1305 { "glXSwapIntervalSGI", (__GLXextFuncPtr
) glXSwapIntervalSGI
},
1307 /*** GLX_SGI_video_sync ***/
1308 { "glXGetVideoSyncSGI", (__GLXextFuncPtr
) glXGetVideoSyncSGI
},
1309 { "glXWaitVideoSyncSGI", (__GLXextFuncPtr
) glXWaitVideoSyncSGI
},
1311 /*** GLX_SGI_make_current_read ***/
1312 { "glXMakeCurrentReadSGI", (__GLXextFuncPtr
) glXMakeCurrentReadSGI
},
1313 { "glXGetCurrentReadDrawableSGI", (__GLXextFuncPtr
) glXGetCurrentReadDrawableSGI
},
1315 /*** GLX_SGIX_video_source ***/
1317 { "glXCreateGLXVideoSourceSGIX", (__GLXextFuncPtr
) glXCreateGLXVideoSourceSGIX
},
1318 { "glXDestroyGLXVideoSourceSGIX", (__GLXextFuncPtr
) glXDestroyGLXVideoSourceSGIX
},
1321 /*** GLX_EXT_import_context ***/
1322 { "glXFreeContextEXT", (__GLXextFuncPtr
) glXFreeContextEXT
},
1323 { "glXGetContextIDEXT", (__GLXextFuncPtr
) glXGetContextIDEXT
},
1324 { "glXGetCurrentDisplayEXT", (__GLXextFuncPtr
) glXGetCurrentDisplayEXT
},
1325 { "glXImportContextEXT", (__GLXextFuncPtr
) glXImportContextEXT
},
1326 { "glXQueryContextInfoEXT", (__GLXextFuncPtr
) glXQueryContextInfoEXT
},
1328 /*** GLX_SGIX_fbconfig ***/
1329 { "glXGetFBConfigAttribSGIX", (__GLXextFuncPtr
) glXGetFBConfigAttribSGIX
},
1330 { "glXChooseFBConfigSGIX", (__GLXextFuncPtr
) glXChooseFBConfigSGIX
},
1331 { "glXCreateGLXPixmapWithConfigSGIX", (__GLXextFuncPtr
) glXCreateGLXPixmapWithConfigSGIX
},
1332 { "glXCreateContextWithConfigSGIX", (__GLXextFuncPtr
) glXCreateContextWithConfigSGIX
},
1333 { "glXGetVisualFromFBConfigSGIX", (__GLXextFuncPtr
) glXGetVisualFromFBConfigSGIX
},
1334 { "glXGetFBConfigFromVisualSGIX", (__GLXextFuncPtr
) glXGetFBConfigFromVisualSGIX
},
1336 /*** GLX_SGIX_pbuffer ***/
1337 { "glXCreateGLXPbufferSGIX", (__GLXextFuncPtr
) glXCreateGLXPbufferSGIX
},
1338 { "glXDestroyGLXPbufferSGIX", (__GLXextFuncPtr
) glXDestroyGLXPbufferSGIX
},
1339 { "glXQueryGLXPbufferSGIX", (__GLXextFuncPtr
) glXQueryGLXPbufferSGIX
},
1340 { "glXSelectEventSGIX", (__GLXextFuncPtr
) glXSelectEventSGIX
},
1341 { "glXGetSelectedEventSGIX", (__GLXextFuncPtr
) glXGetSelectedEventSGIX
},
1343 /*** GLX_SGI_cushion ***/
1344 { "glXCushionSGI", (__GLXextFuncPtr
) glXCushionSGI
},
1346 /*** GLX_SGIX_video_resize ***/
1347 { "glXBindChannelToWindowSGIX", (__GLXextFuncPtr
) glXBindChannelToWindowSGIX
},
1348 { "glXChannelRectSGIX", (__GLXextFuncPtr
) glXChannelRectSGIX
},
1349 { "glXQueryChannelRectSGIX", (__GLXextFuncPtr
) glXQueryChannelRectSGIX
},
1350 { "glXQueryChannelDeltasSGIX", (__GLXextFuncPtr
) glXQueryChannelDeltasSGIX
},
1351 { "glXChannelRectSyncSGIX", (__GLXextFuncPtr
) glXChannelRectSyncSGIX
},
1353 /*** GLX_SGIX_dmbuffer **/
1354 #if defined(_DM_BUFFER_H_)
1355 { "glXAssociateDMPbufferSGIX", (__GLXextFuncPtr
) glXAssociateDMPbufferSGIX
},
1358 /*** GLX_SGIX_swap_group ***/
1359 { "glXJoinSwapGroupSGIX", (__GLXextFuncPtr
) glXJoinSwapGroupSGIX
},
1361 /*** GLX_SGIX_swap_barrier ***/
1362 { "glXBindSwapBarrierSGIX", (__GLXextFuncPtr
) glXBindSwapBarrierSGIX
},
1363 { "glXQueryMaxSwapBarriersSGIX", (__GLXextFuncPtr
) glXQueryMaxSwapBarriersSGIX
},
1365 /*** GLX_SUN_get_transparent_index ***/
1366 { "glXGetTransparentIndexSUN", (__GLXextFuncPtr
) glXGetTransparentIndexSUN
},
1368 /*** GLX_MESA_copy_sub_buffer ***/
1369 { "glXCopySubBufferMESA", (__GLXextFuncPtr
) glXCopySubBufferMESA
},
1371 /*** GLX_MESA_pixmap_colormap ***/
1372 { "glXCreateGLXPixmapMESA", (__GLXextFuncPtr
) glXCreateGLXPixmapMESA
},
1374 /*** GLX_MESA_release_buffers ***/
1375 { "glXReleaseBuffersMESA", (__GLXextFuncPtr
) glXReleaseBuffersMESA
},
1377 /*** GLX_MESA_set_3dfx_mode ***/
1378 { "glXSet3DfxModeMESA", (__GLXextFuncPtr
) glXSet3DfxModeMESA
},
1380 /*** GLX_ARB_get_proc_address ***/
1381 { "glXGetProcAddressARB", (__GLXextFuncPtr
) glXGetProcAddressARB
},
1383 /*** GLX_NV_vertex_array_range ***/
1384 { "glXAllocateMemoryNV", (__GLXextFuncPtr
) glXAllocateMemoryNV
},
1385 { "glXFreeMemoryNV", (__GLXextFuncPtr
) glXFreeMemoryNV
},
1387 /*** GLX_MESA_agp_offset ***/
1388 { "glXGetAGPOffsetMESA", (__GLXextFuncPtr
) glXGetAGPOffsetMESA
},
1390 /*** GLX_MESA_allocate_memory ***/
1391 { "glXAllocateMemoryMESA", (__GLXextFuncPtr
) glXAllocateMemoryMESA
},
1392 { "glXFreeMemoryMESA", (__GLXextFuncPtr
) glXFreeMemoryMESA
},
1393 { "glXGetMemoryOffsetMESA", (__GLXextFuncPtr
) glXGetMemoryOffsetMESA
},
1395 /*** GLX_EXT_texture_from_pixmap ***/
1396 { "glXBindTexImageEXT", (__GLXextFuncPtr
) glXBindTexImageEXT
},
1397 { "glXReleaseTexImageEXT", (__GLXextFuncPtr
) glXReleaseTexImageEXT
},
1399 { NULL
, NULL
} /* end of list */
1405 * Return address of named glX function, or NULL if not found.
1408 _glxapi_get_proc_address(const char *funcName
)
1411 for (i
= 0; GLX_functions
[i
].Name
; i
++) {
1413 /* skip the "m" prefix on the name */
1414 if (strcmp(GLX_functions
[i
].Name
, funcName
+1) == 0)
1416 if (strcmp(GLX_functions
[i
].Name
, funcName
) == 0)
1418 return GLX_functions
[i
].Address
;
1426 * This function does not get dispatched through the dispatch table
1427 * since it's really a "meta" function.
1429 __GLXextFuncPtr PUBLIC
1430 glXGetProcAddressARB(const GLubyte
*procName
)
1434 f
= _glxapi_get_proc_address((const char *) procName
);
1439 f
= (__GLXextFuncPtr
) _glapi_get_proc_address((const char *) procName
);
1446 (*glXGetProcAddress(const GLubyte
*procName
))()
1448 return glXGetProcAddressARB(procName
);