2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 * This is the GLX API dispatcher. Calls to the glX* functions are
28 * either routed to the real GLX encoders or to Mesa's pseudo-GLX functions.
29 * See the glxapi.h file for more details.
37 #include "main/glheader.h"
38 #include "glapi/glapi.h"
40 #include "pipe/p_thread.h"
43 extern struct _glxapi_table
*_real_GetGLXDispatchTable(void);
44 extern struct _glxapi_table
*_mesa_GetGLXDispatchTable(void);
47 struct display_dispatch
{
49 struct _glxapi_table
*Table
;
50 struct display_dispatch
*Next
;
53 static struct display_dispatch
*DispatchList
= NULL
;
56 /* Display -> Dispatch caching */
57 static Display
*prevDisplay
= NULL
;
58 static struct _glxapi_table
*prevTable
= NULL
;
61 static struct _glxapi_table
*
62 get_dispatch(Display
*dpy
)
67 /* search list of display/dispatch pairs for this display */
69 const struct display_dispatch
*d
= DispatchList
;
74 return d
->Table
; /* done! */
80 /* A new display, determine if we should use real GLX
81 * or Mesa's pseudo-GLX.
84 struct _glxapi_table
*t
= _mesa_GetGLXDispatchTable();
87 struct display_dispatch
*d
;
88 d
= (struct display_dispatch
*) malloc(sizeof(struct display_dispatch
));
92 /* insert at head of list */
93 d
->Next
= DispatchList
;
103 /* If we get here that means we can't use real GLX on this display
104 * and the Mesa pseudo-GLX software renderer wasn't compiled in.
105 * Or, we ran out of memory!
111 /* Don't use the GET_DISPATCH defined in glthread.h */
114 #define GET_DISPATCH(DPY, TABLE) \
115 if (DPY == prevDisplay) { \
122 TABLE = get_dispatch(DPY); \
129 * GLX API current context.
135 SetCurrentContext(GLXContext c
)
137 pipe_tsd_set(&ContextTSD
, c
);
142 * GLX API entrypoints
145 /*** GLX_VERSION_1_0 ***/
148 glXChooseVisual(Display
*dpy
, int screen
, int *list
)
150 struct _glxapi_table
*t
;
151 GET_DISPATCH(dpy
, t
);
154 return (t
->ChooseVisual
)(dpy
, screen
, list
);
159 glXCopyContext(Display
*dpy
, GLXContext src
, GLXContext dst
, unsigned long mask
)
161 struct _glxapi_table
*t
;
162 GET_DISPATCH(dpy
, t
);
165 (t
->CopyContext
)(dpy
, src
, dst
, mask
);
170 glXCreateContext(Display
*dpy
, XVisualInfo
*visinfo
, GLXContext shareList
, Bool direct
)
172 struct _glxapi_table
*t
;
173 GET_DISPATCH(dpy
, t
);
176 return (t
->CreateContext
)(dpy
, visinfo
, shareList
, direct
);
181 glXCreateGLXPixmap(Display
*dpy
, XVisualInfo
*visinfo
, Pixmap pixmap
)
183 struct _glxapi_table
*t
;
184 GET_DISPATCH(dpy
, t
);
187 return (t
->CreateGLXPixmap
)(dpy
, visinfo
, pixmap
);
192 glXDestroyContext(Display
*dpy
, GLXContext ctx
)
194 struct _glxapi_table
*t
;
195 GET_DISPATCH(dpy
, t
);
198 if (glXGetCurrentContext() == ctx
)
199 SetCurrentContext(NULL
);
200 (t
->DestroyContext
)(dpy
, ctx
);
205 glXDestroyGLXPixmap(Display
*dpy
, GLXPixmap pixmap
)
207 struct _glxapi_table
*t
;
208 GET_DISPATCH(dpy
, t
);
211 (t
->DestroyGLXPixmap
)(dpy
, pixmap
);
216 glXGetConfig(Display
*dpy
, XVisualInfo
*visinfo
, int attrib
, int *value
)
218 struct _glxapi_table
*t
;
219 GET_DISPATCH(dpy
, t
);
221 return GLX_NO_EXTENSION
;
222 return (t
->GetConfig
)(dpy
, visinfo
, attrib
, value
);
227 glXGetCurrentContext(void)
229 return (GLXContext
) pipe_tsd_get(&ContextTSD
);
234 glXGetCurrentDrawable(void)
236 __GLXcontext
*gc
= (__GLXcontext
*) glXGetCurrentContext();
237 return gc
? gc
->currentDrawable
: 0;
242 glXIsDirect(Display
*dpy
, GLXContext ctx
)
244 struct _glxapi_table
*t
;
245 GET_DISPATCH(dpy
, t
);
248 return (t
->IsDirect
)(dpy
, ctx
);
253 glXMakeCurrent(Display
*dpy
, GLXDrawable drawable
, GLXContext ctx
)
256 struct _glxapi_table
*t
;
257 GET_DISPATCH(dpy
, t
);
261 b
= (*t
->MakeCurrent
)(dpy
, drawable
, ctx
);
263 SetCurrentContext(ctx
);
270 glXQueryExtension(Display
*dpy
, int *errorb
, int *event
)
272 struct _glxapi_table
*t
;
273 GET_DISPATCH(dpy
, t
);
276 return (t
->QueryExtension
)(dpy
, errorb
, event
);
281 glXQueryVersion(Display
*dpy
, int *maj
, int *min
)
283 struct _glxapi_table
*t
;
284 GET_DISPATCH(dpy
, t
);
287 return (t
->QueryVersion
)(dpy
, maj
, min
);
292 glXSwapBuffers(Display
*dpy
, GLXDrawable drawable
)
294 struct _glxapi_table
*t
;
295 GET_DISPATCH(dpy
, t
);
298 (t
->SwapBuffers
)(dpy
, drawable
);
303 glXUseXFont(Font font
, int first
, int count
, int listBase
)
305 struct _glxapi_table
*t
;
306 Display
*dpy
= glXGetCurrentDisplay();
307 GET_DISPATCH(dpy
, t
);
310 (t
->UseXFont
)(font
, first
, count
, listBase
);
317 struct _glxapi_table
*t
;
318 Display
*dpy
= glXGetCurrentDisplay();
319 GET_DISPATCH(dpy
, t
);
329 struct _glxapi_table
*t
;
330 Display
*dpy
= glXGetCurrentDisplay();
331 GET_DISPATCH(dpy
, t
);
339 /*** GLX_VERSION_1_1 ***/
342 glXGetClientString(Display
*dpy
, int name
)
344 struct _glxapi_table
*t
;
345 GET_DISPATCH(dpy
, t
);
348 return (t
->GetClientString
)(dpy
, name
);
353 glXQueryExtensionsString(Display
*dpy
, int screen
)
355 struct _glxapi_table
*t
;
356 GET_DISPATCH(dpy
, t
);
359 return (t
->QueryExtensionsString
)(dpy
, screen
);
364 glXQueryServerString(Display
*dpy
, int screen
, int name
)
366 struct _glxapi_table
*t
;
367 GET_DISPATCH(dpy
, t
);
370 return (t
->QueryServerString
)(dpy
, screen
, name
);
374 /*** GLX_VERSION_1_2 ***/
377 glXGetCurrentDisplay(void)
379 /* Same code as in libGL's glxext.c */
380 __GLXcontext
*gc
= (__GLXcontext
*) glXGetCurrentContext();
381 if (NULL
== gc
) return NULL
;
382 return gc
->currentDpy
;
387 /*** GLX_VERSION_1_3 ***/
390 glXChooseFBConfig(Display
*dpy
, int screen
, const int *attribList
, int *nitems
)
392 struct _glxapi_table
*t
;
393 GET_DISPATCH(dpy
, t
);
396 return (t
->ChooseFBConfig
)(dpy
, screen
, attribList
, nitems
);
401 glXCreateNewContext(Display
*dpy
, GLXFBConfig config
, int renderType
, GLXContext shareList
, Bool direct
)
403 struct _glxapi_table
*t
;
404 GET_DISPATCH(dpy
, t
);
407 return (t
->CreateNewContext
)(dpy
, config
, renderType
, shareList
, direct
);
412 glXCreatePbuffer(Display
*dpy
, GLXFBConfig config
, const int *attribList
)
414 struct _glxapi_table
*t
;
415 GET_DISPATCH(dpy
, t
);
418 return (t
->CreatePbuffer
)(dpy
, config
, attribList
);
423 glXCreatePixmap(Display
*dpy
, GLXFBConfig config
, Pixmap pixmap
, const int *attribList
)
425 struct _glxapi_table
*t
;
426 GET_DISPATCH(dpy
, t
);
429 return (t
->CreatePixmap
)(dpy
, config
, pixmap
, attribList
);
434 glXCreateWindow(Display
*dpy
, GLXFBConfig config
, Window win
, const int *attribList
)
436 struct _glxapi_table
*t
;
437 GET_DISPATCH(dpy
, t
);
440 return (t
->CreateWindow
)(dpy
, config
, win
, attribList
);
445 glXDestroyPbuffer(Display
*dpy
, GLXPbuffer pbuf
)
447 struct _glxapi_table
*t
;
448 GET_DISPATCH(dpy
, t
);
451 (t
->DestroyPbuffer
)(dpy
, pbuf
);
456 glXDestroyPixmap(Display
*dpy
, GLXPixmap pixmap
)
458 struct _glxapi_table
*t
;
459 GET_DISPATCH(dpy
, t
);
462 (t
->DestroyPixmap
)(dpy
, pixmap
);
467 glXDestroyWindow(Display
*dpy
, GLXWindow window
)
469 struct _glxapi_table
*t
;
470 GET_DISPATCH(dpy
, t
);
473 (t
->DestroyWindow
)(dpy
, window
);
478 glXGetCurrentReadDrawable(void)
480 __GLXcontext
*gc
= (__GLXcontext
*) glXGetCurrentContext();
481 return gc
? gc
->currentReadable
: 0;
486 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
);
497 glXGetFBConfigs(Display
*dpy
, int screen
, int *nelements
)
499 struct _glxapi_table
*t
;
500 GET_DISPATCH(dpy
, t
);
503 return (t
->GetFBConfigs
)(dpy
, screen
, nelements
);
507 glXGetSelectedEvent(Display
*dpy
, GLXDrawable drawable
, unsigned long *mask
)
509 struct _glxapi_table
*t
;
510 GET_DISPATCH(dpy
, t
);
513 (t
->GetSelectedEvent
)(dpy
, drawable
, mask
);
518 glXGetVisualFromFBConfig(Display
*dpy
, GLXFBConfig config
)
520 struct _glxapi_table
*t
;
521 GET_DISPATCH(dpy
, t
);
524 return (t
->GetVisualFromFBConfig
)(dpy
, config
);
529 glXMakeContextCurrent(Display
*dpy
, GLXDrawable draw
, GLXDrawable read
, GLXContext ctx
)
532 struct _glxapi_table
*t
;
533 GET_DISPATCH(dpy
, t
);
536 b
= (t
->MakeContextCurrent
)(dpy
, draw
, read
, ctx
);
538 SetCurrentContext(ctx
);
545 glXQueryContext(Display
*dpy
, GLXContext ctx
, int attribute
, int *value
)
547 struct _glxapi_table
*t
;
548 GET_DISPATCH(dpy
, t
);
551 return 0; /* XXX correct? */
552 return (t
->QueryContext
)(dpy
, ctx
, attribute
, value
);
557 glXQueryDrawable(Display
*dpy
, GLXDrawable draw
, int attribute
, unsigned int *value
)
559 struct _glxapi_table
*t
;
560 GET_DISPATCH(dpy
, t
);
563 (t
->QueryDrawable
)(dpy
, draw
, attribute
, value
);
568 glXSelectEvent(Display
*dpy
, GLXDrawable drawable
, unsigned long mask
)
570 struct _glxapi_table
*t
;
571 GET_DISPATCH(dpy
, t
);
574 (t
->SelectEvent
)(dpy
, drawable
, mask
);
579 /*** GLX_SGI_swap_control ***/
582 glXSwapIntervalSGI(int interval
)
584 struct _glxapi_table
*t
;
585 Display
*dpy
= glXGetCurrentDisplay();
586 GET_DISPATCH(dpy
, t
);
589 return (t
->SwapIntervalSGI
)(interval
);
594 /*** GLX_SGI_video_sync ***/
597 glXGetVideoSyncSGI(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
->GetVideoSyncSGI
)(count
);
608 glXWaitVideoSyncSGI(int divisor
, int remainder
, unsigned int *count
)
610 struct _glxapi_table
*t
;
611 Display
*dpy
= glXGetCurrentDisplay();
612 GET_DISPATCH(dpy
, t
);
613 if (!t
|| !glXGetCurrentContext())
614 return GLX_BAD_CONTEXT
;
615 return (t
->WaitVideoSyncSGI
)(divisor
, remainder
, count
);
620 /*** GLX_SGI_make_current_read ***/
623 glXMakeCurrentReadSGI(Display
*dpy
, GLXDrawable draw
, GLXDrawable read
, GLXContext ctx
)
625 struct _glxapi_table
*t
;
626 GET_DISPATCH(dpy
, t
);
629 return (t
->MakeCurrentReadSGI
)(dpy
, draw
, read
, ctx
);
633 glXGetCurrentReadDrawableSGI(void)
635 return glXGetCurrentReadDrawable();
641 GLXVideoSourceSGIX PUBLIC
642 glXCreateGLXVideoSourceSGIX(Display
*dpy
, int screen
, VLServer server
, VLPath path
, int nodeClass
, VLNode drainNode
)
644 struct _glxapi_table
*t
;
645 GET_DISPATCH(dpy
, t
);
648 return (t
->CreateGLXVideoSourceSGIX
)(dpy
, screen
, server
, path
, nodeClass
, drainNode
);
652 glXDestroyGLXVideoSourceSGIX(Display
*dpy
, GLXVideoSourceSGIX src
)
654 struct _glxapi_table
*t
;
655 GET_DISPATCH(dpy
, t
);
658 return (t
->DestroyGLXVideoSourceSGIX
)(dpy
, src
);
664 /*** GLX_EXT_import_context ***/
667 glXFreeContextEXT(Display
*dpy
, GLXContext context
)
669 struct _glxapi_table
*t
;
670 GET_DISPATCH(dpy
, t
);
673 (t
->FreeContextEXT
)(dpy
, context
);
677 glXGetContextIDEXT(const GLXContext context
)
679 return ((__GLXcontext
*) context
)->xid
;
683 glXGetCurrentDisplayEXT(void)
685 return glXGetCurrentDisplay();
689 glXImportContextEXT(Display
*dpy
, GLXContextID contextID
)
691 struct _glxapi_table
*t
;
692 GET_DISPATCH(dpy
, t
);
695 return (t
->ImportContextEXT
)(dpy
, contextID
);
699 glXQueryContextInfoEXT(Display
*dpy
, GLXContext context
, int attribute
,int *value
)
701 struct _glxapi_table
*t
;
702 GET_DISPATCH(dpy
, t
);
704 return 0; /* XXX ok? */
705 return (t
->QueryContextInfoEXT
)(dpy
, context
, attribute
, value
);
710 /*** GLX_SGIX_fbconfig ***/
713 glXGetFBConfigAttribSGIX(Display
*dpy
, GLXFBConfigSGIX config
, int attribute
, int *value
)
715 struct _glxapi_table
*t
;
716 GET_DISPATCH(dpy
, t
);
719 return (t
->GetFBConfigAttribSGIX
)(dpy
, config
, attribute
, value
);
722 GLXFBConfigSGIX PUBLIC
*
723 glXChooseFBConfigSGIX(Display
*dpy
, int screen
, int *attrib_list
, int *nelements
)
725 struct _glxapi_table
*t
;
726 GET_DISPATCH(dpy
, t
);
729 return (t
->ChooseFBConfigSGIX
)(dpy
, screen
, attrib_list
, nelements
);
733 glXCreateGLXPixmapWithConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
, Pixmap pixmap
)
735 struct _glxapi_table
*t
;
736 GET_DISPATCH(dpy
, t
);
739 return (t
->CreateGLXPixmapWithConfigSGIX
)(dpy
, config
, pixmap
);
743 glXCreateContextWithConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
, int render_type
, GLXContext share_list
, Bool direct
)
745 struct _glxapi_table
*t
;
746 GET_DISPATCH(dpy
, t
);
749 return (t
->CreateContextWithConfigSGIX
)(dpy
, config
, render_type
, share_list
, direct
);
753 glXGetVisualFromFBConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
)
755 struct _glxapi_table
*t
;
756 GET_DISPATCH(dpy
, t
);
759 return (t
->GetVisualFromFBConfigSGIX
)(dpy
, config
);
762 GLXFBConfigSGIX PUBLIC
763 glXGetFBConfigFromVisualSGIX(Display
*dpy
, XVisualInfo
*vis
)
765 struct _glxapi_table
*t
;
766 GET_DISPATCH(dpy
, t
);
769 return (t
->GetFBConfigFromVisualSGIX
)(dpy
, vis
);
774 /*** GLX_SGIX_pbuffer ***/
776 GLXPbufferSGIX PUBLIC
777 glXCreateGLXPbufferSGIX(Display
*dpy
, GLXFBConfigSGIX config
, unsigned int width
, unsigned int height
, int *attrib_list
)
779 struct _glxapi_table
*t
;
780 GET_DISPATCH(dpy
, t
);
783 return (t
->CreateGLXPbufferSGIX
)(dpy
, config
, width
, height
, attrib_list
);
787 glXDestroyGLXPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuf
)
789 struct _glxapi_table
*t
;
790 GET_DISPATCH(dpy
, t
);
793 (t
->DestroyGLXPbufferSGIX
)(dpy
, pbuf
);
797 glXQueryGLXPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuf
, int attribute
, unsigned int *value
)
799 struct _glxapi_table
*t
;
800 GET_DISPATCH(dpy
, t
);
803 return (t
->QueryGLXPbufferSGIX
)(dpy
, pbuf
, attribute
, value
);
807 glXSelectEventSGIX(Display
*dpy
, GLXDrawable drawable
, unsigned long mask
)
809 struct _glxapi_table
*t
;
810 GET_DISPATCH(dpy
, t
);
813 (t
->SelectEventSGIX
)(dpy
, drawable
, mask
);
817 glXGetSelectedEventSGIX(Display
*dpy
, GLXDrawable drawable
, unsigned long *mask
)
819 struct _glxapi_table
*t
;
820 GET_DISPATCH(dpy
, t
);
823 (t
->GetSelectedEventSGIX
)(dpy
, drawable
, mask
);
828 /*** GLX_SGI_cushion ***/
831 glXCushionSGI(Display
*dpy
, Window win
, float cushion
)
833 struct _glxapi_table
*t
;
834 GET_DISPATCH(dpy
, t
);
837 (t
->CushionSGI
)(dpy
, win
, cushion
);
842 /*** GLX_SGIX_video_resize ***/
845 glXBindChannelToWindowSGIX(Display
*dpy
, int screen
, int channel
, Window window
)
847 struct _glxapi_table
*t
;
848 GET_DISPATCH(dpy
, t
);
851 return (t
->BindChannelToWindowSGIX
)(dpy
, screen
, channel
, window
);
855 glXChannelRectSGIX(Display
*dpy
, int screen
, int channel
, int x
, int y
, int w
, int h
)
857 struct _glxapi_table
*t
;
858 GET_DISPATCH(dpy
, t
);
861 return (t
->ChannelRectSGIX
)(dpy
, screen
, channel
, x
, y
, w
, h
);
865 glXQueryChannelRectSGIX(Display
*dpy
, int screen
, int channel
, int *x
, int *y
, int *w
, int *h
)
867 struct _glxapi_table
*t
;
868 GET_DISPATCH(dpy
, t
);
871 return (t
->QueryChannelRectSGIX
)(dpy
, screen
, channel
, x
, y
, w
, h
);
875 glXQueryChannelDeltasSGIX(Display
*dpy
, int screen
, int channel
, int *dx
, int *dy
, int *dw
, int *dh
)
877 struct _glxapi_table
*t
;
878 GET_DISPATCH(dpy
, t
);
881 return (t
->QueryChannelDeltasSGIX
)(dpy
, screen
, channel
, dx
, dy
, dw
, dh
);
885 glXChannelRectSyncSGIX(Display
*dpy
, int screen
, int channel
, GLenum synctype
)
887 struct _glxapi_table
*t
;
888 GET_DISPATCH(dpy
, t
);
891 return (t
->ChannelRectSyncSGIX
)(dpy
, screen
, channel
, synctype
);
896 #if defined(_DM_BUFFER_H_)
899 glXAssociateDMPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuffer
, DMparams
*params
, DMbuffer dmbuffer
)
901 struct _glxapi_table
*t
;
902 GET_DISPATCH(dpy
, t
);
905 return (t
->AssociateDMPbufferSGIX
)(dpy
, pbuffer
, params
, dmbuffer
);
911 /*** GLX_SGIX_swap_group ***/
914 glXJoinSwapGroupSGIX(Display
*dpy
, GLXDrawable drawable
, GLXDrawable member
)
916 struct _glxapi_table
*t
;
917 GET_DISPATCH(dpy
, t
);
920 (*t
->JoinSwapGroupSGIX
)(dpy
, drawable
, member
);
924 /*** GLX_SGIX_swap_barrier ***/
927 glXBindSwapBarrierSGIX(Display
*dpy
, GLXDrawable drawable
, int barrier
)
929 struct _glxapi_table
*t
;
930 GET_DISPATCH(dpy
, t
);
933 (*t
->BindSwapBarrierSGIX
)(dpy
, drawable
, barrier
);
937 glXQueryMaxSwapBarriersSGIX(Display
*dpy
, int screen
, int *max
)
939 struct _glxapi_table
*t
;
940 GET_DISPATCH(dpy
, t
);
943 return (*t
->QueryMaxSwapBarriersSGIX
)(dpy
, screen
, max
);
948 /*** GLX_SUN_get_transparent_index ***/
951 glXGetTransparentIndexSUN(Display
*dpy
, Window overlay
, Window underlay
, long *pTransparent
)
953 struct _glxapi_table
*t
;
954 GET_DISPATCH(dpy
, t
);
957 return (*t
->GetTransparentIndexSUN
)(dpy
, overlay
, underlay
, pTransparent
);
962 /*** GLX_MESA_copy_sub_buffer ***/
965 glXCopySubBufferMESA(Display
*dpy
, GLXDrawable drawable
, int x
, int y
, int width
, int height
)
967 struct _glxapi_table
*t
;
968 GET_DISPATCH(dpy
, t
);
971 (t
->CopySubBufferMESA
)(dpy
, drawable
, x
, y
, width
, height
);
976 /*** GLX_MESA_release_buffers ***/
979 glXReleaseBuffersMESA(Display
*dpy
, Window w
)
981 struct _glxapi_table
*t
;
982 GET_DISPATCH(dpy
, t
);
985 return (t
->ReleaseBuffersMESA
)(dpy
, w
);
990 /*** GLX_MESA_pixmap_colormap ***/
993 glXCreateGLXPixmapMESA(Display
*dpy
, XVisualInfo
*visinfo
, Pixmap pixmap
, Colormap cmap
)
995 struct _glxapi_table
*t
;
996 GET_DISPATCH(dpy
, t
);
999 return (t
->CreateGLXPixmapMESA
)(dpy
, visinfo
, pixmap
, cmap
);
1004 /*** GLX_MESA_set_3dfx_mode ***/
1007 glXSet3DfxModeMESA(int mode
)
1009 struct _glxapi_table
*t
;
1010 Display
*dpy
= glXGetCurrentDisplay();
1011 GET_DISPATCH(dpy
, t
);
1014 return (t
->Set3DfxModeMESA
)(mode
);
1019 /*** GLX_NV_vertex_array_range ***/
1022 glXAllocateMemoryNV( GLsizei size
,
1023 GLfloat readFrequency
,
1024 GLfloat writeFrequency
,
1027 struct _glxapi_table
*t
;
1028 Display
*dpy
= glXGetCurrentDisplay();
1029 GET_DISPATCH(dpy
, t
);
1032 return (t
->AllocateMemoryNV
)(size
, readFrequency
, writeFrequency
, priority
);
1037 glXFreeMemoryNV( GLvoid
*pointer
)
1039 struct _glxapi_table
*t
;
1040 Display
*dpy
= glXGetCurrentDisplay();
1041 GET_DISPATCH(dpy
, t
);
1044 (t
->FreeMemoryNV
)(pointer
);
1050 /*** GLX_MESA_agp_offset */
1053 glXGetAGPOffsetMESA( const GLvoid
*pointer
)
1055 struct _glxapi_table
*t
;
1056 Display
*dpy
= glXGetCurrentDisplay();
1057 GET_DISPATCH(dpy
, t
);
1060 return (t
->GetAGPOffsetMESA
)(pointer
);
1064 /*** GLX_MESA_allocate_memory */
1067 glXAllocateMemoryMESA(Display
*dpy
, int scrn
, size_t size
,
1068 float readfreq
, float writefreq
, float priority
)
1075 glXFreeMemoryMESA(Display
*dpy
, int scrn
, void *pointer
)
1082 glXGetMemoryOffsetMESA(Display
*dpy
, int scrn
, const void *pointer
)
1089 /*** GLX_EXT_texture_from_pixmap */
1092 glXBindTexImageEXT(Display
*dpy
, GLXDrawable drawable
, int buffer
,
1093 const int *attrib_list
)
1095 struct _glxapi_table
*t
;
1096 GET_DISPATCH(dpy
, t
);
1098 t
->BindTexImageEXT(dpy
, drawable
, buffer
, attrib_list
);
1102 glXReleaseTexImageEXT(Display
*dpy
, GLXDrawable drawable
, int buffer
)
1104 struct _glxapi_table
*t
;
1105 GET_DISPATCH(dpy
, t
);
1107 t
->ReleaseTexImageEXT(dpy
, drawable
, buffer
);
1111 /**********************************************************************/
1112 /* GLX API management functions */
1113 /**********************************************************************/
1117 _glxapi_get_version(void)
1124 * Return array of extension strings.
1127 _glxapi_get_extensions(void)
1129 static const char *extensions
[] = {
1130 #ifdef GLX_EXT_import_context
1131 "GLX_EXT_import_context",
1133 #ifdef GLX_SGI_video_sync
1134 "GLX_SGI_video_sync",
1136 #ifdef GLX_MESA_copy_sub_buffer
1137 "GLX_MESA_copy_sub_buffer",
1139 #ifdef GLX_MESA_release_buffers
1140 "GLX_MESA_release_buffers",
1142 #ifdef GLX_MESA_pixmap_colormap
1143 "GLX_MESA_pixmap_colormap",
1145 #ifdef GLX_MESA_set_3dfx_mode
1146 "GLX_MESA_set_3dfx_mode",
1148 #ifdef GLX_SGIX_fbconfig
1149 "GLX_SGIX_fbconfig",
1151 #ifdef GLX_SGIX_pbuffer
1154 #ifdef GLX_EXT_texture_from_pixmap
1155 "GLX_EXT_texture_from_pixmap",
1164 * Return size of the GLX dispatch table, in entries, not bytes.
1167 _glxapi_get_dispatch_table_size(void)
1169 return sizeof(struct _glxapi_table
) / sizeof(void *);
1174 generic_no_op_func(void)
1181 * Initialize all functions in given dispatch table to be no-ops
1184 _glxapi_set_no_op_table(struct _glxapi_table
*t
)
1186 typedef int (*nop_func
)(void);
1187 nop_func
*dispatch
= (nop_func
*) t
;
1188 GLuint n
= _glxapi_get_dispatch_table_size();
1190 for (i
= 0; i
< n
; i
++) {
1191 dispatch
[i
] = generic_no_op_func
;
1196 struct name_address_pair
{
1198 __GLXextFuncPtr Address
;
1201 static struct name_address_pair GLX_functions
[] = {
1202 /*** GLX_VERSION_1_0 ***/
1203 { "glXChooseVisual", (__GLXextFuncPtr
) glXChooseVisual
},
1204 { "glXCopyContext", (__GLXextFuncPtr
) glXCopyContext
},
1205 { "glXCreateContext", (__GLXextFuncPtr
) glXCreateContext
},
1206 { "glXCreateGLXPixmap", (__GLXextFuncPtr
) glXCreateGLXPixmap
},
1207 { "glXDestroyContext", (__GLXextFuncPtr
) glXDestroyContext
},
1208 { "glXDestroyGLXPixmap", (__GLXextFuncPtr
) glXDestroyGLXPixmap
},
1209 { "glXGetConfig", (__GLXextFuncPtr
) glXGetConfig
},
1210 { "glXGetCurrentContext", (__GLXextFuncPtr
) glXGetCurrentContext
},
1211 { "glXGetCurrentDrawable", (__GLXextFuncPtr
) glXGetCurrentDrawable
},
1212 { "glXIsDirect", (__GLXextFuncPtr
) glXIsDirect
},
1213 { "glXMakeCurrent", (__GLXextFuncPtr
) glXMakeCurrent
},
1214 { "glXQueryExtension", (__GLXextFuncPtr
) glXQueryExtension
},
1215 { "glXQueryVersion", (__GLXextFuncPtr
) glXQueryVersion
},
1216 { "glXSwapBuffers", (__GLXextFuncPtr
) glXSwapBuffers
},
1217 { "glXUseXFont", (__GLXextFuncPtr
) glXUseXFont
},
1218 { "glXWaitGL", (__GLXextFuncPtr
) glXWaitGL
},
1219 { "glXWaitX", (__GLXextFuncPtr
) glXWaitX
},
1221 /*** GLX_VERSION_1_1 ***/
1222 { "glXGetClientString", (__GLXextFuncPtr
) glXGetClientString
},
1223 { "glXQueryExtensionsString", (__GLXextFuncPtr
) glXQueryExtensionsString
},
1224 { "glXQueryServerString", (__GLXextFuncPtr
) glXQueryServerString
},
1226 /*** GLX_VERSION_1_2 ***/
1227 { "glXGetCurrentDisplay", (__GLXextFuncPtr
) glXGetCurrentDisplay
},
1229 /*** GLX_VERSION_1_3 ***/
1230 { "glXChooseFBConfig", (__GLXextFuncPtr
) glXChooseFBConfig
},
1231 { "glXCreateNewContext", (__GLXextFuncPtr
) glXCreateNewContext
},
1232 { "glXCreatePbuffer", (__GLXextFuncPtr
) glXCreatePbuffer
},
1233 { "glXCreatePixmap", (__GLXextFuncPtr
) glXCreatePixmap
},
1234 { "glXCreateWindow", (__GLXextFuncPtr
) glXCreateWindow
},
1235 { "glXDestroyPbuffer", (__GLXextFuncPtr
) glXDestroyPbuffer
},
1236 { "glXDestroyPixmap", (__GLXextFuncPtr
) glXDestroyPixmap
},
1237 { "glXDestroyWindow", (__GLXextFuncPtr
) glXDestroyWindow
},
1238 { "glXGetCurrentReadDrawable", (__GLXextFuncPtr
) glXGetCurrentReadDrawable
},
1239 { "glXGetFBConfigAttrib", (__GLXextFuncPtr
) glXGetFBConfigAttrib
},
1240 { "glXGetFBConfigs", (__GLXextFuncPtr
) glXGetFBConfigs
},
1241 { "glXGetSelectedEvent", (__GLXextFuncPtr
) glXGetSelectedEvent
},
1242 { "glXGetVisualFromFBConfig", (__GLXextFuncPtr
) glXGetVisualFromFBConfig
},
1243 { "glXMakeContextCurrent", (__GLXextFuncPtr
) glXMakeContextCurrent
},
1244 { "glXQueryContext", (__GLXextFuncPtr
) glXQueryContext
},
1245 { "glXQueryDrawable", (__GLXextFuncPtr
) glXQueryDrawable
},
1246 { "glXSelectEvent", (__GLXextFuncPtr
) glXSelectEvent
},
1248 /*** GLX_VERSION_1_4 ***/
1249 { "glXGetProcAddress", (__GLXextFuncPtr
) glXGetProcAddress
},
1251 /*** GLX_SGI_swap_control ***/
1252 { "glXSwapIntervalSGI", (__GLXextFuncPtr
) glXSwapIntervalSGI
},
1254 /*** GLX_SGI_video_sync ***/
1255 { "glXGetVideoSyncSGI", (__GLXextFuncPtr
) glXGetVideoSyncSGI
},
1256 { "glXWaitVideoSyncSGI", (__GLXextFuncPtr
) glXWaitVideoSyncSGI
},
1258 /*** GLX_SGI_make_current_read ***/
1259 { "glXMakeCurrentReadSGI", (__GLXextFuncPtr
) glXMakeCurrentReadSGI
},
1260 { "glXGetCurrentReadDrawableSGI", (__GLXextFuncPtr
) glXGetCurrentReadDrawableSGI
},
1262 /*** GLX_SGIX_video_source ***/
1264 { "glXCreateGLXVideoSourceSGIX", (__GLXextFuncPtr
) glXCreateGLXVideoSourceSGIX
},
1265 { "glXDestroyGLXVideoSourceSGIX", (__GLXextFuncPtr
) glXDestroyGLXVideoSourceSGIX
},
1268 /*** GLX_EXT_import_context ***/
1269 { "glXFreeContextEXT", (__GLXextFuncPtr
) glXFreeContextEXT
},
1270 { "glXGetContextIDEXT", (__GLXextFuncPtr
) glXGetContextIDEXT
},
1271 { "glXGetCurrentDisplayEXT", (__GLXextFuncPtr
) glXGetCurrentDisplayEXT
},
1272 { "glXImportContextEXT", (__GLXextFuncPtr
) glXImportContextEXT
},
1273 { "glXQueryContextInfoEXT", (__GLXextFuncPtr
) glXQueryContextInfoEXT
},
1275 /*** GLX_SGIX_fbconfig ***/
1276 { "glXGetFBConfigAttribSGIX", (__GLXextFuncPtr
) glXGetFBConfigAttribSGIX
},
1277 { "glXChooseFBConfigSGIX", (__GLXextFuncPtr
) glXChooseFBConfigSGIX
},
1278 { "glXCreateGLXPixmapWithConfigSGIX", (__GLXextFuncPtr
) glXCreateGLXPixmapWithConfigSGIX
},
1279 { "glXCreateContextWithConfigSGIX", (__GLXextFuncPtr
) glXCreateContextWithConfigSGIX
},
1280 { "glXGetVisualFromFBConfigSGIX", (__GLXextFuncPtr
) glXGetVisualFromFBConfigSGIX
},
1281 { "glXGetFBConfigFromVisualSGIX", (__GLXextFuncPtr
) glXGetFBConfigFromVisualSGIX
},
1283 /*** GLX_SGIX_pbuffer ***/
1284 { "glXCreateGLXPbufferSGIX", (__GLXextFuncPtr
) glXCreateGLXPbufferSGIX
},
1285 { "glXDestroyGLXPbufferSGIX", (__GLXextFuncPtr
) glXDestroyGLXPbufferSGIX
},
1286 { "glXQueryGLXPbufferSGIX", (__GLXextFuncPtr
) glXQueryGLXPbufferSGIX
},
1287 { "glXSelectEventSGIX", (__GLXextFuncPtr
) glXSelectEventSGIX
},
1288 { "glXGetSelectedEventSGIX", (__GLXextFuncPtr
) glXGetSelectedEventSGIX
},
1290 /*** GLX_SGI_cushion ***/
1291 { "glXCushionSGI", (__GLXextFuncPtr
) glXCushionSGI
},
1293 /*** GLX_SGIX_video_resize ***/
1294 { "glXBindChannelToWindowSGIX", (__GLXextFuncPtr
) glXBindChannelToWindowSGIX
},
1295 { "glXChannelRectSGIX", (__GLXextFuncPtr
) glXChannelRectSGIX
},
1296 { "glXQueryChannelRectSGIX", (__GLXextFuncPtr
) glXQueryChannelRectSGIX
},
1297 { "glXQueryChannelDeltasSGIX", (__GLXextFuncPtr
) glXQueryChannelDeltasSGIX
},
1298 { "glXChannelRectSyncSGIX", (__GLXextFuncPtr
) glXChannelRectSyncSGIX
},
1300 /*** GLX_SGIX_dmbuffer **/
1301 #if defined(_DM_BUFFER_H_)
1302 { "glXAssociateDMPbufferSGIX", (__GLXextFuncPtr
) glXAssociateDMPbufferSGIX
},
1305 /*** GLX_SGIX_swap_group ***/
1306 { "glXJoinSwapGroupSGIX", (__GLXextFuncPtr
) glXJoinSwapGroupSGIX
},
1308 /*** GLX_SGIX_swap_barrier ***/
1309 { "glXBindSwapBarrierSGIX", (__GLXextFuncPtr
) glXBindSwapBarrierSGIX
},
1310 { "glXQueryMaxSwapBarriersSGIX", (__GLXextFuncPtr
) glXQueryMaxSwapBarriersSGIX
},
1312 /*** GLX_SUN_get_transparent_index ***/
1313 { "glXGetTransparentIndexSUN", (__GLXextFuncPtr
) glXGetTransparentIndexSUN
},
1315 /*** GLX_MESA_copy_sub_buffer ***/
1316 { "glXCopySubBufferMESA", (__GLXextFuncPtr
) glXCopySubBufferMESA
},
1318 /*** GLX_MESA_pixmap_colormap ***/
1319 { "glXCreateGLXPixmapMESA", (__GLXextFuncPtr
) glXCreateGLXPixmapMESA
},
1321 /*** GLX_MESA_release_buffers ***/
1322 { "glXReleaseBuffersMESA", (__GLXextFuncPtr
) glXReleaseBuffersMESA
},
1324 /*** GLX_MESA_set_3dfx_mode ***/
1325 { "glXSet3DfxModeMESA", (__GLXextFuncPtr
) glXSet3DfxModeMESA
},
1327 /*** GLX_ARB_get_proc_address ***/
1328 { "glXGetProcAddressARB", (__GLXextFuncPtr
) glXGetProcAddressARB
},
1330 /*** GLX_NV_vertex_array_range ***/
1331 { "glXAllocateMemoryNV", (__GLXextFuncPtr
) glXAllocateMemoryNV
},
1332 { "glXFreeMemoryNV", (__GLXextFuncPtr
) glXFreeMemoryNV
},
1334 /*** GLX_MESA_agp_offset ***/
1335 { "glXGetAGPOffsetMESA", (__GLXextFuncPtr
) glXGetAGPOffsetMESA
},
1337 /*** GLX_MESA_allocate_memory ***/
1338 { "glXAllocateMemoryMESA", (__GLXextFuncPtr
) glXAllocateMemoryMESA
},
1339 { "glXFreeMemoryMESA", (__GLXextFuncPtr
) glXFreeMemoryMESA
},
1340 { "glXGetMemoryOffsetMESA", (__GLXextFuncPtr
) glXGetMemoryOffsetMESA
},
1342 /*** GLX_EXT_texture_from_pixmap ***/
1343 { "glXBindTexImageEXT", (__GLXextFuncPtr
) glXBindTexImageEXT
},
1344 { "glXReleaseTexImageEXT", (__GLXextFuncPtr
) glXReleaseTexImageEXT
},
1346 { NULL
, NULL
} /* end of list */
1352 * Return address of named glX function, or NULL if not found.
1355 _glxapi_get_proc_address(const char *funcName
)
1358 for (i
= 0; GLX_functions
[i
].Name
; i
++) {
1359 if (strcmp(GLX_functions
[i
].Name
, funcName
) == 0)
1360 return GLX_functions
[i
].Address
;
1368 * This function does not get dispatched through the dispatch table
1369 * since it's really a "meta" function.
1372 glXGetProcAddressARB(const GLubyte
*procName
)
1376 f
= _glxapi_get_proc_address((const char *) procName
);
1381 f
= (__GLXextFuncPtr
) _glapi_get_proc_address((const char *) procName
);
1387 void (*glXGetProcAddress(const GLubyte
*procName
))()
1389 return glXGetProcAddressARB(procName
);