OLD | NEW |
| (Empty) |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 // This file contains the implementation of pglGetProcAddress | |
6 | |
7 #include <string.h> | |
8 #include <GLES2/gl2.h> | |
9 | |
10 extern "C" { | |
11 | |
12 typedef void (*PGLFunctionPointer)(void); | |
13 struct PGLFunctionInfo { | |
14 PGLFunctionPointer func; | |
15 char const * const name; | |
16 }; | |
17 | |
18 void (*pglGetProcAddress(char const * procname))() { | |
19 static const struct PGLFunctionInfo gl_functions[] = { | |
20 { (PGLFunctionPointer)(&glActiveTexture), | |
21 "glActiveTexture", }, | |
22 { (PGLFunctionPointer)(&glAttachShader), | |
23 "glAttachShader", }, | |
24 { (PGLFunctionPointer)(&glBindAttribLocation), | |
25 "glBindAttribLocation", }, | |
26 { (PGLFunctionPointer)(&glBindBuffer), | |
27 "glBindBuffer", }, | |
28 { (PGLFunctionPointer)(&glBindFramebuffer), | |
29 "glBindFramebuffer", }, | |
30 { (PGLFunctionPointer)(&glBindRenderbuffer), | |
31 "glBindRenderbuffer", }, | |
32 { (PGLFunctionPointer)(&glBindTexture), | |
33 "glBindTexture", }, | |
34 { (PGLFunctionPointer)(&glBlendColor), | |
35 "glBlendColor", }, | |
36 { (PGLFunctionPointer)(&glBlendEquation), | |
37 "glBlendEquation", }, | |
38 { (PGLFunctionPointer)(&glBlendEquationSeparate), | |
39 "glBlendEquationSeparate", }, | |
40 { (PGLFunctionPointer)(&glBlendFunc), | |
41 "glBlendFunc", }, | |
42 { (PGLFunctionPointer)(&glBlendFuncSeparate), | |
43 "glBlendFuncSeparate", }, | |
44 { (PGLFunctionPointer)(&glBufferData), | |
45 "glBufferData", }, | |
46 { (PGLFunctionPointer)(&glBufferSubData), | |
47 "glBufferSubData", }, | |
48 { (PGLFunctionPointer)(&glCheckFramebufferStatus), | |
49 "glCheckFramebufferStatus", }, | |
50 { (PGLFunctionPointer)(&glClear), | |
51 "glClear", }, | |
52 { (PGLFunctionPointer)(&glClearColor), | |
53 "glClearColor", }, | |
54 { (PGLFunctionPointer)(&glClearDepthf), | |
55 "glClearDepthf", }, | |
56 { (PGLFunctionPointer)(&glClearStencil), | |
57 "glClearStencil", }, | |
58 { (PGLFunctionPointer)(&glColorMask), | |
59 "glColorMask", }, | |
60 { (PGLFunctionPointer)(&glCompileShader), | |
61 "glCompileShader", }, | |
62 { (PGLFunctionPointer)(&glCompressedTexImage2D), | |
63 "glCompressedTexImage2D", }, | |
64 { (PGLFunctionPointer)(&glCompressedTexSubImage2D), | |
65 "glCompressedTexSubImage2D", }, | |
66 { (PGLFunctionPointer)(&glCopyTexImage2D), | |
67 "glCopyTexImage2D", }, | |
68 { (PGLFunctionPointer)(&glCopyTexSubImage2D), | |
69 "glCopyTexSubImage2D", }, | |
70 { (PGLFunctionPointer)(&glCreateProgram), | |
71 "glCreateProgram", }, | |
72 { (PGLFunctionPointer)(&glCreateShader), | |
73 "glCreateShader", }, | |
74 { (PGLFunctionPointer)(&glCullFace), | |
75 "glCullFace", }, | |
76 { (PGLFunctionPointer)(&glDeleteBuffers), | |
77 "glDeleteBuffers", }, | |
78 { (PGLFunctionPointer)(&glDeleteFramebuffers), | |
79 "glDeleteFramebuffers", }, | |
80 { (PGLFunctionPointer)(&glDeleteProgram), | |
81 "glDeleteProgram", }, | |
82 { (PGLFunctionPointer)(&glDeleteRenderbuffers), | |
83 "glDeleteRenderbuffers", }, | |
84 { (PGLFunctionPointer)(&glDeleteShader), | |
85 "glDeleteShader", }, | |
86 { (PGLFunctionPointer)(&glDeleteTextures), | |
87 "glDeleteTextures", }, | |
88 { (PGLFunctionPointer)(&glDepthFunc), | |
89 "glDepthFunc", }, | |
90 { (PGLFunctionPointer)(&glDepthMask), | |
91 "glDepthMask", }, | |
92 { (PGLFunctionPointer)(&glDepthRangef), | |
93 "glDepthRangef", }, | |
94 { (PGLFunctionPointer)(&glDetachShader), | |
95 "glDetachShader", }, | |
96 { (PGLFunctionPointer)(&glDisable), | |
97 "glDisable", }, | |
98 { (PGLFunctionPointer)(&glDisableVertexAttribArray), | |
99 "glDisableVertexAttribArray", }, | |
100 { (PGLFunctionPointer)(&glDrawArrays), | |
101 "glDrawArrays", }, | |
102 { (PGLFunctionPointer)(&glDrawElements), | |
103 "glDrawElements", }, | |
104 { (PGLFunctionPointer)(&glEnable), | |
105 "glEnable", }, | |
106 { (PGLFunctionPointer)(&glEnableVertexAttribArray), | |
107 "glEnableVertexAttribArray", }, | |
108 { (PGLFunctionPointer)(&glFinish), | |
109 "glFinish", }, | |
110 { (PGLFunctionPointer)(&glFlush), | |
111 "glFlush", }, | |
112 { (PGLFunctionPointer)(&glFramebufferRenderbuffer), | |
113 "glFramebufferRenderbuffer", }, | |
114 { (PGLFunctionPointer)(&glFramebufferTexture2D), | |
115 "glFramebufferTexture2D", }, | |
116 { (PGLFunctionPointer)(&glFrontFace), | |
117 "glFrontFace", }, | |
118 { (PGLFunctionPointer)(&glGenBuffers), | |
119 "glGenBuffers", }, | |
120 { (PGLFunctionPointer)(&glGenerateMipmap), | |
121 "glGenerateMipmap", }, | |
122 { (PGLFunctionPointer)(&glGenFramebuffers), | |
123 "glGenFramebuffers", }, | |
124 { (PGLFunctionPointer)(&glGenRenderbuffers), | |
125 "glGenRenderbuffers", }, | |
126 { (PGLFunctionPointer)(&glGenTextures), | |
127 "glGenTextures", }, | |
128 { (PGLFunctionPointer)(&glGetActiveAttrib), | |
129 "glGetActiveAttrib", }, | |
130 { (PGLFunctionPointer)(&glGetActiveUniform), | |
131 "glGetActiveUniform", }, | |
132 { (PGLFunctionPointer)(&glGetAttachedShaders), | |
133 "glGetAttachedShaders", }, | |
134 { (PGLFunctionPointer)(&glGetAttribLocation), | |
135 "glGetAttribLocation", }, | |
136 { (PGLFunctionPointer)(&glGetBooleanv), | |
137 "glGetBooleanv", }, | |
138 { (PGLFunctionPointer)(&glGetBufferParameteriv), | |
139 "glGetBufferParameteriv", }, | |
140 { (PGLFunctionPointer)(&glGetError), | |
141 "glGetError", }, | |
142 { (PGLFunctionPointer)(&glGetFloatv), | |
143 "glGetFloatv", }, | |
144 { (PGLFunctionPointer)(&glGetFramebufferAttachmentParameteriv), | |
145 "glGetFramebufferAttachmentParameteriv", }, | |
146 { (PGLFunctionPointer)(&glGetIntegerv), | |
147 "glGetIntegerv", }, | |
148 { (PGLFunctionPointer)(&glGetProgramiv), | |
149 "glGetProgramiv", }, | |
150 { (PGLFunctionPointer)(&glGetProgramInfoLog), | |
151 "glGetProgramInfoLog", }, | |
152 { (PGLFunctionPointer)(&glGetRenderbufferParameteriv), | |
153 "glGetRenderbufferParameteriv", }, | |
154 { (PGLFunctionPointer)(&glGetShaderiv), | |
155 "glGetShaderiv", }, | |
156 { (PGLFunctionPointer)(&glGetShaderInfoLog), | |
157 "glGetShaderInfoLog", }, | |
158 { (PGLFunctionPointer)(&glGetShaderPrecisionFormat), | |
159 "glGetShaderPrecisionFormat", }, | |
160 { (PGLFunctionPointer)(&glGetShaderSource), | |
161 "glGetShaderSource", }, | |
162 { (PGLFunctionPointer)(&glGetString), | |
163 "glGetString", }, | |
164 { (PGLFunctionPointer)(&glGetTexParameterfv), | |
165 "glGetTexParameterfv", }, | |
166 { (PGLFunctionPointer)(&glGetTexParameteriv), | |
167 "glGetTexParameteriv", }, | |
168 { (PGLFunctionPointer)(&glGetUniformfv), | |
169 "glGetUniformfv", }, | |
170 { (PGLFunctionPointer)(&glGetUniformiv), | |
171 "glGetUniformiv", }, | |
172 { (PGLFunctionPointer)(&glGetUniformLocation), | |
173 "glGetUniformLocation", }, | |
174 { (PGLFunctionPointer)(&glGetVertexAttribfv), | |
175 "glGetVertexAttribfv", }, | |
176 { (PGLFunctionPointer)(&glGetVertexAttribiv), | |
177 "glGetVertexAttribiv", }, | |
178 { (PGLFunctionPointer)(&glGetVertexAttribPointerv), | |
179 "glGetVertexAttribPointerv", }, | |
180 { (PGLFunctionPointer)(&glHint), | |
181 "glHint", }, | |
182 { (PGLFunctionPointer)(&glIsBuffer), | |
183 "glIsBuffer", }, | |
184 { (PGLFunctionPointer)(&glIsEnabled), | |
185 "glIsEnabled", }, | |
186 { (PGLFunctionPointer)(&glIsFramebuffer), | |
187 "glIsFramebuffer", }, | |
188 { (PGLFunctionPointer)(&glIsProgram), | |
189 "glIsProgram", }, | |
190 { (PGLFunctionPointer)(&glIsRenderbuffer), | |
191 "glIsRenderbuffer", }, | |
192 { (PGLFunctionPointer)(&glIsShader), | |
193 "glIsShader", }, | |
194 { (PGLFunctionPointer)(&glIsTexture), | |
195 "glIsTexture", }, | |
196 { (PGLFunctionPointer)(&glLineWidth), | |
197 "glLineWidth", }, | |
198 { (PGLFunctionPointer)(&glLinkProgram), | |
199 "glLinkProgram", }, | |
200 { (PGLFunctionPointer)(&glPixelStorei), | |
201 "glPixelStorei", }, | |
202 { (PGLFunctionPointer)(&glPolygonOffset), | |
203 "glPolygonOffset", }, | |
204 { (PGLFunctionPointer)(&glReadPixels), | |
205 "glReadPixels", }, | |
206 { (PGLFunctionPointer)(&glReleaseShaderCompiler), | |
207 "glReleaseShaderCompiler", }, | |
208 { (PGLFunctionPointer)(&glRenderbufferStorage), | |
209 "glRenderbufferStorage", }, | |
210 { (PGLFunctionPointer)(&glSampleCoverage), | |
211 "glSampleCoverage", }, | |
212 { (PGLFunctionPointer)(&glScissor), | |
213 "glScissor", }, | |
214 { (PGLFunctionPointer)(&glShaderBinary), | |
215 "glShaderBinary", }, | |
216 { (PGLFunctionPointer)(&glShaderSource), | |
217 "glShaderSource", }, | |
218 { (PGLFunctionPointer)(&glStencilFunc), | |
219 "glStencilFunc", }, | |
220 { (PGLFunctionPointer)(&glStencilFuncSeparate), | |
221 "glStencilFuncSeparate", }, | |
222 { (PGLFunctionPointer)(&glStencilMask), | |
223 "glStencilMask", }, | |
224 { (PGLFunctionPointer)(&glStencilMaskSeparate), | |
225 "glStencilMaskSeparate", }, | |
226 { (PGLFunctionPointer)(&glStencilOp), | |
227 "glStencilOp", }, | |
228 { (PGLFunctionPointer)(&glStencilOpSeparate), | |
229 "glStencilOpSeparate", }, | |
230 { (PGLFunctionPointer)(&glTexImage2D), | |
231 "glTexImage2D", }, | |
232 { (PGLFunctionPointer)(&glTexParameterf), | |
233 "glTexParameterf", }, | |
234 { (PGLFunctionPointer)(&glTexParameterfv), | |
235 "glTexParameterfv", }, | |
236 { (PGLFunctionPointer)(&glTexParameteri), | |
237 "glTexParameteri", }, | |
238 { (PGLFunctionPointer)(&glTexParameteriv), | |
239 "glTexParameteriv", }, | |
240 { (PGLFunctionPointer)(&glTexSubImage2D), | |
241 "glTexSubImage2D", }, | |
242 { (PGLFunctionPointer)(&glUniform1f), | |
243 "glUniform1f", }, | |
244 { (PGLFunctionPointer)(&glUniform1fv), | |
245 "glUniform1fv", }, | |
246 { (PGLFunctionPointer)(&glUniform1i), | |
247 "glUniform1i", }, | |
248 { (PGLFunctionPointer)(&glUniform1iv), | |
249 "glUniform1iv", }, | |
250 { (PGLFunctionPointer)(&glUniform2f), | |
251 "glUniform2f", }, | |
252 { (PGLFunctionPointer)(&glUniform2fv), | |
253 "glUniform2fv", }, | |
254 { (PGLFunctionPointer)(&glUniform2i), | |
255 "glUniform2i", }, | |
256 { (PGLFunctionPointer)(&glUniform2iv), | |
257 "glUniform2iv", }, | |
258 { (PGLFunctionPointer)(&glUniform3f), | |
259 "glUniform3f", }, | |
260 { (PGLFunctionPointer)(&glUniform3fv), | |
261 "glUniform3fv", }, | |
262 { (PGLFunctionPointer)(&glUniform3i), | |
263 "glUniform3i", }, | |
264 { (PGLFunctionPointer)(&glUniform3iv), | |
265 "glUniform3iv", }, | |
266 { (PGLFunctionPointer)(&glUniform4f), | |
267 "glUniform4f", }, | |
268 { (PGLFunctionPointer)(&glUniform4fv), | |
269 "glUniform4fv", }, | |
270 { (PGLFunctionPointer)(&glUniform4i), | |
271 "glUniform4i", }, | |
272 { (PGLFunctionPointer)(&glUniform4iv), | |
273 "glUniform4iv", }, | |
274 { (PGLFunctionPointer)(&glUniformMatrix2fv), | |
275 "glUniformMatrix2fv", }, | |
276 { (PGLFunctionPointer)(&glUniformMatrix3fv), | |
277 "glUniformMatrix3fv", }, | |
278 { (PGLFunctionPointer)(&glUniformMatrix4fv), | |
279 "glUniformMatrix4fv", }, | |
280 { (PGLFunctionPointer)(&glUseProgram), | |
281 "glUseProgram", }, | |
282 { (PGLFunctionPointer)(&glValidateProgram), | |
283 "glValidateProgram", }, | |
284 { (PGLFunctionPointer)(&glVertexAttrib1f), | |
285 "glVertexAttrib1f", }, | |
286 { (PGLFunctionPointer)(&glVertexAttrib1fv), | |
287 "glVertexAttrib1fv", }, | |
288 { (PGLFunctionPointer)(&glVertexAttrib2f), | |
289 "glVertexAttrib2f", }, | |
290 { (PGLFunctionPointer)(&glVertexAttrib2fv), | |
291 "glVertexAttrib2fv", }, | |
292 { (PGLFunctionPointer)(&glVertexAttrib3f), | |
293 "glVertexAttrib3f", }, | |
294 { (PGLFunctionPointer)(&glVertexAttrib3fv), | |
295 "glVertexAttrib3fv", }, | |
296 { (PGLFunctionPointer)(&glVertexAttrib4f), | |
297 "glVertexAttrib4f", }, | |
298 { (PGLFunctionPointer)(&glVertexAttrib4fv), | |
299 "glVertexAttrib4fv", }, | |
300 { (PGLFunctionPointer)(&glVertexAttribPointer), | |
301 "glVertexAttribPointer", }, | |
302 { (PGLFunctionPointer)(&glViewport), | |
303 "glViewport", }, | |
304 }; | |
305 | |
306 unsigned int num_functions = sizeof(gl_functions) / sizeof(gl_functions[0]); | |
307 for (unsigned int ii = 0; ii < num_functions; ++ii) { | |
308 if (strcmp(gl_functions[ii].name, procname) == 0) { | |
309 return gl_functions[ii].func; | |
310 } | |
311 } | |
312 return NULL; | |
313 } | |
314 } // extern "C" | |
315 | |
OLD | NEW |