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