2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2005 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 #define GET_DISPATCH(DPY, TABLE) \
111 if (DPY == prevDisplay) { \
118 TABLE = get_dispatch(DPY); \
124 /* Set by glXMakeCurrent() and glXMakeContextCurrent() only */
125 static GLXContext CurrentContext
= 0;
126 #define __glXGetCurrentContext() CurrentContext;
130 * GLX API entrypoints
133 /*** GLX_VERSION_1_0 ***/
136 glXChooseVisual(Display
*dpy
, int screen
, int *list
)
138 struct _glxapi_table
*t
;
139 GET_DISPATCH(dpy
, t
);
142 return (t
->ChooseVisual
)(dpy
, screen
, list
);
147 glXCopyContext(Display
*dpy
, GLXContext src
, GLXContext dst
, unsigned long mask
)
149 struct _glxapi_table
*t
;
150 GET_DISPATCH(dpy
, t
);
153 (t
->CopyContext
)(dpy
, src
, dst
, mask
);
158 glXCreateContext(Display
*dpy
, XVisualInfo
*visinfo
, GLXContext shareList
, Bool direct
)
160 struct _glxapi_table
*t
;
161 GET_DISPATCH(dpy
, t
);
164 return (t
->CreateContext
)(dpy
, visinfo
, shareList
, direct
);
169 glXCreateGLXPixmap(Display
*dpy
, XVisualInfo
*visinfo
, Pixmap pixmap
)
171 struct _glxapi_table
*t
;
172 GET_DISPATCH(dpy
, t
);
175 return (t
->CreateGLXPixmap
)(dpy
, visinfo
, pixmap
);
180 glXDestroyContext(Display
*dpy
, GLXContext ctx
)
182 struct _glxapi_table
*t
;
183 GET_DISPATCH(dpy
, t
);
186 (t
->DestroyContext
)(dpy
, ctx
);
191 glXDestroyGLXPixmap(Display
*dpy
, GLXPixmap pixmap
)
193 struct _glxapi_table
*t
;
194 GET_DISPATCH(dpy
, t
);
197 (t
->DestroyGLXPixmap
)(dpy
, pixmap
);
202 glXGetConfig(Display
*dpy
, XVisualInfo
*visinfo
, int attrib
, int *value
)
204 struct _glxapi_table
*t
;
205 GET_DISPATCH(dpy
, t
);
207 return GLX_NO_EXTENSION
;
208 return (t
->GetConfig
)(dpy
, visinfo
, attrib
, value
);
213 glXGetCurrentContext(void)
215 return CurrentContext
;
220 glXGetCurrentDrawable(void)
222 __GLXcontext
*gc
= (__GLXcontext
*) glXGetCurrentContext();
223 return gc
? gc
->currentDrawable
: 0;
228 glXIsDirect(Display
*dpy
, GLXContext ctx
)
230 struct _glxapi_table
*t
;
231 GET_DISPATCH(dpy
, t
);
234 return (t
->IsDirect
)(dpy
, ctx
);
239 glXMakeCurrent(Display
*dpy
, GLXDrawable drawable
, GLXContext ctx
)
242 struct _glxapi_table
*t
;
243 GET_DISPATCH(dpy
, t
);
247 b
= (*t
->MakeCurrent
)(dpy
, drawable
, ctx
);
249 CurrentContext
= ctx
;
256 glXQueryExtension(Display
*dpy
, int *errorb
, int *event
)
258 struct _glxapi_table
*t
;
259 GET_DISPATCH(dpy
, t
);
262 return (t
->QueryExtension
)(dpy
, errorb
, event
);
267 glXQueryVersion(Display
*dpy
, int *maj
, int *min
)
269 struct _glxapi_table
*t
;
270 GET_DISPATCH(dpy
, t
);
273 return (t
->QueryVersion
)(dpy
, maj
, min
);
278 glXSwapBuffers(Display
*dpy
, GLXDrawable drawable
)
280 struct _glxapi_table
*t
;
281 GET_DISPATCH(dpy
, t
);
284 (t
->SwapBuffers
)(dpy
, drawable
);
289 glXUseXFont(Font font
, int first
, int count
, int listBase
)
291 struct _glxapi_table
*t
;
292 Display
*dpy
= glXGetCurrentDisplay();
293 GET_DISPATCH(dpy
, t
);
296 (t
->UseXFont
)(font
, first
, count
, listBase
);
303 struct _glxapi_table
*t
;
304 Display
*dpy
= glXGetCurrentDisplay();
305 GET_DISPATCH(dpy
, t
);
315 struct _glxapi_table
*t
;
316 Display
*dpy
= glXGetCurrentDisplay();
317 GET_DISPATCH(dpy
, t
);
325 /*** GLX_VERSION_1_1 ***/
328 glXGetClientString(Display
*dpy
, int name
)
330 struct _glxapi_table
*t
;
331 GET_DISPATCH(dpy
, t
);
334 return (t
->GetClientString
)(dpy
, name
);
339 glXQueryExtensionsString(Display
*dpy
, int screen
)
341 struct _glxapi_table
*t
;
342 GET_DISPATCH(dpy
, t
);
345 return (t
->QueryExtensionsString
)(dpy
, screen
);
350 glXQueryServerString(Display
*dpy
, int screen
, int name
)
352 struct _glxapi_table
*t
;
353 GET_DISPATCH(dpy
, t
);
356 return (t
->QueryServerString
)(dpy
, screen
, name
);
360 /*** GLX_VERSION_1_2 ***/
363 glXGetCurrentDisplay(void)
365 /* Same code as in libGL's glxext.c */
366 __GLXcontext
*gc
= (__GLXcontext
*) glXGetCurrentContext();
367 if (NULL
== gc
) return NULL
;
368 return gc
->currentDpy
;
373 /*** GLX_VERSION_1_3 ***/
376 glXChooseFBConfig(Display
*dpy
, int screen
, const int *attribList
, int *nitems
)
378 struct _glxapi_table
*t
;
379 GET_DISPATCH(dpy
, t
);
382 return (t
->ChooseFBConfig
)(dpy
, screen
, attribList
, nitems
);
387 glXCreateNewContext(Display
*dpy
, GLXFBConfig config
, int renderType
, GLXContext shareList
, Bool direct
)
389 struct _glxapi_table
*t
;
390 GET_DISPATCH(dpy
, t
);
393 return (t
->CreateNewContext
)(dpy
, config
, renderType
, shareList
, direct
);
398 glXCreatePbuffer(Display
*dpy
, GLXFBConfig config
, const int *attribList
)
400 struct _glxapi_table
*t
;
401 GET_DISPATCH(dpy
, t
);
404 return (t
->CreatePbuffer
)(dpy
, config
, attribList
);
409 glXCreatePixmap(Display
*dpy
, GLXFBConfig config
, Pixmap pixmap
, const int *attribList
)
411 struct _glxapi_table
*t
;
412 GET_DISPATCH(dpy
, t
);
415 return (t
->CreatePixmap
)(dpy
, config
, pixmap
, attribList
);
420 glXCreateWindow(Display
*dpy
, GLXFBConfig config
, Window win
, const int *attribList
)
422 struct _glxapi_table
*t
;
423 GET_DISPATCH(dpy
, t
);
426 return (t
->CreateWindow
)(dpy
, config
, win
, attribList
);
431 glXDestroyPbuffer(Display
*dpy
, GLXPbuffer pbuf
)
433 struct _glxapi_table
*t
;
434 GET_DISPATCH(dpy
, t
);
437 (t
->DestroyPbuffer
)(dpy
, pbuf
);
442 glXDestroyPixmap(Display
*dpy
, GLXPixmap pixmap
)
444 struct _glxapi_table
*t
;
445 GET_DISPATCH(dpy
, t
);
448 (t
->DestroyPixmap
)(dpy
, pixmap
);
453 glXDestroyWindow(Display
*dpy
, GLXWindow window
)
455 struct _glxapi_table
*t
;
456 GET_DISPATCH(dpy
, t
);
459 (t
->DestroyWindow
)(dpy
, window
);
464 glXGetCurrentReadDrawable(void)
466 __GLXcontext
*gc
= (__GLXcontext
*) glXGetCurrentContext();
467 return gc
? gc
->currentReadable
: 0;
472 glXGetFBConfigAttrib(Display
*dpy
, GLXFBConfig config
, int attribute
, int *value
)
474 struct _glxapi_table
*t
;
475 GET_DISPATCH(dpy
, t
);
477 return GLX_NO_EXTENSION
;
478 return (t
->GetFBConfigAttrib
)(dpy
, config
, attribute
, value
);
483 glXGetFBConfigs(Display
*dpy
, int screen
, int *nelements
)
485 struct _glxapi_table
*t
;
486 GET_DISPATCH(dpy
, t
);
489 return (t
->GetFBConfigs
)(dpy
, screen
, nelements
);
493 glXGetSelectedEvent(Display
*dpy
, GLXDrawable drawable
, unsigned long *mask
)
495 struct _glxapi_table
*t
;
496 GET_DISPATCH(dpy
, t
);
499 (t
->GetSelectedEvent
)(dpy
, drawable
, mask
);
504 glXGetVisualFromFBConfig(Display
*dpy
, GLXFBConfig config
)
506 struct _glxapi_table
*t
;
507 GET_DISPATCH(dpy
, t
);
510 return (t
->GetVisualFromFBConfig
)(dpy
, config
);
515 glXMakeContextCurrent(Display
*dpy
, GLXDrawable draw
, GLXDrawable read
, GLXContext ctx
)
518 struct _glxapi_table
*t
;
519 GET_DISPATCH(dpy
, t
);
522 b
= (t
->MakeContextCurrent
)(dpy
, draw
, read
, ctx
);
524 CurrentContext
= ctx
;
531 glXQueryContext(Display
*dpy
, GLXContext ctx
, int attribute
, int *value
)
533 struct _glxapi_table
*t
;
534 GET_DISPATCH(dpy
, t
);
537 return 0; /* XXX correct? */
538 return (t
->QueryContext
)(dpy
, ctx
, attribute
, value
);
543 glXQueryDrawable(Display
*dpy
, GLXDrawable draw
, int attribute
, unsigned int *value
)
545 struct _glxapi_table
*t
;
546 GET_DISPATCH(dpy
, t
);
549 (t
->QueryDrawable
)(dpy
, draw
, attribute
, value
);
554 glXSelectEvent(Display
*dpy
, GLXDrawable drawable
, unsigned long mask
)
556 struct _glxapi_table
*t
;
557 GET_DISPATCH(dpy
, t
);
560 (t
->SelectEvent
)(dpy
, drawable
, mask
);
565 /*** GLX_SGI_swap_control ***/
568 glXSwapIntervalSGI(int interval
)
570 struct _glxapi_table
*t
;
571 Display
*dpy
= glXGetCurrentDisplay();
572 GET_DISPATCH(dpy
, t
);
575 return (t
->SwapIntervalSGI
)(interval
);
580 /*** GLX_SGI_video_sync ***/
583 glXGetVideoSyncSGI(unsigned int *count
)
585 struct _glxapi_table
*t
;
586 Display
*dpy
= glXGetCurrentDisplay();
587 GET_DISPATCH(dpy
, t
);
590 return (t
->GetVideoSyncSGI
)(count
);
594 glXWaitVideoSyncSGI(int divisor
, int remainder
, unsigned int *count
)
596 struct _glxapi_table
*t
;
597 Display
*dpy
= glXGetCurrentDisplay();
598 GET_DISPATCH(dpy
, t
);
601 return (t
->WaitVideoSyncSGI
)(divisor
, remainder
, count
);
606 /*** GLX_SGI_make_current_read ***/
609 glXMakeCurrentReadSGI(Display
*dpy
, GLXDrawable draw
, GLXDrawable read
, GLXContext ctx
)
611 struct _glxapi_table
*t
;
612 GET_DISPATCH(dpy
, t
);
615 return (t
->MakeCurrentReadSGI
)(dpy
, draw
, read
, ctx
);
619 glXGetCurrentReadDrawableSGI(void)
621 return glXGetCurrentReadDrawable();
627 GLXVideoSourceSGIX PUBLIC
628 glXCreateGLXVideoSourceSGIX(Display
*dpy
, int screen
, VLServer server
, VLPath path
, int nodeClass
, VLNode drainNode
)
630 struct _glxapi_table
*t
;
631 GET_DISPATCH(dpy
, t
);
634 return (t
->CreateGLXVideoSourceSGIX
)(dpy
, screen
, server
, path
, nodeClass
, drainNode
);
638 glXDestroyGLXVideoSourceSGIX(Display
*dpy
, GLXVideoSourceSGIX src
)
640 struct _glxapi_table
*t
;
641 GET_DISPATCH(dpy
, t
);
644 return (t
->DestroyGLXVideoSourceSGIX
)(dpy
, src
);
650 /*** GLX_EXT_import_context ***/
653 glXFreeContextEXT(Display
*dpy
, GLXContext context
)
655 struct _glxapi_table
*t
;
656 GET_DISPATCH(dpy
, t
);
659 (t
->FreeContextEXT
)(dpy
, context
);
663 glXGetContextIDEXT(const GLXContext context
)
665 return ((__GLXcontext
*) context
)->xid
;
669 glXGetCurrentDisplayEXT(void)
671 return glXGetCurrentDisplay();
675 glXImportContextEXT(Display
*dpy
, GLXContextID contextID
)
677 struct _glxapi_table
*t
;
678 GET_DISPATCH(dpy
, t
);
681 return (t
->ImportContextEXT
)(dpy
, contextID
);
685 glXQueryContextInfoEXT(Display
*dpy
, GLXContext context
, int attribute
,int *value
)
687 struct _glxapi_table
*t
;
688 GET_DISPATCH(dpy
, t
);
690 return 0; /* XXX ok? */
691 return (t
->QueryContextInfoEXT
)(dpy
, context
, attribute
, value
);
696 /*** GLX_SGIX_fbconfig ***/
699 glXGetFBConfigAttribSGIX(Display
*dpy
, GLXFBConfigSGIX config
, int attribute
, int *value
)
701 struct _glxapi_table
*t
;
702 GET_DISPATCH(dpy
, t
);
705 return (t
->GetFBConfigAttribSGIX
)(dpy
, config
, attribute
, value
);
708 GLXFBConfigSGIX PUBLIC
*
709 glXChooseFBConfigSGIX(Display
*dpy
, int screen
, int *attrib_list
, int *nelements
)
711 struct _glxapi_table
*t
;
712 GET_DISPATCH(dpy
, t
);
715 return (t
->ChooseFBConfigSGIX
)(dpy
, screen
, attrib_list
, nelements
);
719 glXCreateGLXPixmapWithConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
, Pixmap pixmap
)
721 struct _glxapi_table
*t
;
722 GET_DISPATCH(dpy
, t
);
725 return (t
->CreateGLXPixmapWithConfigSGIX
)(dpy
, config
, pixmap
);
729 glXCreateContextWithConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
, int render_type
, GLXContext share_list
, Bool direct
)
731 struct _glxapi_table
*t
;
732 GET_DISPATCH(dpy
, t
);
735 return (t
->CreateContextWithConfigSGIX
)(dpy
, config
, render_type
, share_list
, direct
);
739 glXGetVisualFromFBConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
)
741 struct _glxapi_table
*t
;
742 GET_DISPATCH(dpy
, t
);
745 return (t
->GetVisualFromFBConfigSGIX
)(dpy
, config
);
748 GLXFBConfigSGIX PUBLIC
749 glXGetFBConfigFromVisualSGIX(Display
*dpy
, XVisualInfo
*vis
)
751 struct _glxapi_table
*t
;
752 GET_DISPATCH(dpy
, t
);
755 return (t
->GetFBConfigFromVisualSGIX
)(dpy
, vis
);
760 /*** GLX_SGIX_pbuffer ***/
762 GLXPbufferSGIX PUBLIC
763 glXCreateGLXPbufferSGIX(Display
*dpy
, GLXFBConfigSGIX config
, unsigned int width
, unsigned int height
, int *attrib_list
)
765 struct _glxapi_table
*t
;
766 GET_DISPATCH(dpy
, t
);
769 return (t
->CreateGLXPbufferSGIX
)(dpy
, config
, width
, height
, attrib_list
);
773 glXDestroyGLXPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuf
)
775 struct _glxapi_table
*t
;
776 GET_DISPATCH(dpy
, t
);
779 (t
->DestroyGLXPbufferSGIX
)(dpy
, pbuf
);
783 glXQueryGLXPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuf
, int attribute
, unsigned int *value
)
785 struct _glxapi_table
*t
;
786 GET_DISPATCH(dpy
, t
);
789 return (t
->QueryGLXPbufferSGIX
)(dpy
, pbuf
, attribute
, value
);
793 glXSelectEventSGIX(Display
*dpy
, GLXDrawable drawable
, unsigned long mask
)
795 struct _glxapi_table
*t
;
796 GET_DISPATCH(dpy
, t
);
799 (t
->SelectEventSGIX
)(dpy
, drawable
, mask
);
803 glXGetSelectedEventSGIX(Display
*dpy
, GLXDrawable drawable
, unsigned long *mask
)
805 struct _glxapi_table
*t
;
806 GET_DISPATCH(dpy
, t
);
809 (t
->GetSelectedEventSGIX
)(dpy
, drawable
, mask
);
814 /*** GLX_SGI_cushion ***/
817 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 ***/
831 glXBindChannelToWindowSGIX(Display
*dpy
, int screen
, int channel
, Window window
)
833 struct _glxapi_table
*t
;
834 GET_DISPATCH(dpy
, t
);
837 return (t
->BindChannelToWindowSGIX
)(dpy
, screen
, channel
, window
);
841 glXChannelRectSGIX(Display
*dpy
, int screen
, int channel
, int x
, int y
, int w
, int h
)
843 struct _glxapi_table
*t
;
844 GET_DISPATCH(dpy
, t
);
847 return (t
->ChannelRectSGIX
)(dpy
, screen
, channel
, x
, y
, w
, h
);
851 glXQueryChannelRectSGIX(Display
*dpy
, int screen
, int channel
, int *x
, int *y
, int *w
, int *h
)
853 struct _glxapi_table
*t
;
854 GET_DISPATCH(dpy
, t
);
857 return (t
->QueryChannelRectSGIX
)(dpy
, screen
, channel
, x
, y
, w
, h
);
861 glXQueryChannelDeltasSGIX(Display
*dpy
, int screen
, int channel
, int *dx
, int *dy
, int *dw
, int *dh
)
863 struct _glxapi_table
*t
;
864 GET_DISPATCH(dpy
, t
);
867 return (t
->QueryChannelDeltasSGIX
)(dpy
, screen
, channel
, dx
, dy
, dw
, dh
);
871 glXChannelRectSyncSGIX(Display
*dpy
, int screen
, int channel
, GLenum synctype
)
873 struct _glxapi_table
*t
;
874 GET_DISPATCH(dpy
, t
);
877 return (t
->ChannelRectSyncSGIX
)(dpy
, screen
, channel
, synctype
);
882 #if defined(_DM_BUFFER_H_)
885 glXAssociateDMPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuffer
, DMparams
*params
, DMbuffer dmbuffer
)
887 struct _glxapi_table
*t
;
888 GET_DISPATCH(dpy
, t
);
891 return (t
->AssociateDMPbufferSGIX
)(dpy
, pbuffer
, params
, dmbuffer
);
897 /*** GLX_SGIX_swap_group ***/
900 glXJoinSwapGroupSGIX(Display
*dpy
, GLXDrawable drawable
, GLXDrawable member
)
902 struct _glxapi_table
*t
;
903 GET_DISPATCH(dpy
, t
);
906 (*t
->JoinSwapGroupSGIX
)(dpy
, drawable
, member
);
910 /*** GLX_SGIX_swap_barrier ***/
913 glXBindSwapBarrierSGIX(Display
*dpy
, GLXDrawable drawable
, int barrier
)
915 struct _glxapi_table
*t
;
916 GET_DISPATCH(dpy
, t
);
919 (*t
->BindSwapBarrierSGIX
)(dpy
, drawable
, barrier
);
923 glXQueryMaxSwapBarriersSGIX(Display
*dpy
, int screen
, int *max
)
925 struct _glxapi_table
*t
;
926 GET_DISPATCH(dpy
, t
);
929 return (*t
->QueryMaxSwapBarriersSGIX
)(dpy
, screen
, max
);
934 /*** GLX_SUN_get_transparent_index ***/
937 glXGetTransparentIndexSUN(Display
*dpy
, Window overlay
, Window underlay
, long *pTransparent
)
939 struct _glxapi_table
*t
;
940 GET_DISPATCH(dpy
, t
);
943 return (*t
->GetTransparentIndexSUN
)(dpy
, overlay
, underlay
, pTransparent
);
948 /*** GLX_MESA_copy_sub_buffer ***/
951 glXCopySubBufferMESA(Display
*dpy
, GLXDrawable drawable
, int x
, int y
, int width
, int height
)
953 struct _glxapi_table
*t
;
954 GET_DISPATCH(dpy
, t
);
957 (t
->CopySubBufferMESA
)(dpy
, drawable
, x
, y
, width
, height
);
962 /*** GLX_MESA_release_buffers ***/
965 glXReleaseBuffersMESA(Display
*dpy
, Window w
)
967 struct _glxapi_table
*t
;
968 GET_DISPATCH(dpy
, t
);
971 return (t
->ReleaseBuffersMESA
)(dpy
, w
);
976 /*** GLX_MESA_pixmap_colormap ***/
979 glXCreateGLXPixmapMESA(Display
*dpy
, XVisualInfo
*visinfo
, Pixmap pixmap
, Colormap cmap
)
981 struct _glxapi_table
*t
;
982 GET_DISPATCH(dpy
, t
);
985 return (t
->CreateGLXPixmapMESA
)(dpy
, visinfo
, pixmap
, cmap
);
990 /*** GLX_MESA_set_3dfx_mode ***/
993 glXSet3DfxModeMESA(int mode
)
995 struct _glxapi_table
*t
;
996 Display
*dpy
= glXGetCurrentDisplay();
997 GET_DISPATCH(dpy
, t
);
1000 return (t
->Set3DfxModeMESA
)(mode
);
1005 /*** GLX_NV_vertex_array_range ***/
1008 glXAllocateMemoryNV( GLsizei size
,
1009 GLfloat readFrequency
,
1010 GLfloat writeFrequency
,
1013 struct _glxapi_table
*t
;
1014 Display
*dpy
= glXGetCurrentDisplay();
1015 GET_DISPATCH(dpy
, t
);
1018 return (t
->AllocateMemoryNV
)(size
, readFrequency
, writeFrequency
, priority
);
1023 glXFreeMemoryNV( GLvoid
*pointer
)
1025 struct _glxapi_table
*t
;
1026 Display
*dpy
= glXGetCurrentDisplay();
1027 GET_DISPATCH(dpy
, t
);
1030 (t
->FreeMemoryNV
)(pointer
);
1036 /*** GLX_MESA_agp_offset */
1039 glXGetAGPOffsetMESA( const GLvoid
*pointer
)
1041 struct _glxapi_table
*t
;
1042 Display
*dpy
= glXGetCurrentDisplay();
1043 GET_DISPATCH(dpy
, t
);
1046 return (t
->GetAGPOffsetMESA
)(pointer
);
1050 /*** GLX_MESA_allocate_memory */
1053 glXAllocateMemoryMESA(Display
*dpy
, int scrn
, size_t size
,
1054 float readfreq
, float writefreq
, float priority
)
1061 glXFreeMemoryMESA(Display
*dpy
, int scrn
, void *pointer
)
1068 glXGetMemoryOffsetMESA(Display
*dpy
, int scrn
, const void *pointer
)
1076 /**********************************************************************/
1077 /* GLX API management functions */
1078 /**********************************************************************/
1082 _glxapi_get_version(void)
1089 * Return array of extension strings.
1092 _glxapi_get_extensions(void)
1094 static const char *extensions
[] = {
1095 #ifdef GLX_EXT_import_context
1096 "GLX_EXT_import_context",
1098 #ifdef GLX_SGI_video_sync
1099 "GLX_SGI_video_sync",
1101 #ifdef GLX_MESA_copy_sub_buffer
1102 "GLX_MESA_copy_sub_buffer",
1104 #ifdef GLX_MESA_release_buffers
1105 "GLX_MESA_release_buffers",
1107 #ifdef GLX_MESA_pixmap_colormap
1108 "GLX_MESA_pixmap_colormap",
1110 #ifdef GLX_MESA_set_3dfx_mode
1111 "GLX_MESA_set_3dfx_mode",
1113 #ifdef GLX_SGIX_fbconfig
1114 "GLX_SGIX_fbconfig",
1116 #ifdef GLX_SGIX_pbuffer
1126 * Return size of the GLX dispatch table, in entries, not bytes.
1129 _glxapi_get_dispatch_table_size(void)
1131 return sizeof(struct _glxapi_table
) / sizeof(void *);
1136 generic_no_op_func(void)
1143 * Initialize all functions in given dispatch table to be no-ops
1146 _glxapi_set_no_op_table(struct _glxapi_table
*t
)
1148 typedef int (*nop_func
)(void);
1149 nop_func
*dispatch
= (nop_func
*) t
;
1150 GLuint n
= _glxapi_get_dispatch_table_size();
1152 for (i
= 0; i
< n
; i
++) {
1153 dispatch
[i
] = generic_no_op_func
;
1158 struct name_address_pair
{
1160 __GLXextFuncPtr Address
;
1163 static struct name_address_pair GLX_functions
[] = {
1164 /*** GLX_VERSION_1_0 ***/
1165 { "glXChooseVisual", (__GLXextFuncPtr
) glXChooseVisual
},
1166 { "glXCopyContext", (__GLXextFuncPtr
) glXCopyContext
},
1167 { "glXCreateContext", (__GLXextFuncPtr
) glXCreateContext
},
1168 { "glXCreateGLXPixmap", (__GLXextFuncPtr
) glXCreateGLXPixmap
},
1169 { "glXDestroyContext", (__GLXextFuncPtr
) glXDestroyContext
},
1170 { "glXDestroyGLXPixmap", (__GLXextFuncPtr
) glXDestroyGLXPixmap
},
1171 { "glXGetConfig", (__GLXextFuncPtr
) glXGetConfig
},
1172 { "glXGetCurrentContext", (__GLXextFuncPtr
) glXGetCurrentContext
},
1173 { "glXGetCurrentDrawable", (__GLXextFuncPtr
) glXGetCurrentDrawable
},
1174 { "glXIsDirect", (__GLXextFuncPtr
) glXIsDirect
},
1175 { "glXMakeCurrent", (__GLXextFuncPtr
) glXMakeCurrent
},
1176 { "glXQueryExtension", (__GLXextFuncPtr
) glXQueryExtension
},
1177 { "glXQueryVersion", (__GLXextFuncPtr
) glXQueryVersion
},
1178 { "glXSwapBuffers", (__GLXextFuncPtr
) glXSwapBuffers
},
1179 { "glXUseXFont", (__GLXextFuncPtr
) glXUseXFont
},
1180 { "glXWaitGL", (__GLXextFuncPtr
) glXWaitGL
},
1181 { "glXWaitX", (__GLXextFuncPtr
) glXWaitX
},
1183 /*** GLX_VERSION_1_1 ***/
1184 { "glXGetClientString", (__GLXextFuncPtr
) glXGetClientString
},
1185 { "glXQueryExtensionsString", (__GLXextFuncPtr
) glXQueryExtensionsString
},
1186 { "glXQueryServerString", (__GLXextFuncPtr
) glXQueryServerString
},
1188 /*** GLX_VERSION_1_2 ***/
1189 { "glXGetCurrentDisplay", (__GLXextFuncPtr
) glXGetCurrentDisplay
},
1191 /*** GLX_VERSION_1_3 ***/
1192 { "glXChooseFBConfig", (__GLXextFuncPtr
) glXChooseFBConfig
},
1193 { "glXCreateNewContext", (__GLXextFuncPtr
) glXCreateNewContext
},
1194 { "glXCreatePbuffer", (__GLXextFuncPtr
) glXCreatePbuffer
},
1195 { "glXCreatePixmap", (__GLXextFuncPtr
) glXCreatePixmap
},
1196 { "glXCreateWindow", (__GLXextFuncPtr
) glXCreateWindow
},
1197 { "glXDestroyPbuffer", (__GLXextFuncPtr
) glXDestroyPbuffer
},
1198 { "glXDestroyPixmap", (__GLXextFuncPtr
) glXDestroyPixmap
},
1199 { "glXDestroyWindow", (__GLXextFuncPtr
) glXDestroyWindow
},
1200 { "glXGetCurrentReadDrawable", (__GLXextFuncPtr
) glXGetCurrentReadDrawable
},
1201 { "glXGetFBConfigAttrib", (__GLXextFuncPtr
) glXGetFBConfigAttrib
},
1202 { "glXGetFBConfigs", (__GLXextFuncPtr
) glXGetFBConfigs
},
1203 { "glXGetSelectedEvent", (__GLXextFuncPtr
) glXGetSelectedEvent
},
1204 { "glXGetVisualFromFBConfig", (__GLXextFuncPtr
) glXGetVisualFromFBConfig
},
1205 { "glXMakeContextCurrent", (__GLXextFuncPtr
) glXMakeContextCurrent
},
1206 { "glXQueryContext", (__GLXextFuncPtr
) glXQueryContext
},
1207 { "glXQueryDrawable", (__GLXextFuncPtr
) glXQueryDrawable
},
1208 { "glXSelectEvent", (__GLXextFuncPtr
) glXSelectEvent
},
1210 /*** GLX_VERSION_1_4 ***/
1211 { "glXGetProcAddress", (__GLXextFuncPtr
) glXGetProcAddress
},
1213 /*** GLX_SGI_swap_control ***/
1214 { "glXSwapIntervalSGI", (__GLXextFuncPtr
) glXSwapIntervalSGI
},
1216 /*** GLX_SGI_video_sync ***/
1217 { "glXGetVideoSyncSGI", (__GLXextFuncPtr
) glXGetVideoSyncSGI
},
1218 { "glXWaitVideoSyncSGI", (__GLXextFuncPtr
) glXWaitVideoSyncSGI
},
1220 /*** GLX_SGI_make_current_read ***/
1221 { "glXMakeCurrentReadSGI", (__GLXextFuncPtr
) glXMakeCurrentReadSGI
},
1222 { "glXGetCurrentReadDrawableSGI", (__GLXextFuncPtr
) glXGetCurrentReadDrawableSGI
},
1224 /*** GLX_SGIX_video_source ***/
1226 { "glXCreateGLXVideoSourceSGIX", (__GLXextFuncPtr
) glXCreateGLXVideoSourceSGIX
},
1227 { "glXDestroyGLXVideoSourceSGIX", (__GLXextFuncPtr
) glXDestroyGLXVideoSourceSGIX
},
1230 /*** GLX_EXT_import_context ***/
1231 { "glXFreeContextEXT", (__GLXextFuncPtr
) glXFreeContextEXT
},
1232 { "glXGetContextIDEXT", (__GLXextFuncPtr
) glXGetContextIDEXT
},
1233 { "glXGetCurrentDisplayEXT", (__GLXextFuncPtr
) glXGetCurrentDisplayEXT
},
1234 { "glXImportContextEXT", (__GLXextFuncPtr
) glXImportContextEXT
},
1235 { "glXQueryContextInfoEXT", (__GLXextFuncPtr
) glXQueryContextInfoEXT
},
1237 /*** GLX_SGIX_fbconfig ***/
1238 { "glXGetFBConfigAttribSGIX", (__GLXextFuncPtr
) glXGetFBConfigAttribSGIX
},
1239 { "glXChooseFBConfigSGIX", (__GLXextFuncPtr
) glXChooseFBConfigSGIX
},
1240 { "glXCreateGLXPixmapWithConfigSGIX", (__GLXextFuncPtr
) glXCreateGLXPixmapWithConfigSGIX
},
1241 { "glXCreateContextWithConfigSGIX", (__GLXextFuncPtr
) glXCreateContextWithConfigSGIX
},
1242 { "glXGetVisualFromFBConfigSGIX", (__GLXextFuncPtr
) glXGetVisualFromFBConfigSGIX
},
1243 { "glXGetFBConfigFromVisualSGIX", (__GLXextFuncPtr
) glXGetFBConfigFromVisualSGIX
},
1245 /*** GLX_SGIX_pbuffer ***/
1246 { "glXCreateGLXPbufferSGIX", (__GLXextFuncPtr
) glXCreateGLXPbufferSGIX
},
1247 { "glXDestroyGLXPbufferSGIX", (__GLXextFuncPtr
) glXDestroyGLXPbufferSGIX
},
1248 { "glXQueryGLXPbufferSGIX", (__GLXextFuncPtr
) glXQueryGLXPbufferSGIX
},
1249 { "glXSelectEventSGIX", (__GLXextFuncPtr
) glXSelectEventSGIX
},
1250 { "glXGetSelectedEventSGIX", (__GLXextFuncPtr
) glXGetSelectedEventSGIX
},
1252 /*** GLX_SGI_cushion ***/
1253 { "glXCushionSGI", (__GLXextFuncPtr
) glXCushionSGI
},
1255 /*** GLX_SGIX_video_resize ***/
1256 { "glXBindChannelToWindowSGIX", (__GLXextFuncPtr
) glXBindChannelToWindowSGIX
},
1257 { "glXChannelRectSGIX", (__GLXextFuncPtr
) glXChannelRectSGIX
},
1258 { "glXQueryChannelRectSGIX", (__GLXextFuncPtr
) glXQueryChannelRectSGIX
},
1259 { "glXQueryChannelDeltasSGIX", (__GLXextFuncPtr
) glXQueryChannelDeltasSGIX
},
1260 { "glXChannelRectSyncSGIX", (__GLXextFuncPtr
) glXChannelRectSyncSGIX
},
1262 /*** GLX_SGIX_dmbuffer **/
1263 #if defined(_DM_BUFFER_H_)
1264 { "glXAssociateDMPbufferSGIX", (__GLXextFuncPtr
) glXAssociateDMPbufferSGIX
},
1267 /*** GLX_SGIX_swap_group ***/
1268 { "glXJoinSwapGroupSGIX", (__GLXextFuncPtr
) glXJoinSwapGroupSGIX
},
1270 /*** GLX_SGIX_swap_barrier ***/
1271 { "glXBindSwapBarrierSGIX", (__GLXextFuncPtr
) glXBindSwapBarrierSGIX
},
1272 { "glXQueryMaxSwapBarriersSGIX", (__GLXextFuncPtr
) glXQueryMaxSwapBarriersSGIX
},
1274 /*** GLX_SUN_get_transparent_index ***/
1275 { "glXGetTransparentIndexSUN", (__GLXextFuncPtr
) glXGetTransparentIndexSUN
},
1277 /*** GLX_MESA_copy_sub_buffer ***/
1278 { "glXCopySubBufferMESA", (__GLXextFuncPtr
) glXCopySubBufferMESA
},
1280 /*** GLX_MESA_pixmap_colormap ***/
1281 { "glXCreateGLXPixmapMESA", (__GLXextFuncPtr
) glXCreateGLXPixmapMESA
},
1283 /*** GLX_MESA_release_buffers ***/
1284 { "glXReleaseBuffersMESA", (__GLXextFuncPtr
) glXReleaseBuffersMESA
},
1286 /*** GLX_MESA_set_3dfx_mode ***/
1287 { "glXSet3DfxModeMESA", (__GLXextFuncPtr
) glXSet3DfxModeMESA
},
1289 /*** GLX_ARB_get_proc_address ***/
1290 { "glXGetProcAddressARB", (__GLXextFuncPtr
) glXGetProcAddressARB
},
1292 /*** GLX_NV_vertex_array_range ***/
1293 { "glXAllocateMemoryNV", (__GLXextFuncPtr
) glXAllocateMemoryNV
},
1294 { "glXFreeMemoryNV", (__GLXextFuncPtr
) glXFreeMemoryNV
},
1296 /*** GLX_MESA_agp_offset ***/
1297 { "glXGetAGPOffsetMESA", (__GLXextFuncPtr
) glXGetAGPOffsetMESA
},
1299 /*** GLX_MESA_allocate_memory ***/
1300 { "glXAllocateMemoryMESA", (__GLXextFuncPtr
) glXAllocateMemoryMESA
},
1301 { "glXFreeMemoryMESA", (__GLXextFuncPtr
) glXFreeMemoryMESA
},
1302 { "glXGetMemoryOffsetMESA", (__GLXextFuncPtr
) glXGetMemoryOffsetMESA
},
1304 { NULL
, NULL
} /* end of list */
1310 * Return address of named glX function, or NULL if not found.
1313 _glxapi_get_proc_address(const char *funcName
)
1316 for (i
= 0; GLX_functions
[i
].Name
; i
++) {
1317 if (strcmp(GLX_functions
[i
].Name
, funcName
) == 0)
1318 return GLX_functions
[i
].Address
;
1326 * This function does not get dispatched through the dispatch table
1327 * since it's really a "meta" function.
1330 glXGetProcAddressARB(const GLubyte
*procName
)
1334 f
= _glxapi_get_proc_address((const char *) procName
);
1339 f
= (__GLXextFuncPtr
) _glapi_get_proc_address((const char *) procName
);
1345 void (*glXGetProcAddress(const GLubyte
*procName
))()
1347 return glXGetProcAddressARB(procName
);