glx_getproc.c revision 0e4e2c57d1b5659ba4fce2f9077fb6d4c7fd18d5
1/*
2 * Mesa 3-D graphics library
3 * Version:  7.6
4 *
5 * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
6 * Copyright (C) 2009  VMware, Inc.  All Rights Reserved.
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included
16 * in all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
21 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 */
25
26
27/**
28 * glXGetProcAddress()
29 */
30
31
32#define GLX_GLXEXT_PROTOTYPES
33
34#include <string.h>
35#include "GL/glx.h"
36#include "glapi/glapi.h"
37#include "pipe/p_compiler.h"
38
39
40struct name_address_pair {
41   const char *Name;
42   __GLXextFuncPtr Address;
43};
44
45
46static struct name_address_pair GLX_functions[] = {
47   /*** GLX_VERSION_1_0 ***/
48   { "glXChooseVisual", (__GLXextFuncPtr) glXChooseVisual },
49   { "glXCopyContext", (__GLXextFuncPtr) glXCopyContext },
50   { "glXCreateContext", (__GLXextFuncPtr) glXCreateContext },
51   { "glXCreateGLXPixmap", (__GLXextFuncPtr) glXCreateGLXPixmap },
52   { "glXDestroyContext", (__GLXextFuncPtr) glXDestroyContext },
53   { "glXDestroyGLXPixmap", (__GLXextFuncPtr) glXDestroyGLXPixmap },
54   { "glXGetConfig", (__GLXextFuncPtr) glXGetConfig },
55   { "glXGetCurrentContext", (__GLXextFuncPtr) glXGetCurrentContext },
56   { "glXGetCurrentDrawable", (__GLXextFuncPtr) glXGetCurrentDrawable },
57   { "glXIsDirect", (__GLXextFuncPtr) glXIsDirect },
58   { "glXMakeCurrent", (__GLXextFuncPtr) glXMakeCurrent },
59   { "glXQueryExtension", (__GLXextFuncPtr) glXQueryExtension },
60   { "glXQueryVersion", (__GLXextFuncPtr) glXQueryVersion },
61   { "glXSwapBuffers", (__GLXextFuncPtr) glXSwapBuffers },
62   { "glXUseXFont", (__GLXextFuncPtr) glXUseXFont },
63   { "glXWaitGL", (__GLXextFuncPtr) glXWaitGL },
64   { "glXWaitX", (__GLXextFuncPtr) glXWaitX },
65
66   /*** GLX_VERSION_1_1 ***/
67   { "glXGetClientString", (__GLXextFuncPtr) glXGetClientString },
68   { "glXQueryExtensionsString", (__GLXextFuncPtr) glXQueryExtensionsString },
69   { "glXQueryServerString", (__GLXextFuncPtr) glXQueryServerString },
70
71   /*** GLX_VERSION_1_2 ***/
72   { "glXGetCurrentDisplay", (__GLXextFuncPtr) glXGetCurrentDisplay },
73
74   /*** GLX_VERSION_1_3 ***/
75   { "glXChooseFBConfig", (__GLXextFuncPtr) glXChooseFBConfig },
76   { "glXCreateNewContext", (__GLXextFuncPtr) glXCreateNewContext },
77   { "glXCreatePbuffer", (__GLXextFuncPtr) glXCreatePbuffer },
78   { "glXCreatePixmap", (__GLXextFuncPtr) glXCreatePixmap },
79   { "glXCreateWindow", (__GLXextFuncPtr) glXCreateWindow },
80   { "glXDestroyPbuffer", (__GLXextFuncPtr) glXDestroyPbuffer },
81   { "glXDestroyPixmap", (__GLXextFuncPtr) glXDestroyPixmap },
82   { "glXDestroyWindow", (__GLXextFuncPtr) glXDestroyWindow },
83   { "glXGetCurrentReadDrawable", (__GLXextFuncPtr) glXGetCurrentReadDrawable },
84   { "glXGetFBConfigAttrib", (__GLXextFuncPtr) glXGetFBConfigAttrib },
85   { "glXGetFBConfigs", (__GLXextFuncPtr) glXGetFBConfigs },
86   { "glXGetSelectedEvent", (__GLXextFuncPtr) glXGetSelectedEvent },
87   { "glXGetVisualFromFBConfig", (__GLXextFuncPtr) glXGetVisualFromFBConfig },
88   { "glXMakeContextCurrent", (__GLXextFuncPtr) glXMakeContextCurrent },
89   { "glXQueryContext", (__GLXextFuncPtr) glXQueryContext },
90   { "glXQueryDrawable", (__GLXextFuncPtr) glXQueryDrawable },
91   { "glXSelectEvent", (__GLXextFuncPtr) glXSelectEvent },
92
93   /*** GLX_VERSION_1_4 ***/
94   { "glXGetProcAddress", (__GLXextFuncPtr) glXGetProcAddress },
95
96   /*** GLX_SGI_swap_control ***/
97   { "glXSwapIntervalSGI", (__GLXextFuncPtr) glXSwapIntervalSGI },
98
99   /*** GLX_SGI_video_sync ***/
100   { "glXGetVideoSyncSGI", (__GLXextFuncPtr) glXGetVideoSyncSGI },
101   { "glXWaitVideoSyncSGI", (__GLXextFuncPtr) glXWaitVideoSyncSGI },
102
103   /*** GLX_SGI_make_current_read ***/
104   { "glXMakeCurrentReadSGI", (__GLXextFuncPtr) glXMakeCurrentReadSGI },
105   { "glXGetCurrentReadDrawableSGI", (__GLXextFuncPtr) glXGetCurrentReadDrawableSGI },
106
107   /*** GLX_SGIX_video_source ***/
108#if defined(_VL_H)
109   { "glXCreateGLXVideoSourceSGIX", (__GLXextFuncPtr) glXCreateGLXVideoSourceSGIX },
110   { "glXDestroyGLXVideoSourceSGIX", (__GLXextFuncPtr) glXDestroyGLXVideoSourceSGIX },
111#endif
112
113   /*** GLX_EXT_import_context ***/
114   { "glXFreeContextEXT", (__GLXextFuncPtr) glXFreeContextEXT },
115   { "glXGetContextIDEXT", (__GLXextFuncPtr) glXGetContextIDEXT },
116   { "glXGetCurrentDisplayEXT", (__GLXextFuncPtr) glXGetCurrentDisplayEXT },
117   { "glXImportContextEXT", (__GLXextFuncPtr) glXImportContextEXT },
118   { "glXQueryContextInfoEXT", (__GLXextFuncPtr) glXQueryContextInfoEXT },
119
120   /*** GLX_SGIX_fbconfig ***/
121   { "glXGetFBConfigAttribSGIX", (__GLXextFuncPtr) glXGetFBConfigAttribSGIX },
122   { "glXChooseFBConfigSGIX", (__GLXextFuncPtr) glXChooseFBConfigSGIX },
123   { "glXCreateGLXPixmapWithConfigSGIX", (__GLXextFuncPtr) glXCreateGLXPixmapWithConfigSGIX },
124   { "glXCreateContextWithConfigSGIX", (__GLXextFuncPtr) glXCreateContextWithConfigSGIX },
125   { "glXGetVisualFromFBConfigSGIX", (__GLXextFuncPtr) glXGetVisualFromFBConfigSGIX },
126   { "glXGetFBConfigFromVisualSGIX", (__GLXextFuncPtr) glXGetFBConfigFromVisualSGIX },
127
128   /*** GLX_SGIX_pbuffer ***/
129   { "glXCreateGLXPbufferSGIX", (__GLXextFuncPtr) glXCreateGLXPbufferSGIX },
130   { "glXDestroyGLXPbufferSGIX", (__GLXextFuncPtr) glXDestroyGLXPbufferSGIX },
131   { "glXQueryGLXPbufferSGIX", (__GLXextFuncPtr) glXQueryGLXPbufferSGIX },
132   { "glXSelectEventSGIX", (__GLXextFuncPtr) glXSelectEventSGIX },
133   { "glXGetSelectedEventSGIX", (__GLXextFuncPtr) glXGetSelectedEventSGIX },
134
135   /*** GLX_SGI_cushion ***/
136   { "glXCushionSGI", (__GLXextFuncPtr) glXCushionSGI },
137
138   /*** GLX_SGIX_video_resize ***/
139   { "glXBindChannelToWindowSGIX", (__GLXextFuncPtr) glXBindChannelToWindowSGIX },
140   { "glXChannelRectSGIX", (__GLXextFuncPtr) glXChannelRectSGIX },
141   { "glXQueryChannelRectSGIX", (__GLXextFuncPtr) glXQueryChannelRectSGIX },
142   { "glXQueryChannelDeltasSGIX", (__GLXextFuncPtr) glXQueryChannelDeltasSGIX },
143   { "glXChannelRectSyncSGIX", (__GLXextFuncPtr) glXChannelRectSyncSGIX },
144
145   /*** GLX_SGIX_dmbuffer **/
146#if defined(_DM_BUFFER_H_)
147   { "glXAssociateDMPbufferSGIX", (__GLXextFuncPtr) glXAssociateDMPbufferSGIX },
148#endif
149
150   /*** GLX_SGIX_swap_group ***/
151   { "glXJoinSwapGroupSGIX", (__GLXextFuncPtr) glXJoinSwapGroupSGIX },
152
153   /*** GLX_SGIX_swap_barrier ***/
154   { "glXBindSwapBarrierSGIX", (__GLXextFuncPtr) glXBindSwapBarrierSGIX },
155   { "glXQueryMaxSwapBarriersSGIX", (__GLXextFuncPtr) glXQueryMaxSwapBarriersSGIX },
156
157   /*** GLX_SUN_get_transparent_index ***/
158   { "glXGetTransparentIndexSUN", (__GLXextFuncPtr) glXGetTransparentIndexSUN },
159
160   /*** GLX_MESA_copy_sub_buffer ***/
161   { "glXCopySubBufferMESA", (__GLXextFuncPtr) glXCopySubBufferMESA },
162
163   /*** GLX_MESA_pixmap_colormap ***/
164   { "glXCreateGLXPixmapMESA", (__GLXextFuncPtr) glXCreateGLXPixmapMESA },
165
166   /*** GLX_MESA_release_buffers ***/
167   { "glXReleaseBuffersMESA", (__GLXextFuncPtr) glXReleaseBuffersMESA },
168
169   /*** GLX_ARB_get_proc_address ***/
170   { "glXGetProcAddressARB", (__GLXextFuncPtr) glXGetProcAddressARB },
171
172   /*** GLX_EXT_texture_from_pixmap ***/
173   { "glXBindTexImageEXT", (__GLXextFuncPtr) glXBindTexImageEXT },
174   { "glXReleaseTexImageEXT", (__GLXextFuncPtr) glXReleaseTexImageEXT },
175
176   { NULL, NULL }   /* end of list */
177};
178
179
180
181/**
182 * Return address of named glX function, or NULL if not found.
183 */
184static __GLXextFuncPtr
185_glxapi_get_proc_address(const char *funcName)
186{
187   GLuint i;
188   for (i = 0; GLX_functions[i].Name; i++) {
189      if (strcmp(GLX_functions[i].Name, funcName) == 0)
190         return GLX_functions[i].Address;
191   }
192   return NULL;
193}
194
195
196PUBLIC __GLXextFuncPtr
197glXGetProcAddressARB(const GLubyte *procName)
198{
199   __GLXextFuncPtr f;
200
201   f = _glxapi_get_proc_address((const char *) procName);
202   if (f) {
203      return f;
204   }
205
206   f = (__GLXextFuncPtr) _glapi_get_proc_address((const char *) procName);
207   return f;
208}
209
210
211/* GLX 1.4 */
212PUBLIC
213void (*glXGetProcAddress(const GLubyte *procName))()
214{
215   return glXGetProcAddressARB(procName);
216}
217