1 /* $Id: glxapi.c,v 1.29 2002/03/15 18:33:12 brianp Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2001 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 the real GLX encoders or to Mesa's pseudo-GLX functions.
31 * See the glxapi.h file for more details.
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
= NULL
;
86 #ifdef GLX_BUILT_IN_XMESA
87 if (!getenv("LIBGL_FORCE_XMESA")) {
89 if (XQueryExtension( dpy
, "GLX", &ignore
, &ignore
, &ignore
)) {
90 /* the X server has the GLX extension */
91 t
= _real_GetGLXDispatchTable();
97 /* Fallback to Mesa with Xlib driver */
98 #ifdef GLX_BUILT_IN_XMESA
99 if (getenv("LIBGL_DEBUG")) {
101 "libGL: server %s lacks the GLX extension.",
103 fprintf(stderr
, " Using Mesa Xlib renderer.\n");
106 t
= _mesa_GetGLXDispatchTable();
107 assert(t
); /* this has to work */
111 struct display_dispatch
*d
;
112 d
= (struct display_dispatch
*) malloc(sizeof(struct display_dispatch
));
116 /* insert at head of list */
117 d
->Next
= DispatchList
;
127 /* If we get here that means we can't use real GLX on this display
128 * and the Mesa pseudo-GLX software renderer wasn't compiled in.
129 * Or, we ran out of memory!
135 #define GET_DISPATCH(DPY, TABLE) \
136 if (DPY == prevDisplay) { \
143 TABLE = get_dispatch(DPY); \
149 /* Set by glXMakeCurrent() and glXMakeContextCurrent() only */
150 #ifndef GLX_BUILT_IN_XMESA
151 static GLXContext CurrentContext
= 0;
152 #define __glXGetCurrentContext() CurrentContext;
157 * GLX API entrypoints
160 /*** GLX_VERSION_1_0 ***/
162 XVisualInfo
*glXChooseVisual(Display
*dpy
, int screen
, int *list
)
164 struct _glxapi_table
*t
;
165 GET_DISPATCH(dpy
, t
);
168 return (t
->ChooseVisual
)(dpy
, screen
, list
);
172 void 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
);
182 GLXContext
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
);
192 GLXPixmap
glXCreateGLXPixmap(Display
*dpy
, XVisualInfo
*visinfo
, Pixmap pixmap
)
194 struct _glxapi_table
*t
;
195 GET_DISPATCH(dpy
, t
);
198 return (t
->CreateGLXPixmap
)(dpy
, visinfo
, pixmap
);
202 void glXDestroyContext(Display
*dpy
, GLXContext ctx
)
204 struct _glxapi_table
*t
;
205 GET_DISPATCH(dpy
, t
);
208 (t
->DestroyContext
)(dpy
, ctx
);
212 void glXDestroyGLXPixmap(Display
*dpy
, GLXPixmap pixmap
)
214 struct _glxapi_table
*t
;
215 GET_DISPATCH(dpy
, t
);
218 (t
->DestroyGLXPixmap
)(dpy
, pixmap
);
222 int glXGetConfig(Display
*dpy
, XVisualInfo
*visinfo
, int attrib
, int *value
)
224 struct _glxapi_table
*t
;
225 GET_DISPATCH(dpy
, t
);
227 return GLX_NO_EXTENSION
;
228 return (t
->GetConfig
)(dpy
, visinfo
, attrib
, value
);
232 #ifdef GLX_BUILT_IN_XMESA
233 /* Use real libGL's glXGetCurrentContext() function */
235 /* stand-alone Mesa */
236 GLXContext
glXGetCurrentContext(void)
238 return CurrentContext
;
243 #ifdef GLX_BUILT_IN_XMESA
244 /* Use real libGL's glXGetCurrentContext() function */
246 /* stand-alone Mesa */
247 GLXDrawable
glXGetCurrentDrawable(void)
249 __GLXcontext
*gc
= (__GLXcontext
*) glXGetCurrentContext();
250 return gc
? gc
->currentDrawable
: 0;
255 Bool
glXIsDirect(Display
*dpy
, GLXContext ctx
)
257 struct _glxapi_table
*t
;
258 GET_DISPATCH(dpy
, t
);
261 return (t
->IsDirect
)(dpy
, ctx
);
265 Bool
glXMakeCurrent(Display
*dpy
, GLXDrawable drawable
, GLXContext ctx
)
268 struct _glxapi_table
*t
;
269 GET_DISPATCH(dpy
, t
);
273 b
= (*t
->MakeCurrent
)(dpy
, drawable
, ctx
);
274 #ifndef GLX_BUILT_IN_XMESA
276 CurrentContext
= ctx
;
283 Bool
glXQueryExtension(Display
*dpy
, int *errorb
, int *event
)
285 struct _glxapi_table
*t
;
286 GET_DISPATCH(dpy
, t
);
289 return (t
->QueryExtension
)(dpy
, errorb
, event
);
293 Bool
glXQueryVersion(Display
*dpy
, int *maj
, int *min
)
295 struct _glxapi_table
*t
;
296 GET_DISPATCH(dpy
, t
);
299 return (t
->QueryVersion
)(dpy
, maj
, min
);
303 void glXSwapBuffers(Display
*dpy
, GLXDrawable drawable
)
305 struct _glxapi_table
*t
;
306 GET_DISPATCH(dpy
, t
);
309 (t
->SwapBuffers
)(dpy
, drawable
);
313 void glXUseXFont(Font font
, int first
, int count
, int listBase
)
315 struct _glxapi_table
*t
;
316 Display
*dpy
= glXGetCurrentDisplay();
317 GET_DISPATCH(dpy
, t
);
320 (t
->UseXFont
)(font
, first
, count
, listBase
);
326 struct _glxapi_table
*t
;
327 Display
*dpy
= glXGetCurrentDisplay();
328 GET_DISPATCH(dpy
, t
);
337 struct _glxapi_table
*t
;
338 Display
*dpy
= glXGetCurrentDisplay();
339 GET_DISPATCH(dpy
, t
);
347 /*** GLX_VERSION_1_1 ***/
349 const char *glXGetClientString(Display
*dpy
, int name
)
351 struct _glxapi_table
*t
;
352 GET_DISPATCH(dpy
, t
);
355 return (t
->GetClientString
)(dpy
, name
);
359 const char *glXQueryExtensionsString(Display
*dpy
, int screen
)
361 struct _glxapi_table
*t
;
362 GET_DISPATCH(dpy
, t
);
365 return (t
->QueryExtensionsString
)(dpy
, screen
);
369 const char *glXQueryServerString(Display
*dpy
, int screen
, int name
)
371 struct _glxapi_table
*t
;
372 GET_DISPATCH(dpy
, t
);
375 return (t
->QueryServerString
)(dpy
, screen
, name
);
379 /*** GLX_VERSION_1_2 ***/
381 #if !defined(GLX_BUILT_IN_XMESA)
382 Display
*glXGetCurrentDisplay(void)
384 /* Same code as in libGL's glxext.c */
385 __GLXcontext
*gc
= (__GLXcontext
*) glXGetCurrentContext();
386 if (NULL
== gc
) return NULL
;
387 return gc
->currentDpy
;
393 /*** GLX_VERSION_1_3 ***/
395 GLXFBConfig
*glXChooseFBConfig(Display
*dpy
, int screen
, const int *attribList
, int *nitems
)
397 struct _glxapi_table
*t
;
398 GET_DISPATCH(dpy
, t
);
401 return (t
->ChooseFBConfig
)(dpy
, screen
, attribList
, nitems
);
405 GLXContext
glXCreateNewContext(Display
*dpy
, GLXFBConfig config
, int renderType
, GLXContext shareList
, Bool direct
)
407 struct _glxapi_table
*t
;
408 GET_DISPATCH(dpy
, t
);
411 return (t
->CreateNewContext
)(dpy
, config
, renderType
, shareList
, direct
);
415 GLXPbuffer
glXCreatePbuffer(Display
*dpy
, GLXFBConfig config
, const int *attribList
)
417 struct _glxapi_table
*t
;
418 GET_DISPATCH(dpy
, t
);
421 return (t
->CreatePbuffer
)(dpy
, config
, attribList
);
425 GLXPixmap
glXCreatePixmap(Display
*dpy
, GLXFBConfig config
, Pixmap pixmap
, const int *attribList
)
427 struct _glxapi_table
*t
;
428 GET_DISPATCH(dpy
, t
);
431 return (t
->CreatePixmap
)(dpy
, config
, pixmap
, attribList
);
435 GLXWindow
glXCreateWindow(Display
*dpy
, GLXFBConfig config
, Window win
, const int *attribList
)
437 struct _glxapi_table
*t
;
438 GET_DISPATCH(dpy
, t
);
441 return (t
->CreateWindow
)(dpy
, config
, win
, attribList
);
445 void glXDestroyPbuffer(Display
*dpy
, GLXPbuffer pbuf
)
447 struct _glxapi_table
*t
;
448 GET_DISPATCH(dpy
, t
);
451 (t
->DestroyPbuffer
)(dpy
, pbuf
);
455 void glXDestroyPixmap(Display
*dpy
, GLXPixmap pixmap
)
457 struct _glxapi_table
*t
;
458 GET_DISPATCH(dpy
, t
);
461 (t
->DestroyPixmap
)(dpy
, pixmap
);
465 void glXDestroyWindow(Display
*dpy
, GLXWindow window
)
467 struct _glxapi_table
*t
;
468 GET_DISPATCH(dpy
, t
);
471 (t
->DestroyWindow
)(dpy
, window
);
475 #ifdef GLX_BUILT_IN_XMESA
476 /* Use the glXGetCurrentReadDrawable() function from libGL */
478 GLXDrawable
glXGetCurrentReadDrawable(void)
480 __GLXcontext
*gc
= (__GLXcontext
*) glXGetCurrentContext();
481 return gc
? gc
->currentReadable
: 0;
486 int glXGetFBConfigAttrib(Display
*dpy
, GLXFBConfig config
, int attribute
, int *value
)
488 struct _glxapi_table
*t
;
489 GET_DISPATCH(dpy
, t
);
491 return GLX_NO_EXTENSION
;
492 return (t
->GetFBConfigAttrib
)(dpy
, config
, attribute
, value
);
496 GLXFBConfig
*glXGetFBConfigs(Display
*dpy
, int screen
, int *nelements
)
498 struct _glxapi_table
*t
;
499 GET_DISPATCH(dpy
, t
);
502 return (t
->GetFBConfigs
)(dpy
, screen
, nelements
);
505 void glXGetSelectedEvent(Display
*dpy
, GLXDrawable drawable
, unsigned long *mask
)
507 struct _glxapi_table
*t
;
508 GET_DISPATCH(dpy
, t
);
511 (t
->GetSelectedEvent
)(dpy
, drawable
, mask
);
515 XVisualInfo
*glXGetVisualFromFBConfig(Display
*dpy
, GLXFBConfig config
)
517 struct _glxapi_table
*t
;
518 GET_DISPATCH(dpy
, t
);
521 return (t
->GetVisualFromFBConfig
)(dpy
, config
);
525 Bool
glXMakeContextCurrent(Display
*dpy
, GLXDrawable draw
, GLXDrawable read
, GLXContext ctx
)
528 struct _glxapi_table
*t
;
529 GET_DISPATCH(dpy
, t
);
532 b
= (t
->MakeContextCurrent
)(dpy
, draw
, read
, ctx
);
533 #ifndef GLX_BUILT_IN_XMESA
535 CurrentContext
= ctx
;
542 int glXQueryContext(Display
*dpy
, GLXContext ctx
, int attribute
, int *value
)
544 struct _glxapi_table
*t
;
545 GET_DISPATCH(dpy
, t
);
548 return 0; /* XXX correct? */
549 return (t
->QueryContext
)(dpy
, ctx
, attribute
, value
);
553 void glXQueryDrawable(Display
*dpy
, GLXDrawable draw
, int attribute
, unsigned int *value
)
555 struct _glxapi_table
*t
;
556 GET_DISPATCH(dpy
, t
);
559 (t
->QueryDrawable
)(dpy
, draw
, attribute
, value
);
563 void glXSelectEvent(Display
*dpy
, GLXDrawable drawable
, unsigned long mask
)
565 struct _glxapi_table
*t
;
566 GET_DISPATCH(dpy
, t
);
569 (t
->SelectEvent
)(dpy
, drawable
, mask
);
574 /*** GLX_SGI_swap_control ***/
576 int glXSwapIntervalSGI(int interval
)
578 struct _glxapi_table
*t
;
579 Display
*dpy
= glXGetCurrentDisplay();
580 GET_DISPATCH(dpy
, t
);
583 return (t
->SwapIntervalSGI
)(interval
);
588 /*** GLX_SGI_video_sync ***/
590 int glXGetVideoSyncSGI(unsigned int *count
)
592 struct _glxapi_table
*t
;
593 Display
*dpy
= glXGetCurrentDisplay();
594 GET_DISPATCH(dpy
, t
);
597 return (t
->GetVideoSyncSGI
)(count
);
600 int glXWaitVideoSyncSGI(int divisor
, int remainder
, unsigned int *count
)
602 struct _glxapi_table
*t
;
603 Display
*dpy
= glXGetCurrentDisplay();
604 GET_DISPATCH(dpy
, t
);
607 return (t
->WaitVideoSyncSGI
)(divisor
, remainder
, count
);
612 /*** GLX_SGI_make_current_read ***/
614 Bool
glXMakeCurrentReadSGI(Display
*dpy
, GLXDrawable draw
, GLXDrawable read
, GLXContext ctx
)
616 struct _glxapi_table
*t
;
617 GET_DISPATCH(dpy
, t
);
620 return (t
->MakeCurrentReadSGI
)(dpy
, draw
, read
, ctx
);
623 #ifdef GLX_BUILT_IN_XMESA
624 /* Use glXGetCurrentReadDrawableSGI() from libGL */
626 /* stand-alone Mesa */
627 GLXDrawable
glXGetCurrentReadDrawableSGI(void)
629 return glXGetCurrentReadDrawable();
636 GLXVideoSourceSGIX
glXCreateGLXVideoSourceSGIX(Display
*dpy
, int screen
, VLServer server
, VLPath path
, int nodeClass
, VLNode drainNode
)
638 struct _glxapi_table
*t
;
639 GET_DISPATCH(dpy
, t
);
642 return (t
->CreateGLXVideoSourceSGIX
)(dpy
, screen
, server
, path
, nodeClass
, drainNode
);
645 void glXDestroyGLXVideoSourceSGIX(Display
*dpy
, GLXVideoSourceSGIX src
)
647 struct _glxapi_table
*t
;
648 GET_DISPATCH(dpy
, t
);
651 return (t
->DestroyGLXVideoSourceSGIX
)(dpy
, src
);
657 /*** GLX_EXT_import_context ***/
659 void glXFreeContextEXT(Display
*dpy
, GLXContext context
)
661 struct _glxapi_table
*t
;
662 GET_DISPATCH(dpy
, t
);
665 (t
->FreeContextEXT
)(dpy
, context
);
668 #ifdef GLX_BUILT_IN_XMESA
669 /* Use real libGL's glXGetContextIDEXT() function */
671 /* stand-alone Mesa */
672 GLXContextID
glXGetContextIDEXT(const GLXContext context
)
674 return ((__GLXcontext
*) context
)->xid
;
678 #ifdef GLX_BUILT_IN_XMESA
679 /* Use real libGL's glXGetCurrentDisplayEXT() function */
681 /* stand-alone Mesa */
682 Display
*glXGetCurrentDisplayEXT(void)
684 return glXGetCurrentDisplay();
688 GLXContext
glXImportContextEXT(Display
*dpy
, GLXContextID contextID
)
690 struct _glxapi_table
*t
;
691 GET_DISPATCH(dpy
, t
);
694 return (t
->ImportContextEXT
)(dpy
, contextID
);
697 int glXQueryContextInfoEXT(Display
*dpy
, GLXContext context
, int attribute
,int *value
)
699 struct _glxapi_table
*t
;
700 GET_DISPATCH(dpy
, t
);
702 return 0; /* XXX ok? */
703 return (t
->QueryContextInfoEXT
)(dpy
, context
, attribute
, value
);
708 /*** GLX_SGIX_fbconfig ***/
710 int glXGetFBConfigAttribSGIX(Display
*dpy
, GLXFBConfigSGIX config
, int attribute
, int *value
)
712 struct _glxapi_table
*t
;
713 GET_DISPATCH(dpy
, t
);
716 return (t
->GetFBConfigAttribSGIX
)(dpy
, config
, attribute
, value
);
719 GLXFBConfigSGIX
*glXChooseFBConfigSGIX(Display
*dpy
, int screen
, int *attrib_list
, int *nelements
)
721 struct _glxapi_table
*t
;
722 GET_DISPATCH(dpy
, t
);
725 return (t
->ChooseFBConfigSGIX
)(dpy
, screen
, attrib_list
, nelements
);
728 GLXPixmap
glXCreateGLXPixmapWithConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
, Pixmap pixmap
)
730 struct _glxapi_table
*t
;
731 GET_DISPATCH(dpy
, t
);
734 return (t
->CreateGLXPixmapWithConfigSGIX
)(dpy
, config
, pixmap
);
737 GLXContext
glXCreateContextWithConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
, int render_type
, GLXContext share_list
, Bool direct
)
739 struct _glxapi_table
*t
;
740 GET_DISPATCH(dpy
, t
);
743 return (t
->CreateContextWithConfigSGIX
)(dpy
, config
, render_type
, share_list
, direct
);
746 XVisualInfo
* glXGetVisualFromFBConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
)
748 struct _glxapi_table
*t
;
749 GET_DISPATCH(dpy
, t
);
752 return (t
->GetVisualFromFBConfigSGIX
)(dpy
, config
);
755 GLXFBConfigSGIX
glXGetFBConfigFromVisualSGIX(Display
*dpy
, XVisualInfo
*vis
)
757 struct _glxapi_table
*t
;
758 GET_DISPATCH(dpy
, t
);
761 return (t
->GetFBConfigFromVisualSGIX
)(dpy
, vis
);
766 /*** GLX_SGIX_pbuffer ***/
768 GLXPbufferSGIX
glXCreateGLXPbufferSGIX(Display
*dpy
, GLXFBConfigSGIX config
, unsigned int width
, unsigned int height
, int *attrib_list
)
770 struct _glxapi_table
*t
;
771 GET_DISPATCH(dpy
, t
);
774 return (t
->CreateGLXPbufferSGIX
)(dpy
, config
, width
, height
, attrib_list
);
777 void glXDestroyGLXPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuf
)
779 struct _glxapi_table
*t
;
780 GET_DISPATCH(dpy
, t
);
783 (t
->DestroyGLXPbufferSGIX
)(dpy
, pbuf
);
786 int glXQueryGLXPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuf
, int attribute
, unsigned int *value
)
788 struct _glxapi_table
*t
;
789 GET_DISPATCH(dpy
, t
);
792 return (t
->QueryGLXPbufferSGIX
)(dpy
, pbuf
, attribute
, value
);
795 void glXSelectEventSGIX(Display
*dpy
, GLXDrawable drawable
, unsigned long mask
)
797 struct _glxapi_table
*t
;
798 GET_DISPATCH(dpy
, t
);
801 (t
->SelectEventSGIX
)(dpy
, drawable
, mask
);
804 void glXGetSelectedEventSGIX(Display
*dpy
, GLXDrawable drawable
, unsigned long *mask
)
806 struct _glxapi_table
*t
;
807 GET_DISPATCH(dpy
, t
);
810 (t
->GetSelectedEventSGIX
)(dpy
, drawable
, mask
);
815 /*** GLX_SGI_cushion ***/
817 void glXCushionSGI(Display
*dpy
, Window win
, float cushion
)
819 struct _glxapi_table
*t
;
820 GET_DISPATCH(dpy
, t
);
823 (t
->CushionSGI
)(dpy
, win
, cushion
);
828 /*** GLX_SGIX_video_resize ***/
830 int glXBindChannelToWindowSGIX(Display
*dpy
, int screen
, int channel
, Window window
)
832 struct _glxapi_table
*t
;
833 GET_DISPATCH(dpy
, t
);
836 return (t
->BindChannelToWindowSGIX
)(dpy
, screen
, channel
, window
);
839 int glXChannelRectSGIX(Display
*dpy
, int screen
, int channel
, int x
, int y
, int w
, int h
)
841 struct _glxapi_table
*t
;
842 GET_DISPATCH(dpy
, t
);
845 return (t
->ChannelRectSGIX
)(dpy
, screen
, channel
, x
, y
, w
, h
);
848 int glXQueryChannelRectSGIX(Display
*dpy
, int screen
, int channel
, int *x
, int *y
, int *w
, int *h
)
850 struct _glxapi_table
*t
;
851 GET_DISPATCH(dpy
, t
);
854 return (t
->QueryChannelRectSGIX
)(dpy
, screen
, channel
, x
, y
, w
, h
);
857 int glXQueryChannelDeltasSGIX(Display
*dpy
, int screen
, int channel
, int *dx
, int *dy
, int *dw
, int *dh
)
859 struct _glxapi_table
*t
;
860 GET_DISPATCH(dpy
, t
);
863 return (t
->QueryChannelDeltasSGIX
)(dpy
, screen
, channel
, dx
, dy
, dw
, dh
);
866 int glXChannelRectSyncSGIX(Display
*dpy
, int screen
, int channel
, GLenum synctype
)
868 struct _glxapi_table
*t
;
869 GET_DISPATCH(dpy
, t
);
872 return (t
->ChannelRectSyncSGIX
)(dpy
, screen
, channel
, synctype
);
877 #if defined(_DM_BUFFER_H_)
879 Bool
glXAssociateDMPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuffer
, DMparams
*params
, DMbuffer dmbuffer
)
881 struct _glxapi_table
*t
;
882 GET_DISPATCH(dpy
, t
);
885 return (t
->AssociateDMPbufferSGIX
)(dpy
, pbuffer
, params
, dmbuffer
);
891 /*** GLX_SGIX_swap_group ***/
893 void glXJoinSwapGroupSGIX(Display
*dpy
, GLXDrawable drawable
, GLXDrawable member
)
895 struct _glxapi_table
*t
;
896 GET_DISPATCH(dpy
, t
);
899 (*t
->JoinSwapGroupSGIX
)(dpy
, drawable
, member
);
903 /*** GLX_SGIX_swap_barrier ***/
905 void glXBindSwapBarrierSGIX(Display
*dpy
, GLXDrawable drawable
, int barrier
)
907 struct _glxapi_table
*t
;
908 GET_DISPATCH(dpy
, t
);
911 (*t
->BindSwapBarrierSGIX
)(dpy
, drawable
, barrier
);
914 Bool
glXQueryMaxSwapBarriersSGIX(Display
*dpy
, int screen
, int *max
)
916 struct _glxapi_table
*t
;
917 GET_DISPATCH(dpy
, t
);
920 return (*t
->QueryMaxSwapBarriersSGIX
)(dpy
, screen
, max
);
925 /*** GLX_SUN_get_transparent_index ***/
927 Status
glXGetTransparentIndexSUN(Display
*dpy
, Window overlay
, Window underlay
, long *pTransparent
)
929 struct _glxapi_table
*t
;
930 GET_DISPATCH(dpy
, t
);
933 return (*t
->GetTransparentIndexSUN
)(dpy
, overlay
, underlay
, pTransparent
);
938 /*** GLX_MESA_copy_sub_buffer ***/
940 void glXCopySubBufferMESA(Display
*dpy
, GLXDrawable drawable
, int x
, int y
, int width
, int height
)
942 struct _glxapi_table
*t
;
943 GET_DISPATCH(dpy
, t
);
946 (t
->CopySubBufferMESA
)(dpy
, drawable
, x
, y
, width
, height
);
951 /*** GLX_MESA_release_buffers ***/
953 Bool
glXReleaseBuffersMESA(Display
*dpy
, Window w
)
955 struct _glxapi_table
*t
;
956 GET_DISPATCH(dpy
, t
);
959 return (t
->ReleaseBuffersMESA
)(dpy
, w
);
964 /*** GLX_MESA_pixmap_colormap ***/
966 GLXPixmap
glXCreateGLXPixmapMESA(Display
*dpy
, XVisualInfo
*visinfo
, Pixmap pixmap
, Colormap cmap
)
968 struct _glxapi_table
*t
;
969 GET_DISPATCH(dpy
, t
);
972 return (t
->CreateGLXPixmapMESA
)(dpy
, visinfo
, pixmap
, cmap
);
977 /*** GLX_MESA_set_3dfx_mode ***/
979 Bool
glXSet3DfxModeMESA(int mode
)
981 struct _glxapi_table
*t
;
982 Display
*dpy
= glXGetCurrentDisplay();
983 GET_DISPATCH(dpy
, t
);
986 return (t
->Set3DfxModeMESA
)(mode
);
992 /**********************************************************************/
993 /* GLX API management functions */
994 /**********************************************************************/
998 _glxapi_get_version(void)
1005 * Return array of extension strings.
1008 _glxapi_get_extensions(void)
1010 static const char *extensions
[] = {
1011 #ifdef GLX_EXT_import_context
1012 "GLX_EXT_import_context",
1014 #ifdef GLX_SGI_video_sync
1015 "GLX_SGI_video_sync",
1017 #ifdef GLX_MESA_copy_sub_buffer
1018 "GLX_MESA_copy_sub_buffer",
1020 #ifdef GLX_MESA_release_buffers
1021 "GLX_MESA_release_buffers",
1023 #ifdef GLX_MESA_pixmap_colormap
1024 "GLX_MESA_pixmap_colormap",
1026 #ifdef GLX_MESA_set_3dfx_mode
1027 "GLX_MESA_set_3dfx_mode",
1036 * Return size of the GLX dispatch table, in entries, not bytes.
1039 _glxapi_get_dispatch_table_size(void)
1041 return sizeof(struct _glxapi_table
) / sizeof(void *);
1046 generic_no_op_func(void)
1053 * Initialize all functions in given dispatch table to be no-ops
1056 _glxapi_set_no_op_table(struct _glxapi_table
*t
)
1058 GLuint n
= _glxapi_get_dispatch_table_size();
1060 void **dispatch
= (void **) t
;
1061 for (i
= 0; i
< n
; i
++) {
1062 dispatch
[i
] = (void *) generic_no_op_func
;
1067 struct name_address_pair
{
1072 static struct name_address_pair GLX_functions
[] = {
1073 /*** GLX_VERSION_1_0 ***/
1074 { "glXChooseVisual", (GLvoid
*) glXChooseVisual
},
1075 { "glXCopyContext", (GLvoid
*) glXCopyContext
},
1076 { "glXCreateContext", (GLvoid
*) glXCreateContext
},
1077 { "glXCreateGLXPixmap", (GLvoid
*) glXCreateGLXPixmap
},
1078 { "glXDestroyContext", (GLvoid
*) glXDestroyContext
},
1079 { "glXDestroyGLXPixmap", (GLvoid
*) glXDestroyGLXPixmap
},
1080 { "glXGetConfig", (GLvoid
*) glXGetConfig
},
1081 { "glXGetCurrentContext", (GLvoid
*) glXGetCurrentContext
},
1082 { "glXGetCurrentDrawable", (GLvoid
*) glXGetCurrentDrawable
},
1083 { "glXIsDirect", (GLvoid
*) glXIsDirect
},
1084 { "glXMakeCurrent", (GLvoid
*) glXMakeCurrent
},
1085 { "glXQueryExtension", (GLvoid
*) glXQueryExtension
},
1086 { "glXQueryVersion", (GLvoid
*) glXQueryVersion
},
1087 { "glXSwapBuffers", (GLvoid
*) glXSwapBuffers
},
1088 { "glXUseXFont", (GLvoid
*) glXUseXFont
},
1089 { "glXWaitGL", (GLvoid
*) glXWaitGL
},
1090 { "glXWaitX", (GLvoid
*) glXWaitX
},
1092 /*** GLX_VERSION_1_1 ***/
1093 { "glXGetClientString", (GLvoid
*) glXGetClientString
},
1094 { "glXQueryExtensionsString", (GLvoid
*) glXQueryExtensionsString
},
1095 { "glXQueryServerString", (GLvoid
*) glXQueryServerString
},
1097 /*** GLX_VERSION_1_2 ***/
1098 { "glXGetCurrentDisplay", (GLvoid
*) glXGetCurrentDisplay
},
1100 /*** GLX_VERSION_1_3 ***/
1101 { "glXChooseFBConfig", (GLvoid
*) glXChooseFBConfig
},
1102 { "glXCreateNewContext", (GLvoid
*) glXCreateNewContext
},
1103 { "glXCreatePbuffer", (GLvoid
*) glXCreatePbuffer
},
1104 { "glXCreatePixmap", (GLvoid
*) glXCreatePixmap
},
1105 { "glXCreateWindow", (GLvoid
*) glXCreateWindow
},
1106 { "glXDestroyPbuffer", (GLvoid
*) glXDestroyPbuffer
},
1107 { "glXDestroyPixmap", (GLvoid
*) glXDestroyPixmap
},
1108 { "glXDestroyWindow", (GLvoid
*) glXDestroyWindow
},
1109 { "glXGetCurrentReadDrawable", (GLvoid
*) glXGetCurrentReadDrawable
},
1110 { "glXGetFBConfigAttrib", (GLvoid
*) glXGetFBConfigAttrib
},
1111 { "glXGetFBConfigs", (GLvoid
*) glXGetFBConfigs
},
1112 { "glXGetSelectedEvent", (GLvoid
*) glXGetSelectedEvent
},
1113 { "glXGetVisualFromFBConfig", (GLvoid
*) glXGetVisualFromFBConfig
},
1114 { "glXMakeContextCurrent", (GLvoid
*) glXMakeContextCurrent
},
1115 { "glXQueryContext", (GLvoid
*) glXQueryContext
},
1116 { "glXQueryDrawable", (GLvoid
*) glXQueryDrawable
},
1117 { "glXSelectEvent", (GLvoid
*) glXSelectEvent
},
1119 /*** GLX_VERSION_1_4 ***/
1120 { "glXGetProcAddress", (GLvoid
*) glXGetProcAddress
},
1122 /*** GLX_SGI_swap_control ***/
1123 { "glXSwapIntervalSGI", (GLvoid
*) glXSwapIntervalSGI
},
1125 /*** GLX_SGI_video_sync ***/
1126 { "glXGetVideoSyncSGI", (GLvoid
*) glXGetVideoSyncSGI
},
1127 { "glXWaitVideoSyncSGI", (GLvoid
*) glXWaitVideoSyncSGI
},
1129 /*** GLX_SGI_make_current_read ***/
1130 { "glXMakeCurrentReadSGI", (GLvoid
*) glXMakeCurrentReadSGI
},
1131 { "glXGetCurrentReadDrawableSGI", (GLvoid
*) glXGetCurrentReadDrawableSGI
},
1133 /*** GLX_SGIX_video_source ***/
1135 { "glXCreateGLXVideoSourceSGIX", (GLvoid
*) glXCreateGLXVideoSourceSGIX
},
1136 { "glXDestroyGLXVideoSourceSGIX", (GLvoid
*) glXDestroyGLXVideoSourceSGIX
},
1139 /*** GLX_EXT_import_context ***/
1140 { "glXFreeContextEXT", (GLvoid
*) glXFreeContextEXT
},
1141 { "glXGetContextIDEXT", (GLvoid
*) glXGetContextIDEXT
},
1142 { "glXGetCurrentDisplayEXT", (GLvoid
*) glXGetCurrentDisplayEXT
},
1143 { "glXImportContextEXT", (GLvoid
*) glXImportContextEXT
},
1144 { "glXQueryContextInfoEXT", (GLvoid
*) glXQueryContextInfoEXT
},
1146 /*** GLX_SGIX_fbconfig ***/
1147 { "glXGetFBConfigAttribSGIX", (GLvoid
*) glXGetFBConfigAttribSGIX
},
1148 { "glXChooseFBConfigSGIX", (GLvoid
*) glXChooseFBConfigSGIX
},
1149 { "glXCreateGLXPixmapWithConfigSGIX", (GLvoid
*) glXCreateGLXPixmapWithConfigSGIX
},
1150 { "glXCreateContextWithConfigSGIX", (GLvoid
*) glXCreateContextWithConfigSGIX
},
1151 { "glXGetVisualFromFBConfigSGIX", (GLvoid
*) glXGetVisualFromFBConfigSGIX
},
1152 { "glXGetFBConfigFromVisualSGIX", (GLvoid
*) glXGetFBConfigFromVisualSGIX
},
1154 /*** GLX_SGIX_pbuffer ***/
1155 { "glXCreateGLXPbufferSGIX", (GLvoid
*) glXCreateGLXPbufferSGIX
},
1156 { "glXDestroyGLXPbufferSGIX", (GLvoid
*) glXDestroyGLXPbufferSGIX
},
1157 { "glXQueryGLXPbufferSGIX", (GLvoid
*) glXQueryGLXPbufferSGIX
},
1158 { "glXSelectEventSGIX", (GLvoid
*) glXSelectEventSGIX
},
1159 { "glXGetSelectedEventSGIX", (GLvoid
*) glXGetSelectedEventSGIX
},
1161 /*** GLX_SGI_cushion ***/
1162 { "glXCushionSGI", (GLvoid
*) glXCushionSGI
},
1164 /*** GLX_SGIX_video_resize ***/
1165 { "glXBindChannelToWindowSGIX", (GLvoid
*) glXBindChannelToWindowSGIX
},
1166 { "glXChannelRectSGIX", (GLvoid
*) glXChannelRectSGIX
},
1167 { "glXQueryChannelRectSGIX", (GLvoid
*) glXQueryChannelRectSGIX
},
1168 { "glXQueryChannelDeltasSGIX", (GLvoid
*) glXQueryChannelDeltasSGIX
},
1169 { "glXChannelRectSyncSGIX", (GLvoid
*) glXChannelRectSyncSGIX
},
1171 /*** GLX_SGIX_dmbuffer **/
1172 #if defined(_DM_BUFFER_H_)
1173 { "glXAssociateDMPbufferSGIX", (GLvoid
*) glXAssociateDMPbufferSGIX
},
1176 /*** GLX_SGIX_swap_group ***/
1177 { "glXJoinSwapGroupSGIX", (GLvoid
*) glXJoinSwapGroupSGIX
},
1179 /*** GLX_SGIX_swap_barrier ***/
1180 { "glXBindSwapBarrierSGIX", (GLvoid
*) glXBindSwapBarrierSGIX
},
1181 { "glXQueryMaxSwapBarriersSGIX", (GLvoid
*) glXQueryMaxSwapBarriersSGIX
},
1183 /*** GLX_SUN_get_transparent_index ***/
1184 { "glXGetTransparentIndexSUN", (GLvoid
*) glXGetTransparentIndexSUN
},
1186 /*** GLX_MESA_copy_sub_buffer ***/
1187 { "glXCopySubBufferMESA", (GLvoid
*) glXCopySubBufferMESA
},
1189 /*** GLX_MESA_pixmap_colormap ***/
1190 { "glXCreateGLXPixmapMESA", (GLvoid
*) glXCreateGLXPixmapMESA
},
1192 /*** GLX_MESA_release_buffers ***/
1193 { "glXReleaseBuffersMESA", (GLvoid
*) glXReleaseBuffersMESA
},
1195 /*** GLX_MESA_set_3dfx_mode ***/
1196 { "glXSet3DfxModeMESA", (GLvoid
*) glXSet3DfxModeMESA
},
1198 /*** GLX_ARB_get_proc_address ***/
1199 { "glXGetProcAddressARB", (GLvoid
*) glXGetProcAddressARB
},
1201 { NULL
, NULL
} /* end of list */
1207 * Return address of named glX function, or NULL if not found.
1210 _glxapi_get_proc_address(const char *funcName
)
1213 for (i
= 0; GLX_functions
[i
].Name
; i
++) {
1214 if (strcmp(GLX_functions
[i
].Name
, funcName
) == 0)
1215 return GLX_functions
[i
].Address
;
1223 * This function does not get dispatched through the dispatch table
1224 * since it's really a "meta" function.
1226 void (*glXGetProcAddressARB(const GLubyte
*procName
))()
1228 typedef void (*gl_function
)();
1231 f
= (gl_function
) _glxapi_get_proc_address((const char *) procName
);
1236 f
= (gl_function
) _glapi_get_proc_address((const char *) procName
);
1242 void (*glXGetProcAddress(const GLubyte
*procName
))()
1244 return glXGetProcAddressARB(procName
);