Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mesa
Path: blob/21.2-virgl/src/gallium/frontends/glx/xlib/glx_getproc.c
4561 views
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 const 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_SUN_get_transparent_index ***/
151
{ "glXGetTransparentIndexSUN", (__GLXextFuncPtr) glXGetTransparentIndexSUN },
152
153
/*** GLX_MESA_copy_sub_buffer ***/
154
{ "glXCopySubBufferMESA", (__GLXextFuncPtr) glXCopySubBufferMESA },
155
156
/*** GLX_MESA_pixmap_colormap ***/
157
{ "glXCreateGLXPixmapMESA", (__GLXextFuncPtr) glXCreateGLXPixmapMESA },
158
159
/*** GLX_MESA_release_buffers ***/
160
{ "glXReleaseBuffersMESA", (__GLXextFuncPtr) glXReleaseBuffersMESA },
161
162
/*** GLX_ARB_get_proc_address ***/
163
{ "glXGetProcAddressARB", (__GLXextFuncPtr) glXGetProcAddressARB },
164
165
/*** GLX_ARB_create_context ***/
166
{ "glXCreateContextAttribsARB", (__GLXextFuncPtr) glXCreateContextAttribsARB },
167
168
/*** GLX_EXT_texture_from_pixmap ***/
169
{ "glXBindTexImageEXT", (__GLXextFuncPtr) glXBindTexImageEXT },
170
{ "glXReleaseTexImageEXT", (__GLXextFuncPtr) glXReleaseTexImageEXT },
171
172
{ NULL, NULL } /* end of list */
173
};
174
175
176
177
/**
178
* Return address of named glX function, or NULL if not found.
179
*/
180
static __GLXextFuncPtr
181
_glxapi_get_proc_address(const char *funcName)
182
{
183
GLuint i;
184
for (i = 0; GLX_functions[i].Name; i++) {
185
if (strcmp(GLX_functions[i].Name, funcName) == 0)
186
return GLX_functions[i].Address;
187
}
188
return NULL;
189
}
190
191
192
PUBLIC __GLXextFuncPtr
193
glXGetProcAddressARB(const GLubyte *procName)
194
{
195
__GLXextFuncPtr f;
196
197
f = _glxapi_get_proc_address((const char *) procName);
198
if (f) {
199
return f;
200
}
201
202
f = (__GLXextFuncPtr) _glapi_get_proc_address((const char *) procName);
203
return f;
204
}
205
206
207
/* GLX 1.4 */
208
PUBLIC
209
void (*glXGetProcAddress(const GLubyte *procName))()
210
{
211
return glXGetProcAddressARB(procName);
212
}
213
214