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
;
53 static struct display_dispatch
*DispatchList
= NULL
;
56 /* Display -> Dispatch caching */
57 static Display
*prevDisplay
= NULL
;
58 static struct _glxapi_table
*prevTable
= NULL
;
61 static struct _glxapi_table
*
62 get_dispatch(Display
*dpy
)
67 /* search list of display/dispatch pairs for this display */
69 const struct display_dispatch
*d
= DispatchList
;
74 return d
->Table
; /* done! */
80 /* A new display, determine if we should use real GLX
81 * or Mesa's pseudo-GLX.
84 struct _glxapi_table
*t
= _mesa_GetGLXDispatchTable();
87 struct display_dispatch
*d
;
88 d
= (struct display_dispatch
*) malloc(sizeof(struct display_dispatch
));
92 /* insert at head of list */
93 d
->Next
= DispatchList
;
103 /* If we get here that means we can't use real GLX on this display
104 * and the Mesa pseudo-GLX software renderer wasn't compiled in.
105 * Or, we ran out of memory!
111 /* Don't use the GET_DISPATCH defined in glthread.h */
114 #define GET_DISPATCH(DPY, TABLE) \
115 if (DPY == prevDisplay) { \
122 TABLE = get_dispatch(DPY); \
129 * GLX API current context.
131 #if defined(GLX_USE_TLS)
132 PUBLIC __thread
void * CurrentContext
133 __attribute__((tls_model("initial-exec")));
134 #elif defined(THREADS)
135 static _glthread_TSD ContextTSD
; /**< Per-thread context pointer */
137 static GLXContext CurrentContext
= 0;
142 SetCurrentContext(GLXContext c
)
144 #if defined(GLX_USE_TLS)
146 #elif defined(THREADS)
147 _glthread_SetTSD(&ContextTSD
, c
);
155 * GLX API entrypoints
158 /*** GLX_VERSION_1_0 ***/
161 glXChooseVisual(Display
*dpy
, int screen
, int *list
)
163 struct _glxapi_table
*t
;
164 GET_DISPATCH(dpy
, t
);
167 return (t
->ChooseVisual
)(dpy
, screen
, list
);
172 glXCopyContext(Display
*dpy
, GLXContext src
, GLXContext dst
, unsigned long mask
)
174 struct _glxapi_table
*t
;
175 GET_DISPATCH(dpy
, t
);
178 (t
->CopyContext
)(dpy
, src
, dst
, mask
);
183 glXCreateContext(Display
*dpy
, XVisualInfo
*visinfo
, GLXContext shareList
, Bool direct
)
185 struct _glxapi_table
*t
;
186 GET_DISPATCH(dpy
, t
);
189 return (t
->CreateContext
)(dpy
, visinfo
, shareList
, direct
);
194 glXCreateGLXPixmap(Display
*dpy
, XVisualInfo
*visinfo
, Pixmap pixmap
)
196 struct _glxapi_table
*t
;
197 GET_DISPATCH(dpy
, t
);
200 return (t
->CreateGLXPixmap
)(dpy
, visinfo
, pixmap
);
205 glXDestroyContext(Display
*dpy
, GLXContext ctx
)
207 struct _glxapi_table
*t
;
208 GET_DISPATCH(dpy
, t
);
211 if (glXGetCurrentContext() == ctx
)
212 SetCurrentContext(NULL
);
213 (t
->DestroyContext
)(dpy
, ctx
);
218 glXDestroyGLXPixmap(Display
*dpy
, GLXPixmap pixmap
)
220 struct _glxapi_table
*t
;
221 GET_DISPATCH(dpy
, t
);
224 (t
->DestroyGLXPixmap
)(dpy
, pixmap
);
229 glXGetConfig(Display
*dpy
, XVisualInfo
*visinfo
, int attrib
, int *value
)
231 struct _glxapi_table
*t
;
232 GET_DISPATCH(dpy
, t
);
234 return GLX_NO_EXTENSION
;
235 return (t
->GetConfig
)(dpy
, visinfo
, attrib
, value
);
240 glXGetCurrentContext(void)
242 #if defined(GLX_USE_TLS)
243 return CurrentContext
;
244 #elif defined(THREADS)
245 return (GLXContext
) _glthread_GetTSD(&ContextTSD
);
247 return CurrentContext
;
253 glXGetCurrentDrawable(void)
255 __GLXcontext
*gc
= (__GLXcontext
*) glXGetCurrentContext();
256 return gc
? gc
->currentDrawable
: 0;
261 glXIsDirect(Display
*dpy
, GLXContext ctx
)
263 struct _glxapi_table
*t
;
264 GET_DISPATCH(dpy
, t
);
267 return (t
->IsDirect
)(dpy
, ctx
);
272 glXMakeCurrent(Display
*dpy
, GLXDrawable drawable
, GLXContext ctx
)
275 struct _glxapi_table
*t
;
276 GET_DISPATCH(dpy
, t
);
280 b
= (*t
->MakeCurrent
)(dpy
, drawable
, ctx
);
282 SetCurrentContext(ctx
);
289 glXQueryExtension(Display
*dpy
, int *errorb
, int *event
)
291 struct _glxapi_table
*t
;
292 GET_DISPATCH(dpy
, t
);
295 return (t
->QueryExtension
)(dpy
, errorb
, event
);
300 glXQueryVersion(Display
*dpy
, int *maj
, int *min
)
302 struct _glxapi_table
*t
;
303 GET_DISPATCH(dpy
, t
);
306 return (t
->QueryVersion
)(dpy
, maj
, min
);
311 glXSwapBuffers(Display
*dpy
, GLXDrawable drawable
)
313 struct _glxapi_table
*t
;
314 GET_DISPATCH(dpy
, t
);
317 (t
->SwapBuffers
)(dpy
, drawable
);
322 glXUseXFont(Font font
, int first
, int count
, int listBase
)
324 struct _glxapi_table
*t
;
325 Display
*dpy
= glXGetCurrentDisplay();
326 GET_DISPATCH(dpy
, t
);
329 (t
->UseXFont
)(font
, first
, count
, listBase
);
336 struct _glxapi_table
*t
;
337 Display
*dpy
= glXGetCurrentDisplay();
338 GET_DISPATCH(dpy
, t
);
348 struct _glxapi_table
*t
;
349 Display
*dpy
= glXGetCurrentDisplay();
350 GET_DISPATCH(dpy
, t
);
358 /*** GLX_VERSION_1_1 ***/
361 glXGetClientString(Display
*dpy
, int name
)
363 struct _glxapi_table
*t
;
364 GET_DISPATCH(dpy
, t
);
367 return (t
->GetClientString
)(dpy
, name
);
372 glXQueryExtensionsString(Display
*dpy
, int screen
)
374 struct _glxapi_table
*t
;
375 GET_DISPATCH(dpy
, t
);
378 return (t
->QueryExtensionsString
)(dpy
, screen
);
383 glXQueryServerString(Display
*dpy
, int screen
, int name
)
385 struct _glxapi_table
*t
;
386 GET_DISPATCH(dpy
, t
);
389 return (t
->QueryServerString
)(dpy
, screen
, name
);
393 /*** GLX_VERSION_1_2 ***/
396 glXGetCurrentDisplay(void)
398 /* Same code as in libGL's glxext.c */
399 __GLXcontext
*gc
= (__GLXcontext
*) glXGetCurrentContext();
400 if (NULL
== gc
) return NULL
;
401 return gc
->currentDpy
;
406 /*** GLX_VERSION_1_3 ***/
409 glXChooseFBConfig(Display
*dpy
, int screen
, const int *attribList
, int *nitems
)
411 struct _glxapi_table
*t
;
412 GET_DISPATCH(dpy
, t
);
415 return (t
->ChooseFBConfig
)(dpy
, screen
, attribList
, nitems
);
420 glXCreateNewContext(Display
*dpy
, GLXFBConfig config
, int renderType
, GLXContext shareList
, Bool direct
)
422 struct _glxapi_table
*t
;
423 GET_DISPATCH(dpy
, t
);
426 return (t
->CreateNewContext
)(dpy
, config
, renderType
, shareList
, direct
);
431 glXCreatePbuffer(Display
*dpy
, GLXFBConfig config
, const int *attribList
)
433 struct _glxapi_table
*t
;
434 GET_DISPATCH(dpy
, t
);
437 return (t
->CreatePbuffer
)(dpy
, config
, attribList
);
442 glXCreatePixmap(Display
*dpy
, GLXFBConfig config
, Pixmap pixmap
, const int *attribList
)
444 struct _glxapi_table
*t
;
445 GET_DISPATCH(dpy
, t
);
448 return (t
->CreatePixmap
)(dpy
, config
, pixmap
, attribList
);
453 glXCreateWindow(Display
*dpy
, GLXFBConfig config
, Window win
, const int *attribList
)
455 struct _glxapi_table
*t
;
456 GET_DISPATCH(dpy
, t
);
459 return (t
->CreateWindow
)(dpy
, config
, win
, attribList
);
464 glXDestroyPbuffer(Display
*dpy
, GLXPbuffer pbuf
)
466 struct _glxapi_table
*t
;
467 GET_DISPATCH(dpy
, t
);
470 (t
->DestroyPbuffer
)(dpy
, pbuf
);
475 glXDestroyPixmap(Display
*dpy
, GLXPixmap pixmap
)
477 struct _glxapi_table
*t
;
478 GET_DISPATCH(dpy
, t
);
481 (t
->DestroyPixmap
)(dpy
, pixmap
);
486 glXDestroyWindow(Display
*dpy
, GLXWindow window
)
488 struct _glxapi_table
*t
;
489 GET_DISPATCH(dpy
, t
);
492 (t
->DestroyWindow
)(dpy
, window
);
497 glXGetCurrentReadDrawable(void)
499 __GLXcontext
*gc
= (__GLXcontext
*) glXGetCurrentContext();
500 return gc
? gc
->currentReadable
: 0;
505 glXGetFBConfigAttrib(Display
*dpy
, GLXFBConfig config
, int attribute
, int *value
)
507 struct _glxapi_table
*t
;
508 GET_DISPATCH(dpy
, t
);
510 return GLX_NO_EXTENSION
;
511 return (t
->GetFBConfigAttrib
)(dpy
, config
, attribute
, value
);
516 glXGetFBConfigs(Display
*dpy
, int screen
, int *nelements
)
518 struct _glxapi_table
*t
;
519 GET_DISPATCH(dpy
, t
);
522 return (t
->GetFBConfigs
)(dpy
, screen
, nelements
);
526 glXGetSelectedEvent(Display
*dpy
, GLXDrawable drawable
, unsigned long *mask
)
528 struct _glxapi_table
*t
;
529 GET_DISPATCH(dpy
, t
);
532 (t
->GetSelectedEvent
)(dpy
, drawable
, mask
);
537 glXGetVisualFromFBConfig(Display
*dpy
, GLXFBConfig config
)
539 struct _glxapi_table
*t
;
540 GET_DISPATCH(dpy
, t
);
543 return (t
->GetVisualFromFBConfig
)(dpy
, config
);
548 glXMakeContextCurrent(Display
*dpy
, GLXDrawable draw
, GLXDrawable read
, GLXContext ctx
)
551 struct _glxapi_table
*t
;
552 GET_DISPATCH(dpy
, t
);
555 b
= (t
->MakeContextCurrent
)(dpy
, draw
, read
, ctx
);
557 SetCurrentContext(ctx
);
564 glXQueryContext(Display
*dpy
, GLXContext ctx
, int attribute
, int *value
)
566 struct _glxapi_table
*t
;
567 GET_DISPATCH(dpy
, t
);
570 return 0; /* XXX correct? */
571 return (t
->QueryContext
)(dpy
, ctx
, attribute
, value
);
576 glXQueryDrawable(Display
*dpy
, GLXDrawable draw
, int attribute
, unsigned int *value
)
578 struct _glxapi_table
*t
;
579 GET_DISPATCH(dpy
, t
);
582 (t
->QueryDrawable
)(dpy
, draw
, attribute
, value
);
587 glXSelectEvent(Display
*dpy
, GLXDrawable drawable
, unsigned long mask
)
589 struct _glxapi_table
*t
;
590 GET_DISPATCH(dpy
, t
);
593 (t
->SelectEvent
)(dpy
, drawable
, mask
);
598 /*** GLX_SGI_swap_control ***/
601 glXSwapIntervalSGI(int interval
)
603 struct _glxapi_table
*t
;
604 Display
*dpy
= glXGetCurrentDisplay();
605 GET_DISPATCH(dpy
, t
);
608 return (t
->SwapIntervalSGI
)(interval
);
613 /*** GLX_SGI_video_sync ***/
616 glXGetVideoSyncSGI(unsigned int *count
)
618 struct _glxapi_table
*t
;
619 Display
*dpy
= glXGetCurrentDisplay();
620 GET_DISPATCH(dpy
, t
);
621 if (!t
|| !glXGetCurrentContext())
622 return GLX_BAD_CONTEXT
;
623 return (t
->GetVideoSyncSGI
)(count
);
627 glXWaitVideoSyncSGI(int divisor
, int remainder
, unsigned int *count
)
629 struct _glxapi_table
*t
;
630 Display
*dpy
= glXGetCurrentDisplay();
631 GET_DISPATCH(dpy
, t
);
632 if (!t
|| !glXGetCurrentContext())
633 return GLX_BAD_CONTEXT
;
634 return (t
->WaitVideoSyncSGI
)(divisor
, remainder
, count
);
639 /*** GLX_SGI_make_current_read ***/
642 glXMakeCurrentReadSGI(Display
*dpy
, GLXDrawable draw
, GLXDrawable read
, GLXContext ctx
)
644 struct _glxapi_table
*t
;
645 GET_DISPATCH(dpy
, t
);
648 return (t
->MakeCurrentReadSGI
)(dpy
, draw
, read
, ctx
);
652 glXGetCurrentReadDrawableSGI(void)
654 return glXGetCurrentReadDrawable();
660 GLXVideoSourceSGIX PUBLIC
661 glXCreateGLXVideoSourceSGIX(Display
*dpy
, int screen
, VLServer server
, VLPath path
, int nodeClass
, VLNode drainNode
)
663 struct _glxapi_table
*t
;
664 GET_DISPATCH(dpy
, t
);
667 return (t
->CreateGLXVideoSourceSGIX
)(dpy
, screen
, server
, path
, nodeClass
, drainNode
);
671 glXDestroyGLXVideoSourceSGIX(Display
*dpy
, GLXVideoSourceSGIX src
)
673 struct _glxapi_table
*t
;
674 GET_DISPATCH(dpy
, t
);
677 return (t
->DestroyGLXVideoSourceSGIX
)(dpy
, src
);
683 /*** GLX_EXT_import_context ***/
686 glXFreeContextEXT(Display
*dpy
, GLXContext context
)
688 struct _glxapi_table
*t
;
689 GET_DISPATCH(dpy
, t
);
692 (t
->FreeContextEXT
)(dpy
, context
);
696 glXGetContextIDEXT(const GLXContext context
)
698 return ((__GLXcontext
*) context
)->xid
;
702 glXGetCurrentDisplayEXT(void)
704 return glXGetCurrentDisplay();
708 glXImportContextEXT(Display
*dpy
, GLXContextID contextID
)
710 struct _glxapi_table
*t
;
711 GET_DISPATCH(dpy
, t
);
714 return (t
->ImportContextEXT
)(dpy
, contextID
);
718 glXQueryContextInfoEXT(Display
*dpy
, GLXContext context
, int attribute
,int *value
)
720 struct _glxapi_table
*t
;
721 GET_DISPATCH(dpy
, t
);
723 return 0; /* XXX ok? */
724 return (t
->QueryContextInfoEXT
)(dpy
, context
, attribute
, value
);
729 /*** GLX_SGIX_fbconfig ***/
732 glXGetFBConfigAttribSGIX(Display
*dpy
, GLXFBConfigSGIX config
, int attribute
, int *value
)
734 struct _glxapi_table
*t
;
735 GET_DISPATCH(dpy
, t
);
738 return (t
->GetFBConfigAttribSGIX
)(dpy
, config
, attribute
, value
);
741 GLXFBConfigSGIX PUBLIC
*
742 glXChooseFBConfigSGIX(Display
*dpy
, int screen
, int *attrib_list
, int *nelements
)
744 struct _glxapi_table
*t
;
745 GET_DISPATCH(dpy
, t
);
748 return (t
->ChooseFBConfigSGIX
)(dpy
, screen
, attrib_list
, nelements
);
752 glXCreateGLXPixmapWithConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
, Pixmap pixmap
)
754 struct _glxapi_table
*t
;
755 GET_DISPATCH(dpy
, t
);
758 return (t
->CreateGLXPixmapWithConfigSGIX
)(dpy
, config
, pixmap
);
762 glXCreateContextWithConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
, int render_type
, GLXContext share_list
, Bool direct
)
764 struct _glxapi_table
*t
;
765 GET_DISPATCH(dpy
, t
);
768 return (t
->CreateContextWithConfigSGIX
)(dpy
, config
, render_type
, share_list
, direct
);
772 glXGetVisualFromFBConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
)
774 struct _glxapi_table
*t
;
775 GET_DISPATCH(dpy
, t
);
778 return (t
->GetVisualFromFBConfigSGIX
)(dpy
, config
);
781 GLXFBConfigSGIX PUBLIC
782 glXGetFBConfigFromVisualSGIX(Display
*dpy
, XVisualInfo
*vis
)
784 struct _glxapi_table
*t
;
785 GET_DISPATCH(dpy
, t
);
788 return (t
->GetFBConfigFromVisualSGIX
)(dpy
, vis
);
793 /*** GLX_SGIX_pbuffer ***/
795 GLXPbufferSGIX PUBLIC
796 glXCreateGLXPbufferSGIX(Display
*dpy
, GLXFBConfigSGIX config
, unsigned int width
, unsigned int height
, int *attrib_list
)
798 struct _glxapi_table
*t
;
799 GET_DISPATCH(dpy
, t
);
802 return (t
->CreateGLXPbufferSGIX
)(dpy
, config
, width
, height
, attrib_list
);
806 glXDestroyGLXPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuf
)
808 struct _glxapi_table
*t
;
809 GET_DISPATCH(dpy
, t
);
812 (t
->DestroyGLXPbufferSGIX
)(dpy
, pbuf
);
816 glXQueryGLXPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuf
, int attribute
, unsigned int *value
)
818 struct _glxapi_table
*t
;
819 GET_DISPATCH(dpy
, t
);
822 return (t
->QueryGLXPbufferSGIX
)(dpy
, pbuf
, attribute
, value
);
826 glXSelectEventSGIX(Display
*dpy
, GLXDrawable drawable
, unsigned long mask
)
828 struct _glxapi_table
*t
;
829 GET_DISPATCH(dpy
, t
);
832 (t
->SelectEventSGIX
)(dpy
, drawable
, mask
);
836 glXGetSelectedEventSGIX(Display
*dpy
, GLXDrawable drawable
, unsigned long *mask
)
838 struct _glxapi_table
*t
;
839 GET_DISPATCH(dpy
, t
);
842 (t
->GetSelectedEventSGIX
)(dpy
, drawable
, mask
);
847 /*** GLX_SGI_cushion ***/
850 glXCushionSGI(Display
*dpy
, Window win
, float cushion
)
852 struct _glxapi_table
*t
;
853 GET_DISPATCH(dpy
, t
);
856 (t
->CushionSGI
)(dpy
, win
, cushion
);
861 /*** GLX_SGIX_video_resize ***/
864 glXBindChannelToWindowSGIX(Display
*dpy
, int screen
, int channel
, Window window
)
866 struct _glxapi_table
*t
;
867 GET_DISPATCH(dpy
, t
);
870 return (t
->BindChannelToWindowSGIX
)(dpy
, screen
, channel
, window
);
874 glXChannelRectSGIX(Display
*dpy
, int screen
, int channel
, int x
, int y
, int w
, int h
)
876 struct _glxapi_table
*t
;
877 GET_DISPATCH(dpy
, t
);
880 return (t
->ChannelRectSGIX
)(dpy
, screen
, channel
, x
, y
, w
, h
);
884 glXQueryChannelRectSGIX(Display
*dpy
, int screen
, int channel
, int *x
, int *y
, int *w
, int *h
)
886 struct _glxapi_table
*t
;
887 GET_DISPATCH(dpy
, t
);
890 return (t
->QueryChannelRectSGIX
)(dpy
, screen
, channel
, x
, y
, w
, h
);
894 glXQueryChannelDeltasSGIX(Display
*dpy
, int screen
, int channel
, int *dx
, int *dy
, int *dw
, int *dh
)
896 struct _glxapi_table
*t
;
897 GET_DISPATCH(dpy
, t
);
900 return (t
->QueryChannelDeltasSGIX
)(dpy
, screen
, channel
, dx
, dy
, dw
, dh
);
904 glXChannelRectSyncSGIX(Display
*dpy
, int screen
, int channel
, GLenum synctype
)
906 struct _glxapi_table
*t
;
907 GET_DISPATCH(dpy
, t
);
910 return (t
->ChannelRectSyncSGIX
)(dpy
, screen
, channel
, synctype
);
915 #if defined(_DM_BUFFER_H_)
918 glXAssociateDMPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuffer
, DMparams
*params
, DMbuffer dmbuffer
)
920 struct _glxapi_table
*t
;
921 GET_DISPATCH(dpy
, t
);
924 return (t
->AssociateDMPbufferSGIX
)(dpy
, pbuffer
, params
, dmbuffer
);
930 /*** GLX_SGIX_swap_group ***/
933 glXJoinSwapGroupSGIX(Display
*dpy
, GLXDrawable drawable
, GLXDrawable member
)
935 struct _glxapi_table
*t
;
936 GET_DISPATCH(dpy
, t
);
939 (*t
->JoinSwapGroupSGIX
)(dpy
, drawable
, member
);
943 /*** GLX_SGIX_swap_barrier ***/
946 glXBindSwapBarrierSGIX(Display
*dpy
, GLXDrawable drawable
, int barrier
)
948 struct _glxapi_table
*t
;
949 GET_DISPATCH(dpy
, t
);
952 (*t
->BindSwapBarrierSGIX
)(dpy
, drawable
, barrier
);
956 glXQueryMaxSwapBarriersSGIX(Display
*dpy
, int screen
, int *max
)
958 struct _glxapi_table
*t
;
959 GET_DISPATCH(dpy
, t
);
962 return (*t
->QueryMaxSwapBarriersSGIX
)(dpy
, screen
, max
);
967 /*** GLX_SUN_get_transparent_index ***/
970 glXGetTransparentIndexSUN(Display
*dpy
, Window overlay
, Window underlay
, long *pTransparent
)
972 struct _glxapi_table
*t
;
973 GET_DISPATCH(dpy
, t
);
976 return (*t
->GetTransparentIndexSUN
)(dpy
, overlay
, underlay
, pTransparent
);
981 /*** GLX_MESA_copy_sub_buffer ***/
984 glXCopySubBufferMESA(Display
*dpy
, GLXDrawable drawable
, int x
, int y
, int width
, int height
)
986 struct _glxapi_table
*t
;
987 GET_DISPATCH(dpy
, t
);
990 (t
->CopySubBufferMESA
)(dpy
, drawable
, x
, y
, width
, height
);
995 /*** GLX_MESA_release_buffers ***/
998 glXReleaseBuffersMESA(Display
*dpy
, Window w
)
1000 struct _glxapi_table
*t
;
1001 GET_DISPATCH(dpy
, t
);
1004 return (t
->ReleaseBuffersMESA
)(dpy
, w
);
1009 /*** GLX_MESA_pixmap_colormap ***/
1012 glXCreateGLXPixmapMESA(Display
*dpy
, XVisualInfo
*visinfo
, Pixmap pixmap
, Colormap cmap
)
1014 struct _glxapi_table
*t
;
1015 GET_DISPATCH(dpy
, t
);
1018 return (t
->CreateGLXPixmapMESA
)(dpy
, visinfo
, pixmap
, cmap
);
1023 /*** GLX_MESA_set_3dfx_mode ***/
1026 glXSet3DfxModeMESA(int mode
)
1028 struct _glxapi_table
*t
;
1029 Display
*dpy
= glXGetCurrentDisplay();
1030 GET_DISPATCH(dpy
, t
);
1033 return (t
->Set3DfxModeMESA
)(mode
);
1038 /*** GLX_NV_vertex_array_range ***/
1041 glXAllocateMemoryNV( GLsizei size
,
1042 GLfloat readFrequency
,
1043 GLfloat writeFrequency
,
1046 struct _glxapi_table
*t
;
1047 Display
*dpy
= glXGetCurrentDisplay();
1048 GET_DISPATCH(dpy
, t
);
1051 return (t
->AllocateMemoryNV
)(size
, readFrequency
, writeFrequency
, priority
);
1056 glXFreeMemoryNV( GLvoid
*pointer
)
1058 struct _glxapi_table
*t
;
1059 Display
*dpy
= glXGetCurrentDisplay();
1060 GET_DISPATCH(dpy
, t
);
1063 (t
->FreeMemoryNV
)(pointer
);
1069 /*** GLX_MESA_agp_offset */
1072 glXGetAGPOffsetMESA( const GLvoid
*pointer
)
1074 struct _glxapi_table
*t
;
1075 Display
*dpy
= glXGetCurrentDisplay();
1076 GET_DISPATCH(dpy
, t
);
1079 return (t
->GetAGPOffsetMESA
)(pointer
);
1083 /*** GLX_MESA_allocate_memory */
1086 glXAllocateMemoryMESA(Display
*dpy
, int scrn
, size_t size
,
1087 float readfreq
, float writefreq
, float priority
)
1094 glXFreeMemoryMESA(Display
*dpy
, int scrn
, void *pointer
)
1101 glXGetMemoryOffsetMESA(Display
*dpy
, int scrn
, const void *pointer
)
1108 /*** GLX_EXT_texture_from_pixmap */
1111 glXBindTexImageEXT(Display
*dpy
, GLXDrawable drawable
, int buffer
,
1112 const int *attrib_list
)
1114 struct _glxapi_table
*t
;
1115 GET_DISPATCH(dpy
, t
);
1117 t
->BindTexImageEXT(dpy
, drawable
, buffer
, attrib_list
);
1121 glXReleaseTexImageEXT(Display
*dpy
, GLXDrawable drawable
, int buffer
)
1123 struct _glxapi_table
*t
;
1124 GET_DISPATCH(dpy
, t
);
1126 t
->ReleaseTexImageEXT(dpy
, drawable
, buffer
);
1130 /**********************************************************************/
1131 /* GLX API management functions */
1132 /**********************************************************************/
1136 _glxapi_get_version(void)
1143 * Return array of extension strings.
1146 _glxapi_get_extensions(void)
1148 static const char *extensions
[] = {
1149 #ifdef GLX_EXT_import_context
1150 "GLX_EXT_import_context",
1152 #ifdef GLX_SGI_video_sync
1153 "GLX_SGI_video_sync",
1155 #ifdef GLX_MESA_copy_sub_buffer
1156 "GLX_MESA_copy_sub_buffer",
1158 #ifdef GLX_MESA_release_buffers
1159 "GLX_MESA_release_buffers",
1161 #ifdef GLX_MESA_pixmap_colormap
1162 "GLX_MESA_pixmap_colormap",
1164 #ifdef GLX_MESA_set_3dfx_mode
1165 "GLX_MESA_set_3dfx_mode",
1167 #ifdef GLX_SGIX_fbconfig
1168 "GLX_SGIX_fbconfig",
1170 #ifdef GLX_SGIX_pbuffer
1173 #ifdef GLX_EXT_texture_from_pixmap
1174 "GLX_EXT_texture_from_pixmap",
1176 #ifdef GLX_INTEL_swap_event
1177 "GLX_INTEL_swap_event",
1186 * Return size of the GLX dispatch table, in entries, not bytes.
1189 _glxapi_get_dispatch_table_size(void)
1191 return sizeof(struct _glxapi_table
) / sizeof(void *);
1196 generic_no_op_func(void)
1203 * Initialize all functions in given dispatch table to be no-ops
1206 _glxapi_set_no_op_table(struct _glxapi_table
*t
)
1208 typedef int (*nop_func
)(void);
1209 nop_func
*dispatch
= (nop_func
*) t
;
1210 GLuint n
= _glxapi_get_dispatch_table_size();
1212 for (i
= 0; i
< n
; i
++) {
1213 dispatch
[i
] = generic_no_op_func
;
1218 struct name_address_pair
{
1220 __GLXextFuncPtr Address
;
1223 static struct name_address_pair GLX_functions
[] = {
1224 /*** GLX_VERSION_1_0 ***/
1225 { "glXChooseVisual", (__GLXextFuncPtr
) glXChooseVisual
},
1226 { "glXCopyContext", (__GLXextFuncPtr
) glXCopyContext
},
1227 { "glXCreateContext", (__GLXextFuncPtr
) glXCreateContext
},
1228 { "glXCreateGLXPixmap", (__GLXextFuncPtr
) glXCreateGLXPixmap
},
1229 { "glXDestroyContext", (__GLXextFuncPtr
) glXDestroyContext
},
1230 { "glXDestroyGLXPixmap", (__GLXextFuncPtr
) glXDestroyGLXPixmap
},
1231 { "glXGetConfig", (__GLXextFuncPtr
) glXGetConfig
},
1232 { "glXGetCurrentContext", (__GLXextFuncPtr
) glXGetCurrentContext
},
1233 { "glXGetCurrentDrawable", (__GLXextFuncPtr
) glXGetCurrentDrawable
},
1234 { "glXIsDirect", (__GLXextFuncPtr
) glXIsDirect
},
1235 { "glXMakeCurrent", (__GLXextFuncPtr
) glXMakeCurrent
},
1236 { "glXQueryExtension", (__GLXextFuncPtr
) glXQueryExtension
},
1237 { "glXQueryVersion", (__GLXextFuncPtr
) glXQueryVersion
},
1238 { "glXSwapBuffers", (__GLXextFuncPtr
) glXSwapBuffers
},
1239 { "glXUseXFont", (__GLXextFuncPtr
) glXUseXFont
},
1240 { "glXWaitGL", (__GLXextFuncPtr
) glXWaitGL
},
1241 { "glXWaitX", (__GLXextFuncPtr
) glXWaitX
},
1243 /*** GLX_VERSION_1_1 ***/
1244 { "glXGetClientString", (__GLXextFuncPtr
) glXGetClientString
},
1245 { "glXQueryExtensionsString", (__GLXextFuncPtr
) glXQueryExtensionsString
},
1246 { "glXQueryServerString", (__GLXextFuncPtr
) glXQueryServerString
},
1248 /*** GLX_VERSION_1_2 ***/
1249 { "glXGetCurrentDisplay", (__GLXextFuncPtr
) glXGetCurrentDisplay
},
1251 /*** GLX_VERSION_1_3 ***/
1252 { "glXChooseFBConfig", (__GLXextFuncPtr
) glXChooseFBConfig
},
1253 { "glXCreateNewContext", (__GLXextFuncPtr
) glXCreateNewContext
},
1254 { "glXCreatePbuffer", (__GLXextFuncPtr
) glXCreatePbuffer
},
1255 { "glXCreatePixmap", (__GLXextFuncPtr
) glXCreatePixmap
},
1256 { "glXCreateWindow", (__GLXextFuncPtr
) glXCreateWindow
},
1257 { "glXDestroyPbuffer", (__GLXextFuncPtr
) glXDestroyPbuffer
},
1258 { "glXDestroyPixmap", (__GLXextFuncPtr
) glXDestroyPixmap
},
1259 { "glXDestroyWindow", (__GLXextFuncPtr
) glXDestroyWindow
},
1260 { "glXGetCurrentReadDrawable", (__GLXextFuncPtr
) glXGetCurrentReadDrawable
},
1261 { "glXGetFBConfigAttrib", (__GLXextFuncPtr
) glXGetFBConfigAttrib
},
1262 { "glXGetFBConfigs", (__GLXextFuncPtr
) glXGetFBConfigs
},
1263 { "glXGetSelectedEvent", (__GLXextFuncPtr
) glXGetSelectedEvent
},
1264 { "glXGetVisualFromFBConfig", (__GLXextFuncPtr
) glXGetVisualFromFBConfig
},
1265 { "glXMakeContextCurrent", (__GLXextFuncPtr
) glXMakeContextCurrent
},
1266 { "glXQueryContext", (__GLXextFuncPtr
) glXQueryContext
},
1267 { "glXQueryDrawable", (__GLXextFuncPtr
) glXQueryDrawable
},
1268 { "glXSelectEvent", (__GLXextFuncPtr
) glXSelectEvent
},
1270 /*** GLX_VERSION_1_4 ***/
1271 { "glXGetProcAddress", (__GLXextFuncPtr
) glXGetProcAddress
},
1273 /*** GLX_SGI_swap_control ***/
1274 { "glXSwapIntervalSGI", (__GLXextFuncPtr
) glXSwapIntervalSGI
},
1276 /*** GLX_SGI_video_sync ***/
1277 { "glXGetVideoSyncSGI", (__GLXextFuncPtr
) glXGetVideoSyncSGI
},
1278 { "glXWaitVideoSyncSGI", (__GLXextFuncPtr
) glXWaitVideoSyncSGI
},
1280 /*** GLX_SGI_make_current_read ***/
1281 { "glXMakeCurrentReadSGI", (__GLXextFuncPtr
) glXMakeCurrentReadSGI
},
1282 { "glXGetCurrentReadDrawableSGI", (__GLXextFuncPtr
) glXGetCurrentReadDrawableSGI
},
1284 /*** GLX_SGIX_video_source ***/
1286 { "glXCreateGLXVideoSourceSGIX", (__GLXextFuncPtr
) glXCreateGLXVideoSourceSGIX
},
1287 { "glXDestroyGLXVideoSourceSGIX", (__GLXextFuncPtr
) glXDestroyGLXVideoSourceSGIX
},
1290 /*** GLX_EXT_import_context ***/
1291 { "glXFreeContextEXT", (__GLXextFuncPtr
) glXFreeContextEXT
},
1292 { "glXGetContextIDEXT", (__GLXextFuncPtr
) glXGetContextIDEXT
},
1293 { "glXGetCurrentDisplayEXT", (__GLXextFuncPtr
) glXGetCurrentDisplayEXT
},
1294 { "glXImportContextEXT", (__GLXextFuncPtr
) glXImportContextEXT
},
1295 { "glXQueryContextInfoEXT", (__GLXextFuncPtr
) glXQueryContextInfoEXT
},
1297 /*** GLX_SGIX_fbconfig ***/
1298 { "glXGetFBConfigAttribSGIX", (__GLXextFuncPtr
) glXGetFBConfigAttribSGIX
},
1299 { "glXChooseFBConfigSGIX", (__GLXextFuncPtr
) glXChooseFBConfigSGIX
},
1300 { "glXCreateGLXPixmapWithConfigSGIX", (__GLXextFuncPtr
) glXCreateGLXPixmapWithConfigSGIX
},
1301 { "glXCreateContextWithConfigSGIX", (__GLXextFuncPtr
) glXCreateContextWithConfigSGIX
},
1302 { "glXGetVisualFromFBConfigSGIX", (__GLXextFuncPtr
) glXGetVisualFromFBConfigSGIX
},
1303 { "glXGetFBConfigFromVisualSGIX", (__GLXextFuncPtr
) glXGetFBConfigFromVisualSGIX
},
1305 /*** GLX_SGIX_pbuffer ***/
1306 { "glXCreateGLXPbufferSGIX", (__GLXextFuncPtr
) glXCreateGLXPbufferSGIX
},
1307 { "glXDestroyGLXPbufferSGIX", (__GLXextFuncPtr
) glXDestroyGLXPbufferSGIX
},
1308 { "glXQueryGLXPbufferSGIX", (__GLXextFuncPtr
) glXQueryGLXPbufferSGIX
},
1309 { "glXSelectEventSGIX", (__GLXextFuncPtr
) glXSelectEventSGIX
},
1310 { "glXGetSelectedEventSGIX", (__GLXextFuncPtr
) glXGetSelectedEventSGIX
},
1312 /*** GLX_SGI_cushion ***/
1313 { "glXCushionSGI", (__GLXextFuncPtr
) glXCushionSGI
},
1315 /*** GLX_SGIX_video_resize ***/
1316 { "glXBindChannelToWindowSGIX", (__GLXextFuncPtr
) glXBindChannelToWindowSGIX
},
1317 { "glXChannelRectSGIX", (__GLXextFuncPtr
) glXChannelRectSGIX
},
1318 { "glXQueryChannelRectSGIX", (__GLXextFuncPtr
) glXQueryChannelRectSGIX
},
1319 { "glXQueryChannelDeltasSGIX", (__GLXextFuncPtr
) glXQueryChannelDeltasSGIX
},
1320 { "glXChannelRectSyncSGIX", (__GLXextFuncPtr
) glXChannelRectSyncSGIX
},
1322 /*** GLX_SGIX_dmbuffer **/
1323 #if defined(_DM_BUFFER_H_)
1324 { "glXAssociateDMPbufferSGIX", (__GLXextFuncPtr
) glXAssociateDMPbufferSGIX
},
1327 /*** GLX_SGIX_swap_group ***/
1328 { "glXJoinSwapGroupSGIX", (__GLXextFuncPtr
) glXJoinSwapGroupSGIX
},
1330 /*** GLX_SGIX_swap_barrier ***/
1331 { "glXBindSwapBarrierSGIX", (__GLXextFuncPtr
) glXBindSwapBarrierSGIX
},
1332 { "glXQueryMaxSwapBarriersSGIX", (__GLXextFuncPtr
) glXQueryMaxSwapBarriersSGIX
},
1334 /*** GLX_SUN_get_transparent_index ***/
1335 { "glXGetTransparentIndexSUN", (__GLXextFuncPtr
) glXGetTransparentIndexSUN
},
1337 /*** GLX_MESA_copy_sub_buffer ***/
1338 { "glXCopySubBufferMESA", (__GLXextFuncPtr
) glXCopySubBufferMESA
},
1340 /*** GLX_MESA_pixmap_colormap ***/
1341 { "glXCreateGLXPixmapMESA", (__GLXextFuncPtr
) glXCreateGLXPixmapMESA
},
1343 /*** GLX_MESA_release_buffers ***/
1344 { "glXReleaseBuffersMESA", (__GLXextFuncPtr
) glXReleaseBuffersMESA
},
1346 /*** GLX_MESA_set_3dfx_mode ***/
1347 { "glXSet3DfxModeMESA", (__GLXextFuncPtr
) glXSet3DfxModeMESA
},
1349 /*** GLX_ARB_get_proc_address ***/
1350 { "glXGetProcAddressARB", (__GLXextFuncPtr
) glXGetProcAddressARB
},
1352 /*** GLX_NV_vertex_array_range ***/
1353 { "glXAllocateMemoryNV", (__GLXextFuncPtr
) glXAllocateMemoryNV
},
1354 { "glXFreeMemoryNV", (__GLXextFuncPtr
) glXFreeMemoryNV
},
1356 /*** GLX_MESA_agp_offset ***/
1357 { "glXGetAGPOffsetMESA", (__GLXextFuncPtr
) glXGetAGPOffsetMESA
},
1359 /*** GLX_MESA_allocate_memory ***/
1360 { "glXAllocateMemoryMESA", (__GLXextFuncPtr
) glXAllocateMemoryMESA
},
1361 { "glXFreeMemoryMESA", (__GLXextFuncPtr
) glXFreeMemoryMESA
},
1362 { "glXGetMemoryOffsetMESA", (__GLXextFuncPtr
) glXGetMemoryOffsetMESA
},
1364 /*** GLX_EXT_texture_from_pixmap ***/
1365 { "glXBindTexImageEXT", (__GLXextFuncPtr
) glXBindTexImageEXT
},
1366 { "glXReleaseTexImageEXT", (__GLXextFuncPtr
) glXReleaseTexImageEXT
},
1368 { NULL
, NULL
} /* end of list */
1374 * Return address of named glX function, or NULL if not found.
1377 _glxapi_get_proc_address(const char *funcName
)
1380 for (i
= 0; GLX_functions
[i
].Name
; i
++) {
1382 /* skip the "m" prefix on the name */
1383 if (strcmp(GLX_functions
[i
].Name
, funcName
+1) == 0)
1385 if (strcmp(GLX_functions
[i
].Name
, funcName
) == 0)
1387 return GLX_functions
[i
].Address
;
1395 * This function does not get dispatched through the dispatch table
1396 * since it's really a "meta" function.
1399 glXGetProcAddressARB(const GLubyte
*procName
)
1403 f
= _glxapi_get_proc_address((const char *) procName
);
1408 f
= (__GLXextFuncPtr
) _glapi_get_proc_address((const char *) procName
);
1414 void (*glXGetProcAddress(const GLubyte
*procName
))()
1416 return glXGetProcAddressARB(procName
);