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.
42 extern struct _glxapi_table
*_real_GetGLXDispatchTable(void);
43 extern struct _glxapi_table
*_mesa_GetGLXDispatchTable(void);
46 struct display_dispatch
{
48 struct _glxapi_table
*Table
;
49 struct display_dispatch
*Next
;
52 static struct display_dispatch
*DispatchList
= NULL
;
55 /* Display -> Dispatch caching */
56 static Display
*prevDisplay
= NULL
;
57 static struct _glxapi_table
*prevTable
= NULL
;
60 static struct _glxapi_table
*
61 get_dispatch(Display
*dpy
)
66 /* search list of display/dispatch pairs for this display */
68 const struct display_dispatch
*d
= DispatchList
;
73 return d
->Table
; /* done! */
79 /* A new display, determine if we should use real GLX
80 * or Mesa's pseudo-GLX.
83 struct _glxapi_table
*t
= _mesa_GetGLXDispatchTable();
86 struct display_dispatch
*d
;
87 d
= (struct display_dispatch
*) malloc(sizeof(struct display_dispatch
));
91 /* insert at head of list */
92 d
->Next
= DispatchList
;
102 /* If we get here that means we can't use real GLX on this display
103 * and the Mesa pseudo-GLX software renderer wasn't compiled in.
104 * Or, we ran out of memory!
110 /* Don't use the GET_DISPATCH defined in glthread.h */
113 #define GET_DISPATCH(DPY, TABLE) \
114 if (DPY == prevDisplay) { \
121 TABLE = get_dispatch(DPY); \
128 * GLX API current context.
130 #if defined(GLX_USE_TLS)
131 PUBLIC __thread
void * CurrentContext
132 __attribute__((tls_model("initial-exec")));
133 #elif defined(THREADS)
134 static _glthread_TSD ContextTSD
; /**< Per-thread context pointer */
136 static GLXContext CurrentContext
= 0;
141 SetCurrentContext(GLXContext c
)
143 #if defined(GLX_USE_TLS)
145 #elif defined(THREADS)
146 _glthread_SetTSD(&ContextTSD
, c
);
154 * GLX API entrypoints
157 /*** GLX_VERSION_1_0 ***/
160 glXChooseVisual(Display
*dpy
, int screen
, int *list
)
162 struct _glxapi_table
*t
;
163 GET_DISPATCH(dpy
, t
);
166 return (t
->ChooseVisual
)(dpy
, screen
, list
);
171 glXCopyContext(Display
*dpy
, GLXContext src
, GLXContext dst
, unsigned long mask
)
173 struct _glxapi_table
*t
;
174 GET_DISPATCH(dpy
, t
);
177 (t
->CopyContext
)(dpy
, src
, dst
, mask
);
182 glXCreateContext(Display
*dpy
, XVisualInfo
*visinfo
, GLXContext shareList
, Bool direct
)
184 struct _glxapi_table
*t
;
185 GET_DISPATCH(dpy
, t
);
188 return (t
->CreateContext
)(dpy
, visinfo
, shareList
, direct
);
193 glXCreateGLXPixmap(Display
*dpy
, XVisualInfo
*visinfo
, Pixmap pixmap
)
195 struct _glxapi_table
*t
;
196 GET_DISPATCH(dpy
, t
);
199 return (t
->CreateGLXPixmap
)(dpy
, visinfo
, pixmap
);
204 glXDestroyContext(Display
*dpy
, GLXContext ctx
)
206 struct _glxapi_table
*t
;
207 GET_DISPATCH(dpy
, t
);
210 if (glXGetCurrentContext() == ctx
)
211 SetCurrentContext(NULL
);
212 (t
->DestroyContext
)(dpy
, ctx
);
217 glXDestroyGLXPixmap(Display
*dpy
, GLXPixmap pixmap
)
219 struct _glxapi_table
*t
;
220 GET_DISPATCH(dpy
, t
);
223 (t
->DestroyGLXPixmap
)(dpy
, pixmap
);
228 glXGetConfig(Display
*dpy
, XVisualInfo
*visinfo
, int attrib
, int *value
)
230 struct _glxapi_table
*t
;
231 GET_DISPATCH(dpy
, t
);
233 return GLX_NO_EXTENSION
;
234 return (t
->GetConfig
)(dpy
, visinfo
, attrib
, value
);
239 glXGetCurrentContext(void)
241 #if defined(GLX_USE_TLS)
242 return CurrentContext
;
243 #elif defined(THREADS)
244 return (GLXContext
) _glthread_GetTSD(&ContextTSD
);
246 return CurrentContext
;
252 glXGetCurrentDrawable(void)
254 __GLXcontext
*gc
= (__GLXcontext
*) glXGetCurrentContext();
255 return gc
? gc
->currentDrawable
: 0;
260 glXIsDirect(Display
*dpy
, GLXContext ctx
)
262 struct _glxapi_table
*t
;
263 GET_DISPATCH(dpy
, t
);
266 return (t
->IsDirect
)(dpy
, ctx
);
271 glXMakeCurrent(Display
*dpy
, GLXDrawable drawable
, GLXContext ctx
)
274 struct _glxapi_table
*t
;
275 GET_DISPATCH(dpy
, t
);
279 b
= (*t
->MakeCurrent
)(dpy
, drawable
, ctx
);
281 SetCurrentContext(ctx
);
288 glXQueryExtension(Display
*dpy
, int *errorb
, int *event
)
290 struct _glxapi_table
*t
;
291 GET_DISPATCH(dpy
, t
);
294 return (t
->QueryExtension
)(dpy
, errorb
, event
);
299 glXQueryVersion(Display
*dpy
, int *maj
, int *min
)
301 struct _glxapi_table
*t
;
302 GET_DISPATCH(dpy
, t
);
305 return (t
->QueryVersion
)(dpy
, maj
, min
);
310 glXSwapBuffers(Display
*dpy
, GLXDrawable drawable
)
312 struct _glxapi_table
*t
;
313 GET_DISPATCH(dpy
, t
);
316 (t
->SwapBuffers
)(dpy
, drawable
);
321 glXUseXFont(Font font
, int first
, int count
, int listBase
)
323 struct _glxapi_table
*t
;
324 Display
*dpy
= glXGetCurrentDisplay();
325 GET_DISPATCH(dpy
, t
);
328 (t
->UseXFont
)(font
, first
, count
, listBase
);
335 struct _glxapi_table
*t
;
336 Display
*dpy
= glXGetCurrentDisplay();
337 GET_DISPATCH(dpy
, t
);
347 struct _glxapi_table
*t
;
348 Display
*dpy
= glXGetCurrentDisplay();
349 GET_DISPATCH(dpy
, t
);
357 /*** GLX_VERSION_1_1 ***/
360 glXGetClientString(Display
*dpy
, int name
)
362 struct _glxapi_table
*t
;
363 GET_DISPATCH(dpy
, t
);
366 return (t
->GetClientString
)(dpy
, name
);
371 glXQueryExtensionsString(Display
*dpy
, int screen
)
373 struct _glxapi_table
*t
;
374 GET_DISPATCH(dpy
, t
);
377 return (t
->QueryExtensionsString
)(dpy
, screen
);
382 glXQueryServerString(Display
*dpy
, int screen
, int name
)
384 struct _glxapi_table
*t
;
385 GET_DISPATCH(dpy
, t
);
388 return (t
->QueryServerString
)(dpy
, screen
, name
);
392 /*** GLX_VERSION_1_2 ***/
395 glXGetCurrentDisplay(void)
397 /* Same code as in libGL's glxext.c */
398 __GLXcontext
*gc
= (__GLXcontext
*) glXGetCurrentContext();
399 if (NULL
== gc
) return NULL
;
400 return gc
->currentDpy
;
405 /*** GLX_VERSION_1_3 ***/
408 glXChooseFBConfig(Display
*dpy
, int screen
, const int *attribList
, int *nitems
)
410 struct _glxapi_table
*t
;
411 GET_DISPATCH(dpy
, t
);
414 return (t
->ChooseFBConfig
)(dpy
, screen
, attribList
, nitems
);
419 glXCreateNewContext(Display
*dpy
, GLXFBConfig config
, int renderType
, GLXContext shareList
, Bool direct
)
421 struct _glxapi_table
*t
;
422 GET_DISPATCH(dpy
, t
);
425 return (t
->CreateNewContext
)(dpy
, config
, renderType
, shareList
, direct
);
430 glXCreatePbuffer(Display
*dpy
, GLXFBConfig config
, const int *attribList
)
432 struct _glxapi_table
*t
;
433 GET_DISPATCH(dpy
, t
);
436 return (t
->CreatePbuffer
)(dpy
, config
, attribList
);
441 glXCreatePixmap(Display
*dpy
, GLXFBConfig config
, Pixmap pixmap
, const int *attribList
)
443 struct _glxapi_table
*t
;
444 GET_DISPATCH(dpy
, t
);
447 return (t
->CreatePixmap
)(dpy
, config
, pixmap
, attribList
);
452 glXCreateWindow(Display
*dpy
, GLXFBConfig config
, Window win
, const int *attribList
)
454 struct _glxapi_table
*t
;
455 GET_DISPATCH(dpy
, t
);
458 return (t
->CreateWindow
)(dpy
, config
, win
, attribList
);
463 glXDestroyPbuffer(Display
*dpy
, GLXPbuffer pbuf
)
465 struct _glxapi_table
*t
;
466 GET_DISPATCH(dpy
, t
);
469 (t
->DestroyPbuffer
)(dpy
, pbuf
);
474 glXDestroyPixmap(Display
*dpy
, GLXPixmap pixmap
)
476 struct _glxapi_table
*t
;
477 GET_DISPATCH(dpy
, t
);
480 (t
->DestroyPixmap
)(dpy
, pixmap
);
485 glXDestroyWindow(Display
*dpy
, GLXWindow window
)
487 struct _glxapi_table
*t
;
488 GET_DISPATCH(dpy
, t
);
491 (t
->DestroyWindow
)(dpy
, window
);
496 glXGetCurrentReadDrawable(void)
498 __GLXcontext
*gc
= (__GLXcontext
*) glXGetCurrentContext();
499 return gc
? gc
->currentReadable
: 0;
504 glXGetFBConfigAttrib(Display
*dpy
, GLXFBConfig config
, int attribute
, int *value
)
506 struct _glxapi_table
*t
;
507 GET_DISPATCH(dpy
, t
);
509 return GLX_NO_EXTENSION
;
510 return (t
->GetFBConfigAttrib
)(dpy
, config
, attribute
, value
);
515 glXGetFBConfigs(Display
*dpy
, int screen
, int *nelements
)
517 struct _glxapi_table
*t
;
518 GET_DISPATCH(dpy
, t
);
521 return (t
->GetFBConfigs
)(dpy
, screen
, nelements
);
525 glXGetSelectedEvent(Display
*dpy
, GLXDrawable drawable
, unsigned long *mask
)
527 struct _glxapi_table
*t
;
528 GET_DISPATCH(dpy
, t
);
531 (t
->GetSelectedEvent
)(dpy
, drawable
, mask
);
536 glXGetVisualFromFBConfig(Display
*dpy
, GLXFBConfig config
)
538 struct _glxapi_table
*t
;
539 GET_DISPATCH(dpy
, t
);
542 return (t
->GetVisualFromFBConfig
)(dpy
, config
);
547 glXMakeContextCurrent(Display
*dpy
, GLXDrawable draw
, GLXDrawable read
, GLXContext ctx
)
550 struct _glxapi_table
*t
;
551 GET_DISPATCH(dpy
, t
);
554 b
= (t
->MakeContextCurrent
)(dpy
, draw
, read
, ctx
);
556 SetCurrentContext(ctx
);
563 glXQueryContext(Display
*dpy
, GLXContext ctx
, int attribute
, int *value
)
565 struct _glxapi_table
*t
;
566 GET_DISPATCH(dpy
, t
);
569 return 0; /* XXX correct? */
570 return (t
->QueryContext
)(dpy
, ctx
, attribute
, value
);
575 glXQueryDrawable(Display
*dpy
, GLXDrawable draw
, int attribute
, unsigned int *value
)
577 struct _glxapi_table
*t
;
578 GET_DISPATCH(dpy
, t
);
581 (t
->QueryDrawable
)(dpy
, draw
, attribute
, value
);
586 glXSelectEvent(Display
*dpy
, GLXDrawable drawable
, unsigned long mask
)
588 struct _glxapi_table
*t
;
589 GET_DISPATCH(dpy
, t
);
592 (t
->SelectEvent
)(dpy
, drawable
, mask
);
597 /*** GLX_SGI_swap_control ***/
600 glXSwapIntervalSGI(int interval
)
602 struct _glxapi_table
*t
;
603 Display
*dpy
= glXGetCurrentDisplay();
604 GET_DISPATCH(dpy
, t
);
607 return (t
->SwapIntervalSGI
)(interval
);
612 /*** GLX_SGI_video_sync ***/
615 glXGetVideoSyncSGI(unsigned int *count
)
617 struct _glxapi_table
*t
;
618 Display
*dpy
= glXGetCurrentDisplay();
619 GET_DISPATCH(dpy
, t
);
620 if (!t
|| !glXGetCurrentContext())
621 return GLX_BAD_CONTEXT
;
622 return (t
->GetVideoSyncSGI
)(count
);
626 glXWaitVideoSyncSGI(int divisor
, int remainder
, unsigned int *count
)
628 struct _glxapi_table
*t
;
629 Display
*dpy
= glXGetCurrentDisplay();
630 GET_DISPATCH(dpy
, t
);
631 if (!t
|| !glXGetCurrentContext())
632 return GLX_BAD_CONTEXT
;
633 return (t
->WaitVideoSyncSGI
)(divisor
, remainder
, count
);
638 /*** GLX_SGI_make_current_read ***/
641 glXMakeCurrentReadSGI(Display
*dpy
, GLXDrawable draw
, GLXDrawable read
, GLXContext ctx
)
643 struct _glxapi_table
*t
;
644 GET_DISPATCH(dpy
, t
);
647 return (t
->MakeCurrentReadSGI
)(dpy
, draw
, read
, ctx
);
651 glXGetCurrentReadDrawableSGI(void)
653 return glXGetCurrentReadDrawable();
659 GLXVideoSourceSGIX PUBLIC
660 glXCreateGLXVideoSourceSGIX(Display
*dpy
, int screen
, VLServer server
, VLPath path
, int nodeClass
, VLNode drainNode
)
662 struct _glxapi_table
*t
;
663 GET_DISPATCH(dpy
, t
);
666 return (t
->CreateGLXVideoSourceSGIX
)(dpy
, screen
, server
, path
, nodeClass
, drainNode
);
670 glXDestroyGLXVideoSourceSGIX(Display
*dpy
, GLXVideoSourceSGIX src
)
672 struct _glxapi_table
*t
;
673 GET_DISPATCH(dpy
, t
);
676 return (t
->DestroyGLXVideoSourceSGIX
)(dpy
, src
);
682 /*** GLX_EXT_import_context ***/
685 glXFreeContextEXT(Display
*dpy
, GLXContext context
)
687 struct _glxapi_table
*t
;
688 GET_DISPATCH(dpy
, t
);
691 (t
->FreeContextEXT
)(dpy
, context
);
695 glXGetContextIDEXT(const GLXContext context
)
697 return ((__GLXcontext
*) context
)->xid
;
701 glXGetCurrentDisplayEXT(void)
703 return glXGetCurrentDisplay();
707 glXImportContextEXT(Display
*dpy
, GLXContextID contextID
)
709 struct _glxapi_table
*t
;
710 GET_DISPATCH(dpy
, t
);
713 return (t
->ImportContextEXT
)(dpy
, contextID
);
717 glXQueryContextInfoEXT(Display
*dpy
, GLXContext context
, int attribute
,int *value
)
719 struct _glxapi_table
*t
;
720 GET_DISPATCH(dpy
, t
);
722 return 0; /* XXX ok? */
723 return (t
->QueryContextInfoEXT
)(dpy
, context
, attribute
, value
);
728 /*** GLX_SGIX_fbconfig ***/
731 glXGetFBConfigAttribSGIX(Display
*dpy
, GLXFBConfigSGIX config
, int attribute
, int *value
)
733 struct _glxapi_table
*t
;
734 GET_DISPATCH(dpy
, t
);
737 return (t
->GetFBConfigAttribSGIX
)(dpy
, config
, attribute
, value
);
740 GLXFBConfigSGIX PUBLIC
*
741 glXChooseFBConfigSGIX(Display
*dpy
, int screen
, int *attrib_list
, int *nelements
)
743 struct _glxapi_table
*t
;
744 GET_DISPATCH(dpy
, t
);
747 return (t
->ChooseFBConfigSGIX
)(dpy
, screen
, attrib_list
, nelements
);
751 glXCreateGLXPixmapWithConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
, Pixmap pixmap
)
753 struct _glxapi_table
*t
;
754 GET_DISPATCH(dpy
, t
);
757 return (t
->CreateGLXPixmapWithConfigSGIX
)(dpy
, config
, pixmap
);
761 glXCreateContextWithConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
, int render_type
, GLXContext share_list
, Bool direct
)
763 struct _glxapi_table
*t
;
764 GET_DISPATCH(dpy
, t
);
767 return (t
->CreateContextWithConfigSGIX
)(dpy
, config
, render_type
, share_list
, direct
);
771 glXGetVisualFromFBConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
)
773 struct _glxapi_table
*t
;
774 GET_DISPATCH(dpy
, t
);
777 return (t
->GetVisualFromFBConfigSGIX
)(dpy
, config
);
780 GLXFBConfigSGIX PUBLIC
781 glXGetFBConfigFromVisualSGIX(Display
*dpy
, XVisualInfo
*vis
)
783 struct _glxapi_table
*t
;
784 GET_DISPATCH(dpy
, t
);
787 return (t
->GetFBConfigFromVisualSGIX
)(dpy
, vis
);
792 /*** GLX_SGIX_pbuffer ***/
794 GLXPbufferSGIX PUBLIC
795 glXCreateGLXPbufferSGIX(Display
*dpy
, GLXFBConfigSGIX config
, unsigned int width
, unsigned int height
, int *attrib_list
)
797 struct _glxapi_table
*t
;
798 GET_DISPATCH(dpy
, t
);
801 return (t
->CreateGLXPbufferSGIX
)(dpy
, config
, width
, height
, attrib_list
);
805 glXDestroyGLXPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuf
)
807 struct _glxapi_table
*t
;
808 GET_DISPATCH(dpy
, t
);
811 (t
->DestroyGLXPbufferSGIX
)(dpy
, pbuf
);
815 glXQueryGLXPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuf
, int attribute
, unsigned int *value
)
817 struct _glxapi_table
*t
;
818 GET_DISPATCH(dpy
, t
);
821 return (t
->QueryGLXPbufferSGIX
)(dpy
, pbuf
, attribute
, value
);
825 glXSelectEventSGIX(Display
*dpy
, GLXDrawable drawable
, unsigned long mask
)
827 struct _glxapi_table
*t
;
828 GET_DISPATCH(dpy
, t
);
831 (t
->SelectEventSGIX
)(dpy
, drawable
, mask
);
835 glXGetSelectedEventSGIX(Display
*dpy
, GLXDrawable drawable
, unsigned long *mask
)
837 struct _glxapi_table
*t
;
838 GET_DISPATCH(dpy
, t
);
841 (t
->GetSelectedEventSGIX
)(dpy
, drawable
, mask
);
846 /*** GLX_SGI_cushion ***/
849 glXCushionSGI(Display
*dpy
, Window win
, float cushion
)
851 struct _glxapi_table
*t
;
852 GET_DISPATCH(dpy
, t
);
855 (t
->CushionSGI
)(dpy
, win
, cushion
);
860 /*** GLX_SGIX_video_resize ***/
863 glXBindChannelToWindowSGIX(Display
*dpy
, int screen
, int channel
, Window window
)
865 struct _glxapi_table
*t
;
866 GET_DISPATCH(dpy
, t
);
869 return (t
->BindChannelToWindowSGIX
)(dpy
, screen
, channel
, window
);
873 glXChannelRectSGIX(Display
*dpy
, int screen
, int channel
, int x
, int y
, int w
, int h
)
875 struct _glxapi_table
*t
;
876 GET_DISPATCH(dpy
, t
);
879 return (t
->ChannelRectSGIX
)(dpy
, screen
, channel
, x
, y
, w
, h
);
883 glXQueryChannelRectSGIX(Display
*dpy
, int screen
, int channel
, int *x
, int *y
, int *w
, int *h
)
885 struct _glxapi_table
*t
;
886 GET_DISPATCH(dpy
, t
);
889 return (t
->QueryChannelRectSGIX
)(dpy
, screen
, channel
, x
, y
, w
, h
);
893 glXQueryChannelDeltasSGIX(Display
*dpy
, int screen
, int channel
, int *dx
, int *dy
, int *dw
, int *dh
)
895 struct _glxapi_table
*t
;
896 GET_DISPATCH(dpy
, t
);
899 return (t
->QueryChannelDeltasSGIX
)(dpy
, screen
, channel
, dx
, dy
, dw
, dh
);
903 glXChannelRectSyncSGIX(Display
*dpy
, int screen
, int channel
, GLenum synctype
)
905 struct _glxapi_table
*t
;
906 GET_DISPATCH(dpy
, t
);
909 return (t
->ChannelRectSyncSGIX
)(dpy
, screen
, channel
, synctype
);
914 #if defined(_DM_BUFFER_H_)
917 glXAssociateDMPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuffer
, DMparams
*params
, DMbuffer dmbuffer
)
919 struct _glxapi_table
*t
;
920 GET_DISPATCH(dpy
, t
);
923 return (t
->AssociateDMPbufferSGIX
)(dpy
, pbuffer
, params
, dmbuffer
);
929 /*** GLX_SGIX_swap_group ***/
932 glXJoinSwapGroupSGIX(Display
*dpy
, GLXDrawable drawable
, GLXDrawable member
)
934 struct _glxapi_table
*t
;
935 GET_DISPATCH(dpy
, t
);
938 (*t
->JoinSwapGroupSGIX
)(dpy
, drawable
, member
);
942 /*** GLX_SGIX_swap_barrier ***/
945 glXBindSwapBarrierSGIX(Display
*dpy
, GLXDrawable drawable
, int barrier
)
947 struct _glxapi_table
*t
;
948 GET_DISPATCH(dpy
, t
);
951 (*t
->BindSwapBarrierSGIX
)(dpy
, drawable
, barrier
);
955 glXQueryMaxSwapBarriersSGIX(Display
*dpy
, int screen
, int *max
)
957 struct _glxapi_table
*t
;
958 GET_DISPATCH(dpy
, t
);
961 return (*t
->QueryMaxSwapBarriersSGIX
)(dpy
, screen
, max
);
966 /*** GLX_SUN_get_transparent_index ***/
969 glXGetTransparentIndexSUN(Display
*dpy
, Window overlay
, Window underlay
, long *pTransparent
)
971 struct _glxapi_table
*t
;
972 GET_DISPATCH(dpy
, t
);
975 return (*t
->GetTransparentIndexSUN
)(dpy
, overlay
, underlay
, pTransparent
);
980 /*** GLX_MESA_copy_sub_buffer ***/
983 glXCopySubBufferMESA(Display
*dpy
, GLXDrawable drawable
, int x
, int y
, int width
, int height
)
985 struct _glxapi_table
*t
;
986 GET_DISPATCH(dpy
, t
);
989 (t
->CopySubBufferMESA
)(dpy
, drawable
, x
, y
, width
, height
);
994 /*** GLX_MESA_release_buffers ***/
997 glXReleaseBuffersMESA(Display
*dpy
, Window w
)
999 struct _glxapi_table
*t
;
1000 GET_DISPATCH(dpy
, t
);
1003 return (t
->ReleaseBuffersMESA
)(dpy
, w
);
1008 /*** GLX_MESA_pixmap_colormap ***/
1011 glXCreateGLXPixmapMESA(Display
*dpy
, XVisualInfo
*visinfo
, Pixmap pixmap
, Colormap cmap
)
1013 struct _glxapi_table
*t
;
1014 GET_DISPATCH(dpy
, t
);
1017 return (t
->CreateGLXPixmapMESA
)(dpy
, visinfo
, pixmap
, cmap
);
1022 /*** GLX_MESA_set_3dfx_mode ***/
1025 glXSet3DfxModeMESA(int mode
)
1027 struct _glxapi_table
*t
;
1028 Display
*dpy
= glXGetCurrentDisplay();
1029 GET_DISPATCH(dpy
, t
);
1032 return (t
->Set3DfxModeMESA
)(mode
);
1037 /*** GLX_NV_vertex_array_range ***/
1040 glXAllocateMemoryNV( GLsizei size
,
1041 GLfloat readFrequency
,
1042 GLfloat writeFrequency
,
1045 struct _glxapi_table
*t
;
1046 Display
*dpy
= glXGetCurrentDisplay();
1047 GET_DISPATCH(dpy
, t
);
1050 return (t
->AllocateMemoryNV
)(size
, readFrequency
, writeFrequency
, priority
);
1055 glXFreeMemoryNV( GLvoid
*pointer
)
1057 struct _glxapi_table
*t
;
1058 Display
*dpy
= glXGetCurrentDisplay();
1059 GET_DISPATCH(dpy
, t
);
1062 (t
->FreeMemoryNV
)(pointer
);
1068 /*** GLX_MESA_agp_offset */
1071 glXGetAGPOffsetMESA( const GLvoid
*pointer
)
1073 struct _glxapi_table
*t
;
1074 Display
*dpy
= glXGetCurrentDisplay();
1075 GET_DISPATCH(dpy
, t
);
1078 return (t
->GetAGPOffsetMESA
)(pointer
);
1082 /*** GLX_MESA_allocate_memory */
1085 glXAllocateMemoryMESA(Display
*dpy
, int scrn
, size_t size
,
1086 float readfreq
, float writefreq
, float priority
)
1093 glXFreeMemoryMESA(Display
*dpy
, int scrn
, void *pointer
)
1100 glXGetMemoryOffsetMESA(Display
*dpy
, int scrn
, const void *pointer
)
1107 /*** GLX_EXT_texture_from_pixmap */
1110 glXBindTexImageEXT(Display
*dpy
, GLXDrawable drawable
, int buffer
,
1111 const int *attrib_list
)
1113 struct _glxapi_table
*t
;
1114 GET_DISPATCH(dpy
, t
);
1116 t
->BindTexImageEXT(dpy
, drawable
, buffer
, attrib_list
);
1120 glXReleaseTexImageEXT(Display
*dpy
, GLXDrawable drawable
, int buffer
)
1122 struct _glxapi_table
*t
;
1123 GET_DISPATCH(dpy
, t
);
1125 t
->ReleaseTexImageEXT(dpy
, drawable
, buffer
);
1129 /**********************************************************************/
1130 /* GLX API management functions */
1131 /**********************************************************************/
1135 _glxapi_get_version(void)
1142 * Return array of extension strings.
1145 _glxapi_get_extensions(void)
1147 static const char *extensions
[] = {
1148 #ifdef GLX_EXT_import_context
1149 "GLX_EXT_import_context",
1151 #ifdef GLX_SGI_video_sync
1152 "GLX_SGI_video_sync",
1154 #ifdef GLX_MESA_copy_sub_buffer
1155 "GLX_MESA_copy_sub_buffer",
1157 #ifdef GLX_MESA_release_buffers
1158 "GLX_MESA_release_buffers",
1160 #ifdef GLX_MESA_pixmap_colormap
1161 "GLX_MESA_pixmap_colormap",
1163 #ifdef GLX_MESA_set_3dfx_mode
1164 "GLX_MESA_set_3dfx_mode",
1166 #ifdef GLX_SGIX_fbconfig
1167 "GLX_SGIX_fbconfig",
1169 #ifdef GLX_SGIX_pbuffer
1172 #ifdef GLX_EXT_texture_from_pixmap
1173 "GLX_EXT_texture_from_pixmap",
1182 * Return size of the GLX dispatch table, in entries, not bytes.
1185 _glxapi_get_dispatch_table_size(void)
1187 return sizeof(struct _glxapi_table
) / sizeof(void *);
1192 generic_no_op_func(void)
1199 * Initialize all functions in given dispatch table to be no-ops
1202 _glxapi_set_no_op_table(struct _glxapi_table
*t
)
1204 typedef int (*nop_func
)(void);
1205 nop_func
*dispatch
= (nop_func
*) t
;
1206 GLuint n
= _glxapi_get_dispatch_table_size();
1208 for (i
= 0; i
< n
; i
++) {
1209 dispatch
[i
] = generic_no_op_func
;
1214 struct name_address_pair
{
1216 __GLXextFuncPtr Address
;
1219 static struct name_address_pair GLX_functions
[] = {
1220 /*** GLX_VERSION_1_0 ***/
1221 { "glXChooseVisual", (__GLXextFuncPtr
) glXChooseVisual
},
1222 { "glXCopyContext", (__GLXextFuncPtr
) glXCopyContext
},
1223 { "glXCreateContext", (__GLXextFuncPtr
) glXCreateContext
},
1224 { "glXCreateGLXPixmap", (__GLXextFuncPtr
) glXCreateGLXPixmap
},
1225 { "glXDestroyContext", (__GLXextFuncPtr
) glXDestroyContext
},
1226 { "glXDestroyGLXPixmap", (__GLXextFuncPtr
) glXDestroyGLXPixmap
},
1227 { "glXGetConfig", (__GLXextFuncPtr
) glXGetConfig
},
1228 { "glXGetCurrentContext", (__GLXextFuncPtr
) glXGetCurrentContext
},
1229 { "glXGetCurrentDrawable", (__GLXextFuncPtr
) glXGetCurrentDrawable
},
1230 { "glXIsDirect", (__GLXextFuncPtr
) glXIsDirect
},
1231 { "glXMakeCurrent", (__GLXextFuncPtr
) glXMakeCurrent
},
1232 { "glXQueryExtension", (__GLXextFuncPtr
) glXQueryExtension
},
1233 { "glXQueryVersion", (__GLXextFuncPtr
) glXQueryVersion
},
1234 { "glXSwapBuffers", (__GLXextFuncPtr
) glXSwapBuffers
},
1235 { "glXUseXFont", (__GLXextFuncPtr
) glXUseXFont
},
1236 { "glXWaitGL", (__GLXextFuncPtr
) glXWaitGL
},
1237 { "glXWaitX", (__GLXextFuncPtr
) glXWaitX
},
1239 /*** GLX_VERSION_1_1 ***/
1240 { "glXGetClientString", (__GLXextFuncPtr
) glXGetClientString
},
1241 { "glXQueryExtensionsString", (__GLXextFuncPtr
) glXQueryExtensionsString
},
1242 { "glXQueryServerString", (__GLXextFuncPtr
) glXQueryServerString
},
1244 /*** GLX_VERSION_1_2 ***/
1245 { "glXGetCurrentDisplay", (__GLXextFuncPtr
) glXGetCurrentDisplay
},
1247 /*** GLX_VERSION_1_3 ***/
1248 { "glXChooseFBConfig", (__GLXextFuncPtr
) glXChooseFBConfig
},
1249 { "glXCreateNewContext", (__GLXextFuncPtr
) glXCreateNewContext
},
1250 { "glXCreatePbuffer", (__GLXextFuncPtr
) glXCreatePbuffer
},
1251 { "glXCreatePixmap", (__GLXextFuncPtr
) glXCreatePixmap
},
1252 { "glXCreateWindow", (__GLXextFuncPtr
) glXCreateWindow
},
1253 { "glXDestroyPbuffer", (__GLXextFuncPtr
) glXDestroyPbuffer
},
1254 { "glXDestroyPixmap", (__GLXextFuncPtr
) glXDestroyPixmap
},
1255 { "glXDestroyWindow", (__GLXextFuncPtr
) glXDestroyWindow
},
1256 { "glXGetCurrentReadDrawable", (__GLXextFuncPtr
) glXGetCurrentReadDrawable
},
1257 { "glXGetFBConfigAttrib", (__GLXextFuncPtr
) glXGetFBConfigAttrib
},
1258 { "glXGetFBConfigs", (__GLXextFuncPtr
) glXGetFBConfigs
},
1259 { "glXGetSelectedEvent", (__GLXextFuncPtr
) glXGetSelectedEvent
},
1260 { "glXGetVisualFromFBConfig", (__GLXextFuncPtr
) glXGetVisualFromFBConfig
},
1261 { "glXMakeContextCurrent", (__GLXextFuncPtr
) glXMakeContextCurrent
},
1262 { "glXQueryContext", (__GLXextFuncPtr
) glXQueryContext
},
1263 { "glXQueryDrawable", (__GLXextFuncPtr
) glXQueryDrawable
},
1264 { "glXSelectEvent", (__GLXextFuncPtr
) glXSelectEvent
},
1266 /*** GLX_VERSION_1_4 ***/
1267 { "glXGetProcAddress", (__GLXextFuncPtr
) glXGetProcAddress
},
1269 /*** GLX_SGI_swap_control ***/
1270 { "glXSwapIntervalSGI", (__GLXextFuncPtr
) glXSwapIntervalSGI
},
1272 /*** GLX_SGI_video_sync ***/
1273 { "glXGetVideoSyncSGI", (__GLXextFuncPtr
) glXGetVideoSyncSGI
},
1274 { "glXWaitVideoSyncSGI", (__GLXextFuncPtr
) glXWaitVideoSyncSGI
},
1276 /*** GLX_SGI_make_current_read ***/
1277 { "glXMakeCurrentReadSGI", (__GLXextFuncPtr
) glXMakeCurrentReadSGI
},
1278 { "glXGetCurrentReadDrawableSGI", (__GLXextFuncPtr
) glXGetCurrentReadDrawableSGI
},
1280 /*** GLX_SGIX_video_source ***/
1282 { "glXCreateGLXVideoSourceSGIX", (__GLXextFuncPtr
) glXCreateGLXVideoSourceSGIX
},
1283 { "glXDestroyGLXVideoSourceSGIX", (__GLXextFuncPtr
) glXDestroyGLXVideoSourceSGIX
},
1286 /*** GLX_EXT_import_context ***/
1287 { "glXFreeContextEXT", (__GLXextFuncPtr
) glXFreeContextEXT
},
1288 { "glXGetContextIDEXT", (__GLXextFuncPtr
) glXGetContextIDEXT
},
1289 { "glXGetCurrentDisplayEXT", (__GLXextFuncPtr
) glXGetCurrentDisplayEXT
},
1290 { "glXImportContextEXT", (__GLXextFuncPtr
) glXImportContextEXT
},
1291 { "glXQueryContextInfoEXT", (__GLXextFuncPtr
) glXQueryContextInfoEXT
},
1293 /*** GLX_SGIX_fbconfig ***/
1294 { "glXGetFBConfigAttribSGIX", (__GLXextFuncPtr
) glXGetFBConfigAttribSGIX
},
1295 { "glXChooseFBConfigSGIX", (__GLXextFuncPtr
) glXChooseFBConfigSGIX
},
1296 { "glXCreateGLXPixmapWithConfigSGIX", (__GLXextFuncPtr
) glXCreateGLXPixmapWithConfigSGIX
},
1297 { "glXCreateContextWithConfigSGIX", (__GLXextFuncPtr
) glXCreateContextWithConfigSGIX
},
1298 { "glXGetVisualFromFBConfigSGIX", (__GLXextFuncPtr
) glXGetVisualFromFBConfigSGIX
},
1299 { "glXGetFBConfigFromVisualSGIX", (__GLXextFuncPtr
) glXGetFBConfigFromVisualSGIX
},
1301 /*** GLX_SGIX_pbuffer ***/
1302 { "glXCreateGLXPbufferSGIX", (__GLXextFuncPtr
) glXCreateGLXPbufferSGIX
},
1303 { "glXDestroyGLXPbufferSGIX", (__GLXextFuncPtr
) glXDestroyGLXPbufferSGIX
},
1304 { "glXQueryGLXPbufferSGIX", (__GLXextFuncPtr
) glXQueryGLXPbufferSGIX
},
1305 { "glXSelectEventSGIX", (__GLXextFuncPtr
) glXSelectEventSGIX
},
1306 { "glXGetSelectedEventSGIX", (__GLXextFuncPtr
) glXGetSelectedEventSGIX
},
1308 /*** GLX_SGI_cushion ***/
1309 { "glXCushionSGI", (__GLXextFuncPtr
) glXCushionSGI
},
1311 /*** GLX_SGIX_video_resize ***/
1312 { "glXBindChannelToWindowSGIX", (__GLXextFuncPtr
) glXBindChannelToWindowSGIX
},
1313 { "glXChannelRectSGIX", (__GLXextFuncPtr
) glXChannelRectSGIX
},
1314 { "glXQueryChannelRectSGIX", (__GLXextFuncPtr
) glXQueryChannelRectSGIX
},
1315 { "glXQueryChannelDeltasSGIX", (__GLXextFuncPtr
) glXQueryChannelDeltasSGIX
},
1316 { "glXChannelRectSyncSGIX", (__GLXextFuncPtr
) glXChannelRectSyncSGIX
},
1318 /*** GLX_SGIX_dmbuffer **/
1319 #if defined(_DM_BUFFER_H_)
1320 { "glXAssociateDMPbufferSGIX", (__GLXextFuncPtr
) glXAssociateDMPbufferSGIX
},
1323 /*** GLX_SGIX_swap_group ***/
1324 { "glXJoinSwapGroupSGIX", (__GLXextFuncPtr
) glXJoinSwapGroupSGIX
},
1326 /*** GLX_SGIX_swap_barrier ***/
1327 { "glXBindSwapBarrierSGIX", (__GLXextFuncPtr
) glXBindSwapBarrierSGIX
},
1328 { "glXQueryMaxSwapBarriersSGIX", (__GLXextFuncPtr
) glXQueryMaxSwapBarriersSGIX
},
1330 /*** GLX_SUN_get_transparent_index ***/
1331 { "glXGetTransparentIndexSUN", (__GLXextFuncPtr
) glXGetTransparentIndexSUN
},
1333 /*** GLX_MESA_copy_sub_buffer ***/
1334 { "glXCopySubBufferMESA", (__GLXextFuncPtr
) glXCopySubBufferMESA
},
1336 /*** GLX_MESA_pixmap_colormap ***/
1337 { "glXCreateGLXPixmapMESA", (__GLXextFuncPtr
) glXCreateGLXPixmapMESA
},
1339 /*** GLX_MESA_release_buffers ***/
1340 { "glXReleaseBuffersMESA", (__GLXextFuncPtr
) glXReleaseBuffersMESA
},
1342 /*** GLX_MESA_set_3dfx_mode ***/
1343 { "glXSet3DfxModeMESA", (__GLXextFuncPtr
) glXSet3DfxModeMESA
},
1345 /*** GLX_ARB_get_proc_address ***/
1346 { "glXGetProcAddressARB", (__GLXextFuncPtr
) glXGetProcAddressARB
},
1348 /*** GLX_NV_vertex_array_range ***/
1349 { "glXAllocateMemoryNV", (__GLXextFuncPtr
) glXAllocateMemoryNV
},
1350 { "glXFreeMemoryNV", (__GLXextFuncPtr
) glXFreeMemoryNV
},
1352 /*** GLX_MESA_agp_offset ***/
1353 { "glXGetAGPOffsetMESA", (__GLXextFuncPtr
) glXGetAGPOffsetMESA
},
1355 /*** GLX_MESA_allocate_memory ***/
1356 { "glXAllocateMemoryMESA", (__GLXextFuncPtr
) glXAllocateMemoryMESA
},
1357 { "glXFreeMemoryMESA", (__GLXextFuncPtr
) glXFreeMemoryMESA
},
1358 { "glXGetMemoryOffsetMESA", (__GLXextFuncPtr
) glXGetMemoryOffsetMESA
},
1360 /*** GLX_EXT_texture_from_pixmap ***/
1361 { "glXBindTexImageEXT", (__GLXextFuncPtr
) glXBindTexImageEXT
},
1362 { "glXReleaseTexImageEXT", (__GLXextFuncPtr
) glXReleaseTexImageEXT
},
1364 { NULL
, NULL
} /* end of list */
1370 * Return address of named glX function, or NULL if not found.
1373 _glxapi_get_proc_address(const char *funcName
)
1376 for (i
= 0; GLX_functions
[i
].Name
; i
++) {
1377 if (strcmp(GLX_functions
[i
].Name
, funcName
) == 0)
1378 return GLX_functions
[i
].Address
;
1386 * This function does not get dispatched through the dispatch table
1387 * since it's really a "meta" function.
1390 glXGetProcAddressARB(const GLubyte
*procName
)
1394 f
= _glxapi_get_proc_address((const char *) procName
);
1399 f
= (__GLXextFuncPtr
) _glapi_get_proc_address((const char *) procName
);
1405 void (*glXGetProcAddress(const GLubyte
*procName
))()
1407 return glXGetProcAddressARB(procName
);