1 /* $Id: glxapi.c,v 1.20 2000/12/15 04:02:50 brianp Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 * This is the GLX API dispatcher. Calls to the glX* functions are
30 * either routed to real (SGI / Utah) GLX encoders or to Mesa's
43 * XXX - this really shouldn't be here.
44 * Instead, add -DUSE_MESA_GLX to the compiler flags when needed.
46 #define USE_MESA_GLX 1
49 /* Rather than include possibly non-existant headers... */
51 extern struct _glxapi_table
*_sgi_GetGLXDispatchtable(void);
54 extern struct _glxapi_table
*_utah_GetGLXDispatchTable(void);
57 extern struct _glxapi_table
*_mesa_GetGLXDispatchTable(void);
62 struct display_dispatch
{
64 struct _glxapi_table
*Table
;
65 struct display_dispatch
*Next
;
68 static struct display_dispatch
*DispatchList
= NULL
;
71 static struct _glxapi_table
*
72 get_dispatch(Display
*dpy
)
74 static Display
*prevDisplay
= NULL
;
75 static struct _glxapi_table
*prevTable
= NULL
;
80 /* try cached display */
81 if (dpy
== prevDisplay
) {
85 /* search list of display/dispatch pairs for this display */
87 const struct display_dispatch
*d
= DispatchList
;
92 return d
->Table
; /* done! */
98 /* A new display, determine if we should use real GLX (SGI / Utah)
99 * or Mesa's pseudo-GLX.
102 struct _glxapi_table
*t
= NULL
;
104 #if defined(USE_SGI_GLX) || defined(USE_UTAH_GLX)
105 if (!getenv("MESA_FORCE_SOFTX")) {
107 if (XQueryExtension( dpy
, "GLX", &ignore
, &ignore
, &ignore
)) {
108 /* the X server has the GLX extension */
109 #if defined(USE_SGI_GLX)
110 t
= _sgi_GetGLXDispatchtable();
111 #elif defined(USE_UTAH_GLX)
112 t
= _utah_GetGLXDispatchTable();
118 #if defined(USE_MESA_GLX)
120 t
= _mesa_GetGLXDispatchTable();
121 assert(t
); /* this has to work */
126 struct display_dispatch
*d
;
127 d
= (struct display_dispatch
*) malloc(sizeof(struct display_dispatch
));
131 /* insert at head of list */
132 d
->Next
= DispatchList
;
142 /* If we get here that means we can't use real GLX on this display
143 * and the Mesa pseudo-GLX software renderer wasn't compiled in.
144 * Or, we ran out of memory!
151 /* Set by glXMakeCurrent() and glXMakeContextCurrent() only */
152 static Display
*CurrentDisplay
= NULL
;
153 static GLXContext CurrentContext
= 0;
154 static GLXDrawable CurrentDrawable
= 0;
155 static GLXDrawable CurrentReadDrawable
= 0;
160 * GLX API entrypoints
164 XVisualInfo
*glXChooseVisual(Display
*dpy
, int screen
, int *list
)
166 struct _glxapi_table
*t
= get_dispatch(dpy
);
169 return (t
->ChooseVisual
)(dpy
, screen
, list
);
173 void glXCopyContext(Display
*dpy
, GLXContext src
, GLXContext dst
, unsigned long mask
)
175 struct _glxapi_table
*t
= get_dispatch(dpy
);
178 (t
->CopyContext
)(dpy
, src
, dst
, mask
);
182 GLXContext
glXCreateContext(Display
*dpy
, XVisualInfo
*visinfo
, GLXContext shareList
, Bool direct
)
184 struct _glxapi_table
*t
= get_dispatch(dpy
);
187 return (t
->CreateContext
)(dpy
, visinfo
, shareList
, direct
);
191 GLXPixmap
glXCreateGLXPixmap(Display
*dpy
, XVisualInfo
*visinfo
, Pixmap pixmap
)
193 struct _glxapi_table
*t
= get_dispatch(dpy
);
196 return (t
->CreateGLXPixmap
)(dpy
, visinfo
, pixmap
);
200 void glXDestroyContext(Display
*dpy
, GLXContext ctx
)
202 struct _glxapi_table
*t
= get_dispatch(dpy
);
205 (t
->DestroyContext
)(dpy
, ctx
);
209 void glXDestroyGLXPixmap(Display
*dpy
, GLXPixmap pixmap
)
211 struct _glxapi_table
*t
= get_dispatch(dpy
);
214 (t
->DestroyGLXPixmap
)(dpy
, pixmap
);
218 int glXGetConfig(Display
*dpy
, XVisualInfo
*visinfo
, int attrib
, int *value
)
220 struct _glxapi_table
*t
= get_dispatch(dpy
);
222 return GLX_NO_EXTENSION
;
223 return (t
->GetConfig
)(dpy
, visinfo
, attrib
, value
);
227 GLXContext
glXGetCurrentContext(void)
229 return CurrentContext
;
233 GLXDrawable
glXGetCurrentDrawable(void)
235 return CurrentDrawable
;
239 Bool
glXIsDirect(Display
*dpy
, GLXContext ctx
)
241 struct _glxapi_table
*t
= get_dispatch(dpy
);
244 return (t
->IsDirect
)(dpy
, ctx
);
248 Bool
glXMakeCurrent(Display
*dpy
, GLXDrawable drawable
, GLXContext ctx
)
251 struct _glxapi_table
*t
= get_dispatch(dpy
);
254 b
= (*t
->MakeCurrent
)(dpy
, drawable
, ctx
);
256 CurrentDisplay
= dpy
;
257 CurrentContext
= ctx
;
258 CurrentDrawable
= drawable
;
259 CurrentReadDrawable
= drawable
;
265 Bool
glXQueryExtension(Display
*dpy
, int *errorb
, int *event
)
267 struct _glxapi_table
*t
= get_dispatch(dpy
);
270 return (t
->QueryExtension
)(dpy
, errorb
, event
);
274 Bool
glXQueryVersion(Display
*dpy
, int *maj
, int *min
)
276 struct _glxapi_table
*t
= get_dispatch(dpy
);
279 return (t
->QueryVersion
)(dpy
, maj
, min
);
283 void glXSwapBuffers(Display
*dpy
, GLXDrawable drawable
)
285 struct _glxapi_table
*t
= get_dispatch(dpy
);
288 (t
->SwapBuffers
)(dpy
, drawable
);
292 void glXUseXFont(Font font
, int first
, int count
, int listBase
)
294 struct _glxapi_table
*t
= get_dispatch(CurrentDisplay
);
297 (t
->UseXFont
)(font
, first
, count
, listBase
);
303 struct _glxapi_table
*t
= get_dispatch(CurrentDisplay
);
312 struct _glxapi_table
*t
= get_dispatch(CurrentDisplay
);
320 #ifdef GLX_VERSION_1_1
322 const char *glXGetClientString(Display
*dpy
, int name
)
324 struct _glxapi_table
*t
= get_dispatch(dpy
);
327 return (t
->GetClientString
)(dpy
, name
);
331 const char *glXQueryExtensionsString(Display
*dpy
, int screen
)
333 struct _glxapi_table
*t
= get_dispatch(dpy
);
336 return (t
->QueryExtensionsString
)(dpy
, screen
);
340 const char *glXQueryServerString(Display
*dpy
, int screen
, int name
)
342 struct _glxapi_table
*t
= get_dispatch(dpy
);
345 return (t
->QueryServerString
)(dpy
, screen
, name
);
352 #ifdef GLX_VERSION_1_2
353 Display
*glXGetCurrentDisplay(void)
355 return CurrentDisplay
;
361 #ifdef GLX_VERSION_1_3
363 GLXFBConfig
*glXChooseFBConfig(Display
*dpy
, int screen
, const int *attribList
, int *nitems
)
365 struct _glxapi_table
*t
= get_dispatch(dpy
);
368 return (t
->ChooseFBConfig
)(dpy
, screen
, attribList
, nitems
);
372 GLXContext
glXCreateNewContext(Display
*dpy
, GLXFBConfig config
, int renderType
, GLXContext shareList
, Bool direct
)
374 struct _glxapi_table
*t
= get_dispatch(dpy
);
377 return (t
->CreateNewContext
)(dpy
, config
, renderType
, shareList
, direct
);
381 GLXPbuffer
glXCreatePbuffer(Display
*dpy
, GLXFBConfig config
, const int *attribList
)
383 struct _glxapi_table
*t
= get_dispatch(dpy
);
386 return (t
->CreatePbuffer
)(dpy
, config
, attribList
);
390 GLXPixmap
glXCreatePixmap(Display
*dpy
, GLXFBConfig config
, Pixmap pixmap
, const int *attribList
)
392 struct _glxapi_table
*t
= get_dispatch(dpy
);
395 return (t
->CreatePixmap
)(dpy
, config
, pixmap
, attribList
);
399 GLXWindow
glXCreateWindow(Display
*dpy
, GLXFBConfig config
, Window win
, const int *attribList
)
401 struct _glxapi_table
*t
= get_dispatch(dpy
);
404 return (t
->CreateWindow
)(dpy
, config
, win
, attribList
);
408 void glXDestroyPbuffer(Display
*dpy
, GLXPbuffer pbuf
)
410 struct _glxapi_table
*t
= get_dispatch(dpy
);
413 (t
->DestroyPbuffer
)(dpy
, pbuf
);
417 void glXDestroyPixmap(Display
*dpy
, GLXPixmap pixmap
)
419 struct _glxapi_table
*t
= get_dispatch(dpy
);
422 (t
->DestroyPixmap
)(dpy
, pixmap
);
426 void glXDestroyWindow(Display
*dpy
, GLXWindow window
)
428 struct _glxapi_table
*t
= get_dispatch(dpy
);
431 (t
->DestroyWindow
)(dpy
, window
);
435 GLXDrawable
glXGetCurrentReadDrawable(void)
437 return CurrentReadDrawable
;
441 int glXGetFBConfigAttrib(Display
*dpy
, GLXFBConfig config
, int attribute
, int *value
)
443 struct _glxapi_table
*t
= get_dispatch(dpy
);
445 return GLX_NO_EXTENSION
;
446 return (t
->GetFBConfigAttrib
)(dpy
, config
, attribute
, value
);
450 GLXFBConfig
*glXGetFBConfigs(Display
*dpy
, int screen
, int *nelements
)
452 struct _glxapi_table
*t
= get_dispatch(dpy
);
455 return (t
->GetFBConfigs
)(dpy
, screen
, nelements
);
458 void glXGetSelectedEvent(Display
*dpy
, GLXDrawable drawable
, unsigned long *mask
)
460 struct _glxapi_table
*t
= get_dispatch(dpy
);
463 (t
->GetSelectedEvent
)(dpy
, drawable
, mask
);
467 XVisualInfo
*glXGetVisualFromFBConfig(Display
*dpy
, GLXFBConfig config
)
469 struct _glxapi_table
*t
= get_dispatch(dpy
);
472 return (t
->GetVisualFromFBConfig
)(dpy
, config
);
476 Bool
glXMakeContextCurrent(Display
*dpy
, GLXDrawable draw
, GLXDrawable read
, GLXContext ctx
)
478 struct _glxapi_table
*t
= get_dispatch(dpy
);
482 b
= (t
->MakeContextCurrent
)(dpy
, draw
, read
, ctx
);
484 CurrentDisplay
= dpy
;
485 CurrentContext
= ctx
;
486 CurrentDrawable
= draw
;
487 CurrentReadDrawable
= read
;
493 int glXQueryContext(Display
*dpy
, GLXContext ctx
, int attribute
, int *value
)
495 struct _glxapi_table
*t
= get_dispatch(dpy
);
498 return 0; /* XXX correct? */
499 return (t
->QueryContext
)(dpy
, ctx
, attribute
, value
);
503 void glXQueryDrawable(Display
*dpy
, GLXDrawable draw
, int attribute
, unsigned int *value
)
505 struct _glxapi_table
*t
= get_dispatch(dpy
);
508 (t
->QueryDrawable
)(dpy
, draw
, attribute
, value
);
512 void glXSelectEvent(Display
*dpy
, GLXDrawable drawable
, unsigned long mask
)
514 struct _glxapi_table
*t
= get_dispatch(dpy
);
517 (t
->SelectEvent
)(dpy
, drawable
, mask
);
520 #endif /* GLX_VERSION_1_3 */
523 #ifdef GLX_SGI_swap_control
525 int glXSwapIntervalSGI(int interval
)
527 struct _glxapi_table
*t
= get_dispatch(CurrentDisplay
);
530 return (t
->SwapIntervalSGI
)(interval
);
536 #ifdef GLX_SGI_video_sync
538 int glXGetVideoSyncSGI(unsigned int *count
)
540 struct _glxapi_table
*t
= get_dispatch(CurrentDisplay
);
543 return (t
->GetVideoSyncSGI
)(count
);
546 int glXWaitVideoSyncSGI(int divisor
, int remainder
, unsigned int *count
)
548 struct _glxapi_table
*t
= get_dispatch(CurrentDisplay
);
551 return (t
->WaitVideoSyncSGI
)(divisor
, remainder
, count
);
557 #ifdef GLX_SGI_make_current_read
559 Bool
glXMakeCurrentReadSGI(Display
*dpy
, GLXDrawable draw
, GLXDrawable read
, GLXContext ctx
)
561 struct _glxapi_table
*t
= get_dispatch(dpy
);
564 return (t
->MakeCurrentReadSGI
)(dpy
, draw
, read
, ctx
);
567 GLXDrawable
glXGetCurrentReadDrawableSGI(void)
569 struct _glxapi_table
*t
= get_dispatch(CurrentDisplay
);
572 return (t
->GetCurrentReadDrawableSGI
)();
578 #if defined(_VL_H) && defined(GLX_SGIX_video_source)
580 GLXVideoSourceSGIX
glXCreateGLXVideoSourceSGIX(Display
*dpy
, int screen
, VLServer server
, VLPath path
, int nodeClass
, VLNode drainNode
)
582 struct _glxapi_table
*t
= get_dispatch(dpy
);
585 return (t
->CreateGLXVideoSourceSGIX
)(dpy
, screen
, server
, path
, nodeClass
, drainNode
);
588 void glXDestroyGLXVideoSourceSGIX(Display
*dpy
, GLXVideoSourceSGIX src
)
590 struct _glxapi_table
*t
= get_dispatch(dpy
);
593 return (t
->DestroyGLXVideoSourceSGIX
)(dpy
, src
);
599 #ifdef GLX_EXT_import_context
601 void glXFreeContextEXT(Display
*dpy
, GLXContext context
)
603 struct _glxapi_table
*t
= get_dispatch(dpy
);
606 (t
->FreeContextEXT
)(dpy
, context
);
609 GLXContextID
glXGetContextIDEXT(const GLXContext context
)
611 /* XXX is this function right? */
612 struct _glxapi_table
*t
= get_dispatch(CurrentDisplay
);
615 return (t
->GetContextIDEXT
)(context
);
618 Display
*glXGetCurrentDisplayEXT(void)
620 return CurrentDisplay
;
623 GLXContext
glXImportContextEXT(Display
*dpy
, GLXContextID contextID
)
625 struct _glxapi_table
*t
= get_dispatch(dpy
);
628 return (t
->ImportContextEXT
)(dpy
, contextID
);
631 int glXQueryContextInfoEXT(Display
*dpy
, GLXContext context
, int attribute
,int *value
)
633 struct _glxapi_table
*t
= get_dispatch(dpy
);
635 return 0; /* XXX ok? */
636 return (t
->QueryContextInfoEXT
)(dpy
, context
, attribute
, value
);
642 #ifdef GLX_SGIX_fbconfig
644 int glXGetFBConfigAttribSGIX(Display
*dpy
, GLXFBConfigSGIX config
, int attribute
, int *value
)
646 struct _glxapi_table
*t
= get_dispatch(dpy
);
649 return (t
->GetFBConfigAttribSGIX
)(dpy
, config
, attribute
, value
);
652 GLXFBConfigSGIX
*glXChooseFBConfigSGIX(Display
*dpy
, int screen
, int *attrib_list
, int *nelements
)
654 struct _glxapi_table
*t
= get_dispatch(dpy
);
657 return (t
->ChooseFBConfigSGIX
)(dpy
, screen
, attrib_list
, nelements
);
660 GLXPixmap
glXCreateGLXPixmapWithConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
, Pixmap pixmap
)
662 struct _glxapi_table
*t
= get_dispatch(dpy
);
665 return (t
->CreateGLXPixmapWithConfigSGIX
)(dpy
, config
, pixmap
);
668 GLXContext
glXCreateContextWithConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
, int render_type
, GLXContext share_list
, Bool direct
)
670 struct _glxapi_table
*t
= get_dispatch(dpy
);
673 return (t
->CreateContextWithConfigSGIX
)(dpy
, config
, render_type
, share_list
, direct
);
676 XVisualInfo
* glXGetVisualFromFBConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
)
678 struct _glxapi_table
*t
= get_dispatch(dpy
);
681 return (t
->GetVisualFromFBConfigSGIX
)(dpy
, config
);
684 GLXFBConfigSGIX
glXGetFBConfigFromVisualSGIX(Display
*dpy
, XVisualInfo
*vis
)
686 struct _glxapi_table
*t
= get_dispatch(dpy
);
689 return (t
->GetFBConfigFromVisualSGIX
)(dpy
, vis
);
695 #ifdef GLX_SGIX_pbuffer
697 GLXPbufferSGIX
glXCreateGLXPbufferSGIX(Display
*dpy
, GLXFBConfigSGIX config
, unsigned int width
, unsigned int height
, int *attrib_list
)
699 struct _glxapi_table
*t
= get_dispatch(dpy
);
702 return (t
->CreateGLXPbufferSGIX
)(dpy
, config
, width
, height
, attrib_list
);
705 void glXDestroyGLXPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuf
)
707 struct _glxapi_table
*t
= get_dispatch(dpy
);
710 (t
->DestroyGLXPbufferSGIX
)(dpy
, pbuf
);
713 int glXQueryGLXPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuf
, int attribute
, unsigned int *value
)
715 struct _glxapi_table
*t
= get_dispatch(dpy
);
718 return (t
->QueryGLXPbufferSGIX
)(dpy
, pbuf
, attribute
, value
);
721 void glXSelectEventSGIX(Display
*dpy
, GLXDrawable drawable
, unsigned long mask
)
723 struct _glxapi_table
*t
= get_dispatch(dpy
);
726 (t
->SelectEventSGIX
)(dpy
, drawable
, mask
);
729 void glXGetSelectedEventSGIX(Display
*dpy
, GLXDrawable drawable
, unsigned long *mask
)
731 struct _glxapi_table
*t
= get_dispatch(dpy
);
734 (t
->GetSelectedEventSGIX
)(dpy
, drawable
, mask
);
740 #ifdef GLX_SGI_cushion
742 void glXCushionSGI(Display
*dpy
, Window win
, float cushion
)
744 struct _glxapi_table
*t
= get_dispatch(dpy
);
747 (t
->CushionSGI
)(dpy
, win
, cushion
);
753 #ifdef GLX_SGIX_video_resize
755 int glXBindChannelToWindowSGIX(Display
*dpy
, int screen
, int channel
, Window window
)
757 struct _glxapi_table
*t
= get_dispatch(dpy
);
760 return (t
->BindChannelToWindowSGIX
)(dpy
, screen
, channel
, window
);
763 int glXChannelRectSGIX(Display
*dpy
, int screen
, int channel
, int x
, int y
, int w
, int h
)
765 struct _glxapi_table
*t
= get_dispatch(dpy
);
768 return (t
->ChannelRectSGIX
)(dpy
, screen
, channel
, x
, y
, w
, h
);
771 int glXQueryChannelRectSGIX(Display
*dpy
, int screen
, int channel
, int *x
, int *y
, int *w
, int *h
)
773 struct _glxapi_table
*t
= get_dispatch(dpy
);
776 return (t
->QueryChannelRectSGIX
)(dpy
, screen
, channel
, x
, y
, w
, h
);
779 int glXQueryChannelDeltasSGIX(Display
*dpy
, int screen
, int channel
, int *dx
, int *dy
, int *dw
, int *dh
)
781 struct _glxapi_table
*t
= get_dispatch(dpy
);
784 return (t
->QueryChannelDeltasSGIX
)(dpy
, screen
, channel
, dx
, dy
, dw
, dh
);
787 int glXChannelRectSyncSGIX(Display
*dpy
, int screen
, int channel
, GLenum synctype
)
789 struct _glxapi_table
*t
= get_dispatch(dpy
);
792 return (t
->ChannelRectSyncSGIX
)(dpy
, screen
, channel
, synctype
);
798 #if defined(_DM_BUFFER_H_) && defined(GLX_SGIX_dmbuffer)
800 Bool
glXAssociateDMPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuffer
, DMparams
*params
, DMbuffer dmbuffer
)
802 struct _glxapi_table
*t
= get_dispatch(dpy
);
805 return (t
->AssociateDMPbufferSGIX
)(dpy
, pbuffer
, params
, dmbuffer
);
811 #ifdef GLX_SGIX_swap_group
813 void glXJoinSwapGroupSGIX(Display
*dpy
, GLXDrawable drawable
, GLXDrawable member
)
815 struct _glxapi_table
*t
= get_dispatch(dpy
);
818 (*t
->JoinSwapGroupSGIX
)(dpy
, drawable
, member
);
824 #ifdef GLX_SGIX_swap_barrier
826 void glXBindSwapBarrierSGIX(Display
*dpy
, GLXDrawable drawable
, int barrier
)
828 struct _glxapi_table
*t
= get_dispatch(dpy
);
831 (*t
->BindSwapBarrierSGIX
)(dpy
, drawable
, barrier
);
834 Bool
glXQueryMaxSwapBarriersSGIX(Display
*dpy
, int screen
, int *max
)
836 struct _glxapi_table
*t
= get_dispatch(dpy
);
839 return (*t
->QueryMaxSwapBarriersSGIX
)(dpy
, screen
, max
);
845 #ifdef GLX_SUN_get_transparent_index
847 Status
glXGetTransparentIndexSUN(Display
*dpy
, Window overlay
, Window underlay
, long *pTransparent
)
849 struct _glxapi_table
*t
= get_dispatch(dpy
);
852 return (*t
->GetTransparentIndexSUN
)(dpy
, overlay
, underlay
, pTransparent
);
858 #ifdef GLX_MESA_copy_sub_buffer
860 void glXCopySubBufferMESA(Display
*dpy
, GLXDrawable drawable
, int x
, int y
, int width
, int height
)
862 struct _glxapi_table
*t
= get_dispatch(dpy
);
865 (t
->CopySubBufferMESA
)(dpy
, drawable
, x
, y
, width
, height
);
871 #ifdef GLX_MESA_release_buffers
873 Bool
glXReleaseBuffersMESA(Display
*dpy
, Window w
)
875 struct _glxapi_table
*t
= get_dispatch(dpy
);
878 return (t
->ReleaseBuffersMESA
)(dpy
, w
);
884 #ifdef GLX_MESA_pixmap_colormap
886 GLXPixmap
glXCreateGLXPixmapMESA(Display
*dpy
, XVisualInfo
*visinfo
, Pixmap pixmap
, Colormap cmap
)
888 struct _glxapi_table
*t
= get_dispatch(dpy
);
891 return (t
->CreateGLXPixmapMESA
)(dpy
, visinfo
, pixmap
, cmap
);
897 #ifdef GLX_MESA_set_3dfx_mode
899 Bool
glXSet3DfxModeMESA(int mode
)
901 struct _glxapi_table
*t
= get_dispatch(CurrentDisplay
);
904 return (t
->Set3DfxModeMESA
)(mode
);
911 /**********************************************************************/
912 /* GLX API management functions */
913 /**********************************************************************/
917 _glxapi_get_version(void)
924 * Return array of extension strings.
927 _glxapi_get_extensions(void)
929 static const char *extensions
[] = {
930 #ifdef GLX_EXT_import_context
931 "GLX_EXT_import_context",
933 #ifdef GLX_SGI_video_sync
934 "GLX_SGI_video_sync",
936 #ifdef GLX_MESA_copy_sub_buffer
937 "GLX_MESA_copy_sub_buffer",
939 #ifdef GLX_MESA_release_buffers
940 "GLX_MESA_release_buffers",
942 #ifdef GLX_MESA_pixmap_colormap
943 "GLX_MESA_pixmap_colormap",
945 #ifdef GLX_MESA_set_3dfx_mode
946 "GLX_MESA_set_3dfx_mode",
955 * Return size of the GLX dispatch table, in entries, not bytes.
958 _glxapi_get_dispatch_table_size(void)
960 return sizeof(struct _glxapi_table
) / sizeof(void *);
965 generic_no_op_func(void)
972 * Initialize all functions in given dispatch table to be no-ops
975 _glxapi_set_no_op_table(struct _glxapi_table
*t
)
977 GLuint n
= _glxapi_get_dispatch_table_size();
979 void **dispatch
= (void **) t
;
980 for (i
= 0; i
< n
; i
++) {
981 dispatch
[i
] = (void *) generic_no_op_func
;
987 struct name_address_pair
{
992 static struct name_address_pair GLX_functions
[] = {
993 { "glXChooseVisual", (GLvoid
*) glXChooseVisual
},
994 { "glXCopyContext", (GLvoid
*) glXCopyContext
},
995 { "glXCreateContext", (GLvoid
*) glXCreateContext
},
996 { "glXCreateGLXPixmap", (GLvoid
*) glXCreateGLXPixmap
},
997 { "glXDestroyContext", (GLvoid
*) glXDestroyContext
},
998 { "glXDestroyGLXPixmap", (GLvoid
*) glXDestroyGLXPixmap
},
999 { "glXGetConfig", (GLvoid
*) glXGetConfig
},
1000 { "glXGetCurrentContext", (GLvoid
*) glXGetCurrentContext
},
1001 { "glXGetCurrentDrawable", (GLvoid
*) glXGetCurrentDrawable
},
1002 { "glXIsDirect", (GLvoid
*) glXIsDirect
},
1003 { "glXMakeCurrent", (GLvoid
*) glXMakeCurrent
},
1004 { "glXQueryExtension", (GLvoid
*) glXQueryExtension
},
1005 { "glXQueryVersion", (GLvoid
*) glXQueryVersion
},
1006 { "glXSwapBuffers", (GLvoid
*) glXSwapBuffers
},
1007 { "glXUseXFont", (GLvoid
*) glXUseXFont
},
1008 { "glXWaitGL", (GLvoid
*) glXWaitGL
},
1009 { "glXWaitX", (GLvoid
*) glXWaitX
},
1011 #ifdef GLX_VERSION_1_1
1012 { "glXGetClientString", (GLvoid
*) glXGetClientString
},
1013 { "glXQueryExtensionsString", (GLvoid
*) glXQueryExtensionsString
},
1014 { "glXQueryServerString", (GLvoid
*) glXQueryServerString
},
1017 #ifdef GLX_VERSION_1_2
1018 { "glXGetCurrentDisplay", (GLvoid
*) glXGetCurrentDisplay
},
1021 #ifdef GLX_VERSION_1_3
1022 { "glXChooseFBConfig", (GLvoid
*) glXChooseFBConfig
},
1023 { "glXCreateNewContext", (GLvoid
*) glXCreateNewContext
},
1024 { "glXCreatePbuffer", (GLvoid
*) glXCreatePbuffer
},
1025 { "glXCreatePixmap", (GLvoid
*) glXCreatePixmap
},
1026 { "glXCreateWindow", (GLvoid
*) glXCreateWindow
},
1027 { "glXDestroyPbuffer", (GLvoid
*) glXDestroyPbuffer
},
1028 { "glXDestroyPixmap", (GLvoid
*) glXDestroyPixmap
},
1029 { "glXDestroyWindow", (GLvoid
*) glXDestroyWindow
},
1030 { "glXGetCurrentReadDrawable", (GLvoid
*) glXGetCurrentReadDrawable
},
1031 { "glXGetFBConfigAttrib", (GLvoid
*) glXGetFBConfigAttrib
},
1032 { "glXGetSelectedEvent", (GLvoid
*) glXGetSelectedEvent
},
1033 { "glXGetVisualFromFBConfig", (GLvoid
*) glXGetVisualFromFBConfig
},
1034 { "glXMakeContextCurrent", (GLvoid
*) glXMakeContextCurrent
},
1035 { "glXQueryContext", (GLvoid
*) glXQueryContext
},
1036 { "glXQueryDrawable", (GLvoid
*) glXQueryDrawable
},
1037 { "glXSelectEvent", (GLvoid
*) glXSelectEvent
},
1040 #ifdef GLX_SGI_video_sync
1041 { "glXGetVideoSyncSGI", (GLvoid
*) glXGetVideoSyncSGI
},
1042 { "glXWaitVideoSyncSGI", (GLvoid
*) glXWaitVideoSyncSGI
},
1045 #ifdef GLX_MESA_copy_sub_buffer
1046 { "glXCopySubBufferMESA", (GLvoid
*) glXCopySubBufferMESA
},
1049 #ifdef GLX_MESA_release_buffers
1050 { "glXReleaseBuffersMESA", (GLvoid
*) glXReleaseBuffersMESA
},
1053 #ifdef GLX_MESA_pixmap_colormap
1054 { "glXCreateGLXPixmapMESA", (GLvoid
*) glXCreateGLXPixmapMESA
},
1057 #ifdef GLX_MESA_set_3dfx_mode
1058 { "glXSet3DfxModeMESA", (GLvoid
*) glXSet3DfxModeMESA
},
1061 { "glXGetProcAddressARB", (GLvoid
*) glXGetProcAddressARB
},
1063 { NULL
, NULL
} /* end of list */
1069 * Return address of named glX function, or NULL if not found.
1072 _glxapi_get_proc_address(const char *funcName
)
1075 for (i
= 0; GLX_functions
[i
].Name
; i
++) {
1076 if (strcmp(GLX_functions
[i
].Name
, funcName
) == 0)
1077 return GLX_functions
[i
].Address
;
1085 * This function does not get dispatched through the dispatch table
1086 * since it's really a "meta" function.
1088 void (*glXGetProcAddressARB(const GLubyte
*procName
))()
1090 typedef void (*gl_function
)();
1093 f
= (gl_function
) _glxapi_get_proc_address((const char *) procName
);
1098 f
= (gl_function
) _glapi_get_proc_address((const char *) procName
);