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