1 /*
2 * Mesa 3-D graphics library
3 *
4 * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
5 * Copyright (C) 2009 VMware, Inc. All Rights Reserved.
6 *
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:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
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 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 * 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 "pipe/p_compiler.h"
36 #include "GL/glx.h"
37 #include "glapi/glapi.h"
38
39
40 struct name_address_pair {
41 const char *Name;
42 __GLXextFuncPtr Address;
43 };
44
45
46 static 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_ARB_create_context ***/
173 { "glXCreateContextAttribsARB", (__GLXextFuncPtr) glXCreateContextAttribsARB },
174
175 /*** GLX_EXT_texture_from_pixmap ***/
176 { "glXBindTexImageEXT", (__GLXextFuncPtr) glXBindTexImageEXT },
177 { "glXReleaseTexImageEXT", (__GLXextFuncPtr) glXReleaseTexImageEXT },
178
179 { NULL, NULL } /* end of list */
180 };
181
182
183
184 /**
185 * Return address of named glX function, or NULL if not found.
186 */
187 static __GLXextFuncPtr
_glxapi_get_proc_address(const char * funcName)188 _glxapi_get_proc_address(const char *funcName)
189 {
190 GLuint i;
191 for (i = 0; GLX_functions[i].Name; i++) {
192 if (strcmp(GLX_functions[i].Name, funcName) == 0)
193 return GLX_functions[i].Address;
194 }
195 return NULL;
196 }
197
198
199 PUBLIC __GLXextFuncPtr
glXGetProcAddressARB(const GLubyte * procName)200 glXGetProcAddressARB(const GLubyte *procName)
201 {
202 __GLXextFuncPtr f;
203
204 f = _glxapi_get_proc_address((const char *) procName);
205 if (f) {
206 return f;
207 }
208
209 f = (__GLXextFuncPtr) _glapi_get_proc_address((const char *) procName);
210 return f;
211 }
212
213
214 /* GLX 1.4 */
215 PUBLIC
glXGetProcAddress(const GLubyte * procName)216 void (*glXGetProcAddress(const GLubyte *procName))()
217 {
218 return glXGetProcAddressARB(procName);
219 }
220