2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 * This is the GLX API dispatcher. Calls to the glX* functions are
28 * either routed to the real GLX encoders or to Mesa's pseudo-GLX functions.
29 * See the glxapi.h file for more details.
42 extern struct _glxapi_table
*_real_GetGLXDispatchTable(void);
43 extern struct _glxapi_table
*_mesa_GetGLXDispatchTable(void);
46 struct display_dispatch
{
48 struct _glxapi_table
*Table
;
49 struct display_dispatch
*Next
;
52 static struct display_dispatch
*DispatchList
= NULL
;
55 /* Display -> Dispatch caching */
56 static Display
*prevDisplay
= NULL
;
57 static struct _glxapi_table
*prevTable
= NULL
;
60 static struct _glxapi_table
*
61 get_dispatch(Display
*dpy
)
66 /* search list of display/dispatch pairs for this display */
68 const struct display_dispatch
*d
= DispatchList
;
73 return d
->Table
; /* done! */
79 /* A new display, determine if we should use real GLX
80 * or Mesa's pseudo-GLX.
83 struct _glxapi_table
*t
= _mesa_GetGLXDispatchTable();
86 struct display_dispatch
*d
;
87 d
= (struct display_dispatch
*) malloc(sizeof(struct display_dispatch
));
91 /* insert at head of list */
92 d
->Next
= DispatchList
;
102 /* If we get here that means we can't use real GLX on this display
103 * and the Mesa pseudo-GLX software renderer wasn't compiled in.
104 * Or, we ran out of memory!
110 /* Don't use the GET_DISPATCH defined in glthread.h */
113 #define GET_DISPATCH(DPY, TABLE) \
114 if (DPY == prevDisplay) { \
121 TABLE = get_dispatch(DPY); \
127 /* Set by glXMakeCurrent() and glXMakeContextCurrent() only */
128 static GLXContext CurrentContext
= 0;
129 #define __glXGetCurrentContext() CurrentContext;
133 * GLX API entrypoints
136 /*** GLX_VERSION_1_0 ***/
139 glXChooseVisual(Display
*dpy
, int screen
, int *list
)
141 struct _glxapi_table
*t
;
142 GET_DISPATCH(dpy
, t
);
145 return (t
->ChooseVisual
)(dpy
, screen
, list
);
150 glXCopyContext(Display
*dpy
, GLXContext src
, GLXContext dst
, unsigned long mask
)
152 struct _glxapi_table
*t
;
153 GET_DISPATCH(dpy
, t
);
156 (t
->CopyContext
)(dpy
, src
, dst
, mask
);
161 glXCreateContext(Display
*dpy
, XVisualInfo
*visinfo
, GLXContext shareList
, Bool direct
)
163 struct _glxapi_table
*t
;
164 GET_DISPATCH(dpy
, t
);
167 return (t
->CreateContext
)(dpy
, visinfo
, shareList
, direct
);
172 glXCreateGLXPixmap(Display
*dpy
, XVisualInfo
*visinfo
, Pixmap pixmap
)
174 struct _glxapi_table
*t
;
175 GET_DISPATCH(dpy
, t
);
178 return (t
->CreateGLXPixmap
)(dpy
, visinfo
, pixmap
);
183 glXDestroyContext(Display
*dpy
, GLXContext ctx
)
185 struct _glxapi_table
*t
;
186 GET_DISPATCH(dpy
, t
);
189 (t
->DestroyContext
)(dpy
, ctx
);
194 glXDestroyGLXPixmap(Display
*dpy
, GLXPixmap pixmap
)
196 struct _glxapi_table
*t
;
197 GET_DISPATCH(dpy
, t
);
200 (t
->DestroyGLXPixmap
)(dpy
, pixmap
);
205 glXGetConfig(Display
*dpy
, XVisualInfo
*visinfo
, int attrib
, int *value
)
207 struct _glxapi_table
*t
;
208 GET_DISPATCH(dpy
, t
);
210 return GLX_NO_EXTENSION
;
211 return (t
->GetConfig
)(dpy
, visinfo
, attrib
, value
);
216 glXGetCurrentContext(void)
218 return CurrentContext
;
223 glXGetCurrentDrawable(void)
225 __GLXcontext
*gc
= (__GLXcontext
*) glXGetCurrentContext();
226 return gc
? gc
->currentDrawable
: 0;
231 glXIsDirect(Display
*dpy
, GLXContext ctx
)
233 struct _glxapi_table
*t
;
234 GET_DISPATCH(dpy
, t
);
237 return (t
->IsDirect
)(dpy
, ctx
);
242 glXMakeCurrent(Display
*dpy
, GLXDrawable drawable
, GLXContext ctx
)
245 struct _glxapi_table
*t
;
246 GET_DISPATCH(dpy
, t
);
250 b
= (*t
->MakeCurrent
)(dpy
, drawable
, ctx
);
252 CurrentContext
= ctx
;
259 glXQueryExtension(Display
*dpy
, int *errorb
, int *event
)
261 struct _glxapi_table
*t
;
262 GET_DISPATCH(dpy
, t
);
265 return (t
->QueryExtension
)(dpy
, errorb
, event
);
270 glXQueryVersion(Display
*dpy
, int *maj
, int *min
)
272 struct _glxapi_table
*t
;
273 GET_DISPATCH(dpy
, t
);
276 return (t
->QueryVersion
)(dpy
, maj
, min
);
281 glXSwapBuffers(Display
*dpy
, GLXDrawable drawable
)
283 struct _glxapi_table
*t
;
284 GET_DISPATCH(dpy
, t
);
287 (t
->SwapBuffers
)(dpy
, drawable
);
292 glXUseXFont(Font font
, int first
, int count
, int listBase
)
294 struct _glxapi_table
*t
;
295 Display
*dpy
= glXGetCurrentDisplay();
296 GET_DISPATCH(dpy
, t
);
299 (t
->UseXFont
)(font
, first
, count
, listBase
);
306 struct _glxapi_table
*t
;
307 Display
*dpy
= glXGetCurrentDisplay();
308 GET_DISPATCH(dpy
, t
);
318 struct _glxapi_table
*t
;
319 Display
*dpy
= glXGetCurrentDisplay();
320 GET_DISPATCH(dpy
, t
);
328 /*** GLX_VERSION_1_1 ***/
331 glXGetClientString(Display
*dpy
, int name
)
333 struct _glxapi_table
*t
;
334 GET_DISPATCH(dpy
, t
);
337 return (t
->GetClientString
)(dpy
, name
);
342 glXQueryExtensionsString(Display
*dpy
, int screen
)
344 struct _glxapi_table
*t
;
345 GET_DISPATCH(dpy
, t
);
348 return (t
->QueryExtensionsString
)(dpy
, screen
);
353 glXQueryServerString(Display
*dpy
, int screen
, int name
)
355 struct _glxapi_table
*t
;
356 GET_DISPATCH(dpy
, t
);
359 return (t
->QueryServerString
)(dpy
, screen
, name
);
363 /*** GLX_VERSION_1_2 ***/
366 glXGetCurrentDisplay(void)
368 /* Same code as in libGL's glxext.c */
369 __GLXcontext
*gc
= (__GLXcontext
*) glXGetCurrentContext();
370 if (NULL
== gc
) return NULL
;
371 return gc
->currentDpy
;
376 /*** GLX_VERSION_1_3 ***/
379 glXChooseFBConfig(Display
*dpy
, int screen
, const int *attribList
, int *nitems
)
381 struct _glxapi_table
*t
;
382 GET_DISPATCH(dpy
, t
);
385 return (t
->ChooseFBConfig
)(dpy
, screen
, attribList
, nitems
);
390 glXCreateNewContext(Display
*dpy
, GLXFBConfig config
, int renderType
, GLXContext shareList
, Bool direct
)
392 struct _glxapi_table
*t
;
393 GET_DISPATCH(dpy
, t
);
396 return (t
->CreateNewContext
)(dpy
, config
, renderType
, shareList
, direct
);
401 glXCreatePbuffer(Display
*dpy
, GLXFBConfig config
, const int *attribList
)
403 struct _glxapi_table
*t
;
404 GET_DISPATCH(dpy
, t
);
407 return (t
->CreatePbuffer
)(dpy
, config
, attribList
);
412 glXCreatePixmap(Display
*dpy
, GLXFBConfig config
, Pixmap pixmap
, const int *attribList
)
414 struct _glxapi_table
*t
;
415 GET_DISPATCH(dpy
, t
);
418 return (t
->CreatePixmap
)(dpy
, config
, pixmap
, attribList
);
423 glXCreateWindow(Display
*dpy
, GLXFBConfig config
, Window win
, const int *attribList
)
425 struct _glxapi_table
*t
;
426 GET_DISPATCH(dpy
, t
);
429 return (t
->CreateWindow
)(dpy
, config
, win
, attribList
);
434 glXDestroyPbuffer(Display
*dpy
, GLXPbuffer pbuf
)
436 struct _glxapi_table
*t
;
437 GET_DISPATCH(dpy
, t
);
440 (t
->DestroyPbuffer
)(dpy
, pbuf
);
445 glXDestroyPixmap(Display
*dpy
, GLXPixmap pixmap
)
447 struct _glxapi_table
*t
;
448 GET_DISPATCH(dpy
, t
);
451 (t
->DestroyPixmap
)(dpy
, pixmap
);
456 glXDestroyWindow(Display
*dpy
, GLXWindow window
)
458 struct _glxapi_table
*t
;
459 GET_DISPATCH(dpy
, t
);
462 (t
->DestroyWindow
)(dpy
, window
);
467 glXGetCurrentReadDrawable(void)
469 __GLXcontext
*gc
= (__GLXcontext
*) glXGetCurrentContext();
470 return gc
? gc
->currentReadable
: 0;
475 glXGetFBConfigAttrib(Display
*dpy
, GLXFBConfig config
, int attribute
, int *value
)
477 struct _glxapi_table
*t
;
478 GET_DISPATCH(dpy
, t
);
480 return GLX_NO_EXTENSION
;
481 return (t
->GetFBConfigAttrib
)(dpy
, config
, attribute
, value
);
486 glXGetFBConfigs(Display
*dpy
, int screen
, int *nelements
)
488 struct _glxapi_table
*t
;
489 GET_DISPATCH(dpy
, t
);
492 return (t
->GetFBConfigs
)(dpy
, screen
, nelements
);
496 glXGetSelectedEvent(Display
*dpy
, GLXDrawable drawable
, unsigned long *mask
)
498 struct _glxapi_table
*t
;
499 GET_DISPATCH(dpy
, t
);
502 (t
->GetSelectedEvent
)(dpy
, drawable
, mask
);
507 glXGetVisualFromFBConfig(Display
*dpy
, GLXFBConfig config
)
509 struct _glxapi_table
*t
;
510 GET_DISPATCH(dpy
, t
);
513 return (t
->GetVisualFromFBConfig
)(dpy
, config
);
518 glXMakeContextCurrent(Display
*dpy
, GLXDrawable draw
, GLXDrawable read
, GLXContext ctx
)
521 struct _glxapi_table
*t
;
522 GET_DISPATCH(dpy
, t
);
525 b
= (t
->MakeContextCurrent
)(dpy
, draw
, read
, ctx
);
527 CurrentContext
= ctx
;
534 glXQueryContext(Display
*dpy
, GLXContext ctx
, int attribute
, int *value
)
536 struct _glxapi_table
*t
;
537 GET_DISPATCH(dpy
, t
);
540 return 0; /* XXX correct? */
541 return (t
->QueryContext
)(dpy
, ctx
, attribute
, value
);
546 glXQueryDrawable(Display
*dpy
, GLXDrawable draw
, int attribute
, unsigned int *value
)
548 struct _glxapi_table
*t
;
549 GET_DISPATCH(dpy
, t
);
552 (t
->QueryDrawable
)(dpy
, draw
, attribute
, value
);
557 glXSelectEvent(Display
*dpy
, GLXDrawable drawable
, unsigned long mask
)
559 struct _glxapi_table
*t
;
560 GET_DISPATCH(dpy
, t
);
563 (t
->SelectEvent
)(dpy
, drawable
, mask
);
568 /*** GLX_SGI_swap_control ***/
571 glXSwapIntervalSGI(int interval
)
573 struct _glxapi_table
*t
;
574 Display
*dpy
= glXGetCurrentDisplay();
575 GET_DISPATCH(dpy
, t
);
578 return (t
->SwapIntervalSGI
)(interval
);
583 /*** GLX_SGI_video_sync ***/
586 glXGetVideoSyncSGI(unsigned int *count
)
588 struct _glxapi_table
*t
;
589 Display
*dpy
= glXGetCurrentDisplay();
590 GET_DISPATCH(dpy
, t
);
591 if (!t
|| !glXGetCurrentContext())
592 return GLX_BAD_CONTEXT
;
593 return (t
->GetVideoSyncSGI
)(count
);
597 glXWaitVideoSyncSGI(int divisor
, int remainder
, unsigned int *count
)
599 struct _glxapi_table
*t
;
600 Display
*dpy
= glXGetCurrentDisplay();
601 GET_DISPATCH(dpy
, t
);
602 if (!t
|| !glXGetCurrentContext())
603 return GLX_BAD_CONTEXT
;
604 return (t
->WaitVideoSyncSGI
)(divisor
, remainder
, count
);
609 /*** GLX_SGI_make_current_read ***/
612 glXMakeCurrentReadSGI(Display
*dpy
, GLXDrawable draw
, GLXDrawable read
, GLXContext ctx
)
614 struct _glxapi_table
*t
;
615 GET_DISPATCH(dpy
, t
);
618 return (t
->MakeCurrentReadSGI
)(dpy
, draw
, read
, ctx
);
622 glXGetCurrentReadDrawableSGI(void)
624 return glXGetCurrentReadDrawable();
630 GLXVideoSourceSGIX PUBLIC
631 glXCreateGLXVideoSourceSGIX(Display
*dpy
, int screen
, VLServer server
, VLPath path
, int nodeClass
, VLNode drainNode
)
633 struct _glxapi_table
*t
;
634 GET_DISPATCH(dpy
, t
);
637 return (t
->CreateGLXVideoSourceSGIX
)(dpy
, screen
, server
, path
, nodeClass
, drainNode
);
641 glXDestroyGLXVideoSourceSGIX(Display
*dpy
, GLXVideoSourceSGIX src
)
643 struct _glxapi_table
*t
;
644 GET_DISPATCH(dpy
, t
);
647 return (t
->DestroyGLXVideoSourceSGIX
)(dpy
, src
);
653 /*** GLX_EXT_import_context ***/
656 glXFreeContextEXT(Display
*dpy
, GLXContext context
)
658 struct _glxapi_table
*t
;
659 GET_DISPATCH(dpy
, t
);
662 (t
->FreeContextEXT
)(dpy
, context
);
666 glXGetContextIDEXT(const GLXContext context
)
668 return ((__GLXcontext
*) context
)->xid
;
672 glXGetCurrentDisplayEXT(void)
674 return glXGetCurrentDisplay();
678 glXImportContextEXT(Display
*dpy
, GLXContextID contextID
)
680 struct _glxapi_table
*t
;
681 GET_DISPATCH(dpy
, t
);
684 return (t
->ImportContextEXT
)(dpy
, contextID
);
688 glXQueryContextInfoEXT(Display
*dpy
, GLXContext context
, int attribute
,int *value
)
690 struct _glxapi_table
*t
;
691 GET_DISPATCH(dpy
, t
);
693 return 0; /* XXX ok? */
694 return (t
->QueryContextInfoEXT
)(dpy
, context
, attribute
, value
);
699 /*** GLX_SGIX_fbconfig ***/
702 glXGetFBConfigAttribSGIX(Display
*dpy
, GLXFBConfigSGIX config
, int attribute
, int *value
)
704 struct _glxapi_table
*t
;
705 GET_DISPATCH(dpy
, t
);
708 return (t
->GetFBConfigAttribSGIX
)(dpy
, config
, attribute
, value
);
711 GLXFBConfigSGIX PUBLIC
*
712 glXChooseFBConfigSGIX(Display
*dpy
, int screen
, int *attrib_list
, int *nelements
)
714 struct _glxapi_table
*t
;
715 GET_DISPATCH(dpy
, t
);
718 return (t
->ChooseFBConfigSGIX
)(dpy
, screen
, attrib_list
, nelements
);
722 glXCreateGLXPixmapWithConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
, Pixmap pixmap
)
724 struct _glxapi_table
*t
;
725 GET_DISPATCH(dpy
, t
);
728 return (t
->CreateGLXPixmapWithConfigSGIX
)(dpy
, config
, pixmap
);
732 glXCreateContextWithConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
, int render_type
, GLXContext share_list
, Bool direct
)
734 struct _glxapi_table
*t
;
735 GET_DISPATCH(dpy
, t
);
738 return (t
->CreateContextWithConfigSGIX
)(dpy
, config
, render_type
, share_list
, direct
);
742 glXGetVisualFromFBConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
)
744 struct _glxapi_table
*t
;
745 GET_DISPATCH(dpy
, t
);
748 return (t
->GetVisualFromFBConfigSGIX
)(dpy
, config
);
751 GLXFBConfigSGIX PUBLIC
752 glXGetFBConfigFromVisualSGIX(Display
*dpy
, XVisualInfo
*vis
)
754 struct _glxapi_table
*t
;
755 GET_DISPATCH(dpy
, t
);
758 return (t
->GetFBConfigFromVisualSGIX
)(dpy
, vis
);
763 /*** GLX_SGIX_pbuffer ***/
765 GLXPbufferSGIX PUBLIC
766 glXCreateGLXPbufferSGIX(Display
*dpy
, GLXFBConfigSGIX config
, unsigned int width
, unsigned int height
, int *attrib_list
)
768 struct _glxapi_table
*t
;
769 GET_DISPATCH(dpy
, t
);
772 return (t
->CreateGLXPbufferSGIX
)(dpy
, config
, width
, height
, attrib_list
);
776 glXDestroyGLXPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuf
)
778 struct _glxapi_table
*t
;
779 GET_DISPATCH(dpy
, t
);
782 (t
->DestroyGLXPbufferSGIX
)(dpy
, pbuf
);
786 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
);
796 glXSelectEventSGIX(Display
*dpy
, GLXDrawable drawable
, unsigned long mask
)
798 struct _glxapi_table
*t
;
799 GET_DISPATCH(dpy
, t
);
802 (t
->SelectEventSGIX
)(dpy
, drawable
, mask
);
806 glXGetSelectedEventSGIX(Display
*dpy
, GLXDrawable drawable
, unsigned long *mask
)
808 struct _glxapi_table
*t
;
809 GET_DISPATCH(dpy
, t
);
812 (t
->GetSelectedEventSGIX
)(dpy
, drawable
, mask
);
817 /*** GLX_SGI_cushion ***/
820 glXCushionSGI(Display
*dpy
, Window win
, float cushion
)
822 struct _glxapi_table
*t
;
823 GET_DISPATCH(dpy
, t
);
826 (t
->CushionSGI
)(dpy
, win
, cushion
);
831 /*** GLX_SGIX_video_resize ***/
834 glXBindChannelToWindowSGIX(Display
*dpy
, int screen
, int channel
, Window window
)
836 struct _glxapi_table
*t
;
837 GET_DISPATCH(dpy
, t
);
840 return (t
->BindChannelToWindowSGIX
)(dpy
, screen
, channel
, window
);
844 glXChannelRectSGIX(Display
*dpy
, int screen
, int channel
, int x
, int y
, int w
, int h
)
846 struct _glxapi_table
*t
;
847 GET_DISPATCH(dpy
, t
);
850 return (t
->ChannelRectSGIX
)(dpy
, screen
, channel
, x
, y
, w
, h
);
854 glXQueryChannelRectSGIX(Display
*dpy
, int screen
, int channel
, int *x
, int *y
, int *w
, int *h
)
856 struct _glxapi_table
*t
;
857 GET_DISPATCH(dpy
, t
);
860 return (t
->QueryChannelRectSGIX
)(dpy
, screen
, channel
, x
, y
, w
, h
);
864 glXQueryChannelDeltasSGIX(Display
*dpy
, int screen
, int channel
, int *dx
, int *dy
, int *dw
, int *dh
)
866 struct _glxapi_table
*t
;
867 GET_DISPATCH(dpy
, t
);
870 return (t
->QueryChannelDeltasSGIX
)(dpy
, screen
, channel
, dx
, dy
, dw
, dh
);
874 glXChannelRectSyncSGIX(Display
*dpy
, int screen
, int channel
, GLenum synctype
)
876 struct _glxapi_table
*t
;
877 GET_DISPATCH(dpy
, t
);
880 return (t
->ChannelRectSyncSGIX
)(dpy
, screen
, channel
, synctype
);
885 #if defined(_DM_BUFFER_H_)
888 glXAssociateDMPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuffer
, DMparams
*params
, DMbuffer dmbuffer
)
890 struct _glxapi_table
*t
;
891 GET_DISPATCH(dpy
, t
);
894 return (t
->AssociateDMPbufferSGIX
)(dpy
, pbuffer
, params
, dmbuffer
);
900 /*** GLX_SGIX_swap_group ***/
903 glXJoinSwapGroupSGIX(Display
*dpy
, GLXDrawable drawable
, GLXDrawable member
)
905 struct _glxapi_table
*t
;
906 GET_DISPATCH(dpy
, t
);
909 (*t
->JoinSwapGroupSGIX
)(dpy
, drawable
, member
);
913 /*** GLX_SGIX_swap_barrier ***/
916 glXBindSwapBarrierSGIX(Display
*dpy
, GLXDrawable drawable
, int barrier
)
918 struct _glxapi_table
*t
;
919 GET_DISPATCH(dpy
, t
);
922 (*t
->BindSwapBarrierSGIX
)(dpy
, drawable
, barrier
);
926 glXQueryMaxSwapBarriersSGIX(Display
*dpy
, int screen
, int *max
)
928 struct _glxapi_table
*t
;
929 GET_DISPATCH(dpy
, t
);
932 return (*t
->QueryMaxSwapBarriersSGIX
)(dpy
, screen
, max
);
937 /*** GLX_SUN_get_transparent_index ***/
940 glXGetTransparentIndexSUN(Display
*dpy
, Window overlay
, Window underlay
, long *pTransparent
)
942 struct _glxapi_table
*t
;
943 GET_DISPATCH(dpy
, t
);
946 return (*t
->GetTransparentIndexSUN
)(dpy
, overlay
, underlay
, pTransparent
);
951 /*** GLX_MESA_copy_sub_buffer ***/
954 glXCopySubBufferMESA(Display
*dpy
, GLXDrawable drawable
, int x
, int y
, int width
, int height
)
956 struct _glxapi_table
*t
;
957 GET_DISPATCH(dpy
, t
);
960 (t
->CopySubBufferMESA
)(dpy
, drawable
, x
, y
, width
, height
);
965 /*** GLX_MESA_release_buffers ***/
968 glXReleaseBuffersMESA(Display
*dpy
, Window w
)
970 struct _glxapi_table
*t
;
971 GET_DISPATCH(dpy
, t
);
974 return (t
->ReleaseBuffersMESA
)(dpy
, w
);
979 /*** GLX_MESA_pixmap_colormap ***/
982 glXCreateGLXPixmapMESA(Display
*dpy
, XVisualInfo
*visinfo
, Pixmap pixmap
, Colormap cmap
)
984 struct _glxapi_table
*t
;
985 GET_DISPATCH(dpy
, t
);
988 return (t
->CreateGLXPixmapMESA
)(dpy
, visinfo
, pixmap
, cmap
);
993 /*** GLX_MESA_set_3dfx_mode ***/
996 glXSet3DfxModeMESA(int mode
)
998 struct _glxapi_table
*t
;
999 Display
*dpy
= glXGetCurrentDisplay();
1000 GET_DISPATCH(dpy
, t
);
1003 return (t
->Set3DfxModeMESA
)(mode
);
1008 /*** GLX_NV_vertex_array_range ***/
1011 glXAllocateMemoryNV( GLsizei size
,
1012 GLfloat readFrequency
,
1013 GLfloat writeFrequency
,
1016 struct _glxapi_table
*t
;
1017 Display
*dpy
= glXGetCurrentDisplay();
1018 GET_DISPATCH(dpy
, t
);
1021 return (t
->AllocateMemoryNV
)(size
, readFrequency
, writeFrequency
, priority
);
1026 glXFreeMemoryNV( GLvoid
*pointer
)
1028 struct _glxapi_table
*t
;
1029 Display
*dpy
= glXGetCurrentDisplay();
1030 GET_DISPATCH(dpy
, t
);
1033 (t
->FreeMemoryNV
)(pointer
);
1039 /*** GLX_MESA_agp_offset */
1042 glXGetAGPOffsetMESA( const GLvoid
*pointer
)
1044 struct _glxapi_table
*t
;
1045 Display
*dpy
= glXGetCurrentDisplay();
1046 GET_DISPATCH(dpy
, t
);
1049 return (t
->GetAGPOffsetMESA
)(pointer
);
1053 /*** GLX_MESA_allocate_memory */
1056 glXAllocateMemoryMESA(Display
*dpy
, int scrn
, size_t size
,
1057 float readfreq
, float writefreq
, float priority
)
1064 glXFreeMemoryMESA(Display
*dpy
, int scrn
, void *pointer
)
1071 glXGetMemoryOffsetMESA(Display
*dpy
, int scrn
, const void *pointer
)
1079 /**********************************************************************/
1080 /* GLX API management functions */
1081 /**********************************************************************/
1085 _glxapi_get_version(void)
1092 * Return array of extension strings.
1095 _glxapi_get_extensions(void)
1097 static const char *extensions
[] = {
1098 #ifdef GLX_EXT_import_context
1099 "GLX_EXT_import_context",
1101 #ifdef GLX_SGI_video_sync
1102 "GLX_SGI_video_sync",
1104 #ifdef GLX_MESA_copy_sub_buffer
1105 "GLX_MESA_copy_sub_buffer",
1107 #ifdef GLX_MESA_release_buffers
1108 "GLX_MESA_release_buffers",
1110 #ifdef GLX_MESA_pixmap_colormap
1111 "GLX_MESA_pixmap_colormap",
1113 #ifdef GLX_MESA_set_3dfx_mode
1114 "GLX_MESA_set_3dfx_mode",
1116 #ifdef GLX_SGIX_fbconfig
1117 "GLX_SGIX_fbconfig",
1119 #ifdef GLX_SGIX_pbuffer
1129 * Return size of the GLX dispatch table, in entries, not bytes.
1132 _glxapi_get_dispatch_table_size(void)
1134 return sizeof(struct _glxapi_table
) / sizeof(void *);
1139 generic_no_op_func(void)
1146 * Initialize all functions in given dispatch table to be no-ops
1149 _glxapi_set_no_op_table(struct _glxapi_table
*t
)
1151 typedef int (*nop_func
)(void);
1152 nop_func
*dispatch
= (nop_func
*) t
;
1153 GLuint n
= _glxapi_get_dispatch_table_size();
1155 for (i
= 0; i
< n
; i
++) {
1156 dispatch
[i
] = generic_no_op_func
;
1161 struct name_address_pair
{
1163 __GLXextFuncPtr Address
;
1166 static struct name_address_pair GLX_functions
[] = {
1167 /*** GLX_VERSION_1_0 ***/
1168 { "glXChooseVisual", (__GLXextFuncPtr
) glXChooseVisual
},
1169 { "glXCopyContext", (__GLXextFuncPtr
) glXCopyContext
},
1170 { "glXCreateContext", (__GLXextFuncPtr
) glXCreateContext
},
1171 { "glXCreateGLXPixmap", (__GLXextFuncPtr
) glXCreateGLXPixmap
},
1172 { "glXDestroyContext", (__GLXextFuncPtr
) glXDestroyContext
},
1173 { "glXDestroyGLXPixmap", (__GLXextFuncPtr
) glXDestroyGLXPixmap
},
1174 { "glXGetConfig", (__GLXextFuncPtr
) glXGetConfig
},
1175 { "glXGetCurrentContext", (__GLXextFuncPtr
) glXGetCurrentContext
},
1176 { "glXGetCurrentDrawable", (__GLXextFuncPtr
) glXGetCurrentDrawable
},
1177 { "glXIsDirect", (__GLXextFuncPtr
) glXIsDirect
},
1178 { "glXMakeCurrent", (__GLXextFuncPtr
) glXMakeCurrent
},
1179 { "glXQueryExtension", (__GLXextFuncPtr
) glXQueryExtension
},
1180 { "glXQueryVersion", (__GLXextFuncPtr
) glXQueryVersion
},
1181 { "glXSwapBuffers", (__GLXextFuncPtr
) glXSwapBuffers
},
1182 { "glXUseXFont", (__GLXextFuncPtr
) glXUseXFont
},
1183 { "glXWaitGL", (__GLXextFuncPtr
) glXWaitGL
},
1184 { "glXWaitX", (__GLXextFuncPtr
) glXWaitX
},
1186 /*** GLX_VERSION_1_1 ***/
1187 { "glXGetClientString", (__GLXextFuncPtr
) glXGetClientString
},
1188 { "glXQueryExtensionsString", (__GLXextFuncPtr
) glXQueryExtensionsString
},
1189 { "glXQueryServerString", (__GLXextFuncPtr
) glXQueryServerString
},
1191 /*** GLX_VERSION_1_2 ***/
1192 { "glXGetCurrentDisplay", (__GLXextFuncPtr
) glXGetCurrentDisplay
},
1194 /*** GLX_VERSION_1_3 ***/
1195 { "glXChooseFBConfig", (__GLXextFuncPtr
) glXChooseFBConfig
},
1196 { "glXCreateNewContext", (__GLXextFuncPtr
) glXCreateNewContext
},
1197 { "glXCreatePbuffer", (__GLXextFuncPtr
) glXCreatePbuffer
},
1198 { "glXCreatePixmap", (__GLXextFuncPtr
) glXCreatePixmap
},
1199 { "glXCreateWindow", (__GLXextFuncPtr
) glXCreateWindow
},
1200 { "glXDestroyPbuffer", (__GLXextFuncPtr
) glXDestroyPbuffer
},
1201 { "glXDestroyPixmap", (__GLXextFuncPtr
) glXDestroyPixmap
},
1202 { "glXDestroyWindow", (__GLXextFuncPtr
) glXDestroyWindow
},
1203 { "glXGetCurrentReadDrawable", (__GLXextFuncPtr
) glXGetCurrentReadDrawable
},
1204 { "glXGetFBConfigAttrib", (__GLXextFuncPtr
) glXGetFBConfigAttrib
},
1205 { "glXGetFBConfigs", (__GLXextFuncPtr
) glXGetFBConfigs
},
1206 { "glXGetSelectedEvent", (__GLXextFuncPtr
) glXGetSelectedEvent
},
1207 { "glXGetVisualFromFBConfig", (__GLXextFuncPtr
) glXGetVisualFromFBConfig
},
1208 { "glXMakeContextCurrent", (__GLXextFuncPtr
) glXMakeContextCurrent
},
1209 { "glXQueryContext", (__GLXextFuncPtr
) glXQueryContext
},
1210 { "glXQueryDrawable", (__GLXextFuncPtr
) glXQueryDrawable
},
1211 { "glXSelectEvent", (__GLXextFuncPtr
) glXSelectEvent
},
1213 /*** GLX_VERSION_1_4 ***/
1214 { "glXGetProcAddress", (__GLXextFuncPtr
) glXGetProcAddress
},
1216 /*** GLX_SGI_swap_control ***/
1217 { "glXSwapIntervalSGI", (__GLXextFuncPtr
) glXSwapIntervalSGI
},
1219 /*** GLX_SGI_video_sync ***/
1220 { "glXGetVideoSyncSGI", (__GLXextFuncPtr
) glXGetVideoSyncSGI
},
1221 { "glXWaitVideoSyncSGI", (__GLXextFuncPtr
) glXWaitVideoSyncSGI
},
1223 /*** GLX_SGI_make_current_read ***/
1224 { "glXMakeCurrentReadSGI", (__GLXextFuncPtr
) glXMakeCurrentReadSGI
},
1225 { "glXGetCurrentReadDrawableSGI", (__GLXextFuncPtr
) glXGetCurrentReadDrawableSGI
},
1227 /*** GLX_SGIX_video_source ***/
1229 { "glXCreateGLXVideoSourceSGIX", (__GLXextFuncPtr
) glXCreateGLXVideoSourceSGIX
},
1230 { "glXDestroyGLXVideoSourceSGIX", (__GLXextFuncPtr
) glXDestroyGLXVideoSourceSGIX
},
1233 /*** GLX_EXT_import_context ***/
1234 { "glXFreeContextEXT", (__GLXextFuncPtr
) glXFreeContextEXT
},
1235 { "glXGetContextIDEXT", (__GLXextFuncPtr
) glXGetContextIDEXT
},
1236 { "glXGetCurrentDisplayEXT", (__GLXextFuncPtr
) glXGetCurrentDisplayEXT
},
1237 { "glXImportContextEXT", (__GLXextFuncPtr
) glXImportContextEXT
},
1238 { "glXQueryContextInfoEXT", (__GLXextFuncPtr
) glXQueryContextInfoEXT
},
1240 /*** GLX_SGIX_fbconfig ***/
1241 { "glXGetFBConfigAttribSGIX", (__GLXextFuncPtr
) glXGetFBConfigAttribSGIX
},
1242 { "glXChooseFBConfigSGIX", (__GLXextFuncPtr
) glXChooseFBConfigSGIX
},
1243 { "glXCreateGLXPixmapWithConfigSGIX", (__GLXextFuncPtr
) glXCreateGLXPixmapWithConfigSGIX
},
1244 { "glXCreateContextWithConfigSGIX", (__GLXextFuncPtr
) glXCreateContextWithConfigSGIX
},
1245 { "glXGetVisualFromFBConfigSGIX", (__GLXextFuncPtr
) glXGetVisualFromFBConfigSGIX
},
1246 { "glXGetFBConfigFromVisualSGIX", (__GLXextFuncPtr
) glXGetFBConfigFromVisualSGIX
},
1248 /*** GLX_SGIX_pbuffer ***/
1249 { "glXCreateGLXPbufferSGIX", (__GLXextFuncPtr
) glXCreateGLXPbufferSGIX
},
1250 { "glXDestroyGLXPbufferSGIX", (__GLXextFuncPtr
) glXDestroyGLXPbufferSGIX
},
1251 { "glXQueryGLXPbufferSGIX", (__GLXextFuncPtr
) glXQueryGLXPbufferSGIX
},
1252 { "glXSelectEventSGIX", (__GLXextFuncPtr
) glXSelectEventSGIX
},
1253 { "glXGetSelectedEventSGIX", (__GLXextFuncPtr
) glXGetSelectedEventSGIX
},
1255 /*** GLX_SGI_cushion ***/
1256 { "glXCushionSGI", (__GLXextFuncPtr
) glXCushionSGI
},
1258 /*** GLX_SGIX_video_resize ***/
1259 { "glXBindChannelToWindowSGIX", (__GLXextFuncPtr
) glXBindChannelToWindowSGIX
},
1260 { "glXChannelRectSGIX", (__GLXextFuncPtr
) glXChannelRectSGIX
},
1261 { "glXQueryChannelRectSGIX", (__GLXextFuncPtr
) glXQueryChannelRectSGIX
},
1262 { "glXQueryChannelDeltasSGIX", (__GLXextFuncPtr
) glXQueryChannelDeltasSGIX
},
1263 { "glXChannelRectSyncSGIX", (__GLXextFuncPtr
) glXChannelRectSyncSGIX
},
1265 /*** GLX_SGIX_dmbuffer **/
1266 #if defined(_DM_BUFFER_H_)
1267 { "glXAssociateDMPbufferSGIX", (__GLXextFuncPtr
) glXAssociateDMPbufferSGIX
},
1270 /*** GLX_SGIX_swap_group ***/
1271 { "glXJoinSwapGroupSGIX", (__GLXextFuncPtr
) glXJoinSwapGroupSGIX
},
1273 /*** GLX_SGIX_swap_barrier ***/
1274 { "glXBindSwapBarrierSGIX", (__GLXextFuncPtr
) glXBindSwapBarrierSGIX
},
1275 { "glXQueryMaxSwapBarriersSGIX", (__GLXextFuncPtr
) glXQueryMaxSwapBarriersSGIX
},
1277 /*** GLX_SUN_get_transparent_index ***/
1278 { "glXGetTransparentIndexSUN", (__GLXextFuncPtr
) glXGetTransparentIndexSUN
},
1280 /*** GLX_MESA_copy_sub_buffer ***/
1281 { "glXCopySubBufferMESA", (__GLXextFuncPtr
) glXCopySubBufferMESA
},
1283 /*** GLX_MESA_pixmap_colormap ***/
1284 { "glXCreateGLXPixmapMESA", (__GLXextFuncPtr
) glXCreateGLXPixmapMESA
},
1286 /*** GLX_MESA_release_buffers ***/
1287 { "glXReleaseBuffersMESA", (__GLXextFuncPtr
) glXReleaseBuffersMESA
},
1289 /*** GLX_MESA_set_3dfx_mode ***/
1290 { "glXSet3DfxModeMESA", (__GLXextFuncPtr
) glXSet3DfxModeMESA
},
1292 /*** GLX_ARB_get_proc_address ***/
1293 { "glXGetProcAddressARB", (__GLXextFuncPtr
) glXGetProcAddressARB
},
1295 /*** GLX_NV_vertex_array_range ***/
1296 { "glXAllocateMemoryNV", (__GLXextFuncPtr
) glXAllocateMemoryNV
},
1297 { "glXFreeMemoryNV", (__GLXextFuncPtr
) glXFreeMemoryNV
},
1299 /*** GLX_MESA_agp_offset ***/
1300 { "glXGetAGPOffsetMESA", (__GLXextFuncPtr
) glXGetAGPOffsetMESA
},
1302 /*** GLX_MESA_allocate_memory ***/
1303 { "glXAllocateMemoryMESA", (__GLXextFuncPtr
) glXAllocateMemoryMESA
},
1304 { "glXFreeMemoryMESA", (__GLXextFuncPtr
) glXFreeMemoryMESA
},
1305 { "glXGetMemoryOffsetMESA", (__GLXextFuncPtr
) glXGetMemoryOffsetMESA
},
1307 { NULL
, NULL
} /* end of list */
1313 * Return address of named glX function, or NULL if not found.
1316 _glxapi_get_proc_address(const char *funcName
)
1319 for (i
= 0; GLX_functions
[i
].Name
; i
++) {
1320 if (strcmp(GLX_functions
[i
].Name
, funcName
) == 0)
1321 return GLX_functions
[i
].Address
;
1329 * This function does not get dispatched through the dispatch table
1330 * since it's really a "meta" function.
1333 glXGetProcAddressARB(const GLubyte
*procName
)
1337 f
= _glxapi_get_proc_address((const char *) procName
);
1342 f
= (__GLXextFuncPtr
) _glapi_get_proc_address((const char *) procName
);
1348 void (*glXGetProcAddress(const GLubyte
*procName
))()
1350 return glXGetProcAddressARB(procName
);