José Fonseca | c6b49ce | 2010-11-28 16:43:04 +0000 | [diff] [blame] | 1 | ########################################################################## |
| 2 | # |
| 3 | # Copyright 2010 VMware, Inc. |
| 4 | # All Rights Reserved. |
| 5 | # |
| 6 | # Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | # of this software and associated documentation files (the "Software"), to deal |
| 8 | # in the Software without restriction, including without limitation the rights |
| 9 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 10 | # copies of the Software, and to permit persons to whom the Software is |
| 11 | # furnished to do so, subject to the following conditions: |
| 12 | # |
| 13 | # The above copyright notice and this permission notice shall be included in |
| 14 | # all copies or substantial portions of the Software. |
| 15 | # |
| 16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 22 | # THE SOFTWARE. |
| 23 | # |
| 24 | ##########################################################################/ |
| 25 | |
| 26 | |
José Fonseca | 4a826ed | 2010-11-30 16:58:22 +0000 | [diff] [blame] | 27 | """Generated an header, glproc.hpp, which does pretty much what GLEW does, but |
| 28 | covers all the functions we support. |
| 29 | """ |
| 30 | |
| 31 | |
José Fonseca | e91f5bc | 2014-07-17 20:42:35 +0100 | [diff] [blame] | 32 | import sys |
| 33 | |
José Fonseca | 669b200 | 2011-02-20 13:32:19 +0000 | [diff] [blame] | 34 | from dispatch import Dispatcher |
José Fonseca | 4f242f4 | 2012-04-14 18:13:25 +0100 | [diff] [blame] | 35 | import specs.stdapi as stdapi |
José Fonseca | bd86a22 | 2011-09-27 09:21:38 +0100 | [diff] [blame] | 36 | from specs.glapi import glapi |
| 37 | from specs.glxapi import glxapi |
| 38 | from specs.wglapi import wglapi |
| 39 | from specs.cglapi import cglapi |
Chia-I Wu | e50c14b | 2011-11-03 12:24:53 +0800 | [diff] [blame] | 40 | from specs.eglapi import eglapi |
José Fonseca | c6b49ce | 2010-11-28 16:43:04 +0000 | [diff] [blame] | 41 | |
| 42 | |
José Fonseca | 68ec412 | 2011-02-20 11:25:25 +0000 | [diff] [blame] | 43 | # See http://www.opengl.org/registry/ABI/ |
José Fonseca | c6b49ce | 2010-11-28 16:43:04 +0000 | [diff] [blame] | 44 | public_symbols = set([ |
José Fonseca | b87c229 | 2011-10-09 14:56:16 +0100 | [diff] [blame] | 45 | # GL 1.2 and ARB_multitexture |
| 46 | "glAccum", |
| 47 | "glAlphaFunc", |
| 48 | "glAreTexturesResident", |
| 49 | "glArrayElement", |
| 50 | "glBegin", |
| 51 | "glBindTexture", |
| 52 | "glBitmap", |
| 53 | "glBlendFunc", |
| 54 | "glCallList", |
| 55 | "glCallLists", |
| 56 | "glClear", |
| 57 | "glClearAccum", |
| 58 | "glClearColor", |
| 59 | "glClearDepth", |
| 60 | "glClearIndex", |
| 61 | "glClearStencil", |
| 62 | "glClipPlane", |
| 63 | "glColor3b", |
| 64 | "glColor3bv", |
| 65 | "glColor3d", |
| 66 | "glColor3dv", |
| 67 | "glColor3f", |
| 68 | "glColor3fv", |
| 69 | "glColor3i", |
| 70 | "glColor3iv", |
| 71 | "glColor3s", |
| 72 | "glColor3sv", |
| 73 | "glColor3ub", |
| 74 | "glColor3ubv", |
| 75 | "glColor3ui", |
| 76 | "glColor3uiv", |
| 77 | "glColor3us", |
| 78 | "glColor3usv", |
| 79 | "glColor4b", |
| 80 | "glColor4bv", |
| 81 | "glColor4d", |
| 82 | "glColor4dv", |
| 83 | "glColor4f", |
| 84 | "glColor4fv", |
| 85 | "glColor4i", |
| 86 | "glColor4iv", |
| 87 | "glColor4s", |
| 88 | "glColor4sv", |
| 89 | "glColor4ub", |
| 90 | "glColor4ubv", |
| 91 | "glColor4ui", |
| 92 | "glColor4uiv", |
| 93 | "glColor4us", |
| 94 | "glColor4usv", |
| 95 | "glColorMask", |
| 96 | "glColorMaterial", |
| 97 | "glColorPointer", |
| 98 | "glCopyPixels", |
| 99 | "glCopyTexImage1D", |
| 100 | "glCopyTexImage2D", |
| 101 | "glCopyTexSubImage1D", |
| 102 | "glCopyTexSubImage2D", |
| 103 | "glCullFace", |
| 104 | "glDeleteLists", |
| 105 | "glDeleteTextures", |
| 106 | "glDepthFunc", |
| 107 | "glDepthMask", |
| 108 | "glDepthRange", |
| 109 | "glDisable", |
| 110 | "glDisableClientState", |
| 111 | "glDrawArrays", |
| 112 | "glDrawBuffer", |
| 113 | "glDrawElements", |
| 114 | "glDrawPixels", |
| 115 | "glEdgeFlag", |
| 116 | "glEdgeFlagPointer", |
| 117 | "glEdgeFlagv", |
| 118 | "glEnable", |
| 119 | "glEnableClientState", |
| 120 | "glEnd", |
| 121 | "glEndList", |
| 122 | "glEvalCoord1d", |
| 123 | "glEvalCoord1dv", |
| 124 | "glEvalCoord1f", |
| 125 | "glEvalCoord1fv", |
| 126 | "glEvalCoord2d", |
| 127 | "glEvalCoord2dv", |
| 128 | "glEvalCoord2f", |
| 129 | "glEvalCoord2fv", |
| 130 | "glEvalMesh1", |
| 131 | "glEvalMesh2", |
| 132 | "glEvalPoint1", |
| 133 | "glEvalPoint2", |
| 134 | "glFeedbackBuffer", |
| 135 | "glFinish", |
| 136 | "glFlush", |
| 137 | "glFogf", |
| 138 | "glFogfv", |
| 139 | "glFogi", |
| 140 | "glFogiv", |
| 141 | "glFrontFace", |
| 142 | "glFrustum", |
| 143 | "glGenLists", |
| 144 | "glGenTextures", |
| 145 | "glGetBooleanv", |
| 146 | "glGetClipPlane", |
| 147 | "glGetDoublev", |
| 148 | "glGetError", |
| 149 | "glGetFloatv", |
| 150 | "glGetIntegerv", |
| 151 | "glGetLightfv", |
| 152 | "glGetLightiv", |
| 153 | "glGetMapdv", |
| 154 | "glGetMapfv", |
| 155 | "glGetMapiv", |
| 156 | "glGetMaterialfv", |
| 157 | "glGetMaterialiv", |
| 158 | "glGetPixelMapfv", |
| 159 | "glGetPixelMapuiv", |
| 160 | "glGetPixelMapusv", |
| 161 | "glGetPointerv", |
| 162 | "glGetPolygonStipple", |
| 163 | "glGetString", |
| 164 | "glGetTexEnvfv", |
| 165 | "glGetTexEnviv", |
| 166 | "glGetTexGendv", |
| 167 | "glGetTexGenfv", |
| 168 | "glGetTexGeniv", |
| 169 | "glGetTexImage", |
| 170 | "glGetTexLevelParameterfv", |
| 171 | "glGetTexLevelParameteriv", |
| 172 | "glGetTexParameterfv", |
| 173 | "glGetTexParameteriv", |
| 174 | "glHint", |
| 175 | "glIndexMask", |
| 176 | "glIndexPointer", |
| 177 | "glIndexd", |
| 178 | "glIndexdv", |
| 179 | "glIndexf", |
| 180 | "glIndexfv", |
| 181 | "glIndexi", |
| 182 | "glIndexiv", |
| 183 | "glIndexs", |
| 184 | "glIndexsv", |
| 185 | "glIndexub", |
| 186 | "glIndexubv", |
| 187 | "glInitNames", |
| 188 | "glInterleavedArrays", |
| 189 | "glIsEnabled", |
| 190 | "glIsList", |
| 191 | "glIsTexture", |
| 192 | "glLightModelf", |
| 193 | "glLightModelfv", |
| 194 | "glLightModeli", |
| 195 | "glLightModeliv", |
| 196 | "glLightf", |
| 197 | "glLightfv", |
| 198 | "glLighti", |
| 199 | "glLightiv", |
| 200 | "glLineStipple", |
| 201 | "glLineWidth", |
| 202 | "glListBase", |
| 203 | "glLoadIdentity", |
| 204 | "glLoadMatrixd", |
| 205 | "glLoadMatrixf", |
| 206 | "glLoadName", |
| 207 | "glLogicOp", |
| 208 | "glMap1d", |
| 209 | "glMap1f", |
| 210 | "glMap2d", |
| 211 | "glMap2f", |
| 212 | "glMapGrid1d", |
| 213 | "glMapGrid1f", |
| 214 | "glMapGrid2d", |
| 215 | "glMapGrid2f", |
| 216 | "glMaterialf", |
| 217 | "glMaterialfv", |
| 218 | "glMateriali", |
| 219 | "glMaterialiv", |
| 220 | "glMatrixMode", |
| 221 | "glMultMatrixd", |
| 222 | "glMultMatrixf", |
| 223 | "glNewList", |
| 224 | "glNormal3b", |
| 225 | "glNormal3bv", |
| 226 | "glNormal3d", |
| 227 | "glNormal3dv", |
| 228 | "glNormal3f", |
| 229 | "glNormal3fv", |
| 230 | "glNormal3i", |
| 231 | "glNormal3iv", |
| 232 | "glNormal3s", |
| 233 | "glNormal3sv", |
| 234 | "glNormalPointer", |
| 235 | "glOrtho", |
| 236 | "glPassThrough", |
| 237 | "glPixelMapfv", |
| 238 | "glPixelMapuiv", |
| 239 | "glPixelMapusv", |
| 240 | "glPixelStoref", |
| 241 | "glPixelStorei", |
| 242 | "glPixelTransferf", |
| 243 | "glPixelTransferi", |
| 244 | "glPixelZoom", |
| 245 | "glPointSize", |
| 246 | "glPolygonMode", |
| 247 | "glPolygonOffset", |
| 248 | "glPolygonStipple", |
| 249 | "glPopAttrib", |
| 250 | "glPopClientAttrib", |
| 251 | "glPopMatrix", |
| 252 | "glPopName", |
| 253 | "glPrioritizeTextures", |
| 254 | "glPushAttrib", |
| 255 | "glPushClientAttrib", |
| 256 | "glPushMatrix", |
| 257 | "glPushName", |
| 258 | "glRasterPos2d", |
| 259 | "glRasterPos2dv", |
| 260 | "glRasterPos2f", |
| 261 | "glRasterPos2fv", |
| 262 | "glRasterPos2i", |
| 263 | "glRasterPos2iv", |
| 264 | "glRasterPos2s", |
| 265 | "glRasterPos2sv", |
| 266 | "glRasterPos3d", |
| 267 | "glRasterPos3dv", |
| 268 | "glRasterPos3f", |
| 269 | "glRasterPos3fv", |
| 270 | "glRasterPos3i", |
| 271 | "glRasterPos3iv", |
| 272 | "glRasterPos3s", |
| 273 | "glRasterPos3sv", |
| 274 | "glRasterPos4d", |
| 275 | "glRasterPos4dv", |
| 276 | "glRasterPos4f", |
| 277 | "glRasterPos4fv", |
| 278 | "glRasterPos4i", |
| 279 | "glRasterPos4iv", |
| 280 | "glRasterPos4s", |
| 281 | "glRasterPos4sv", |
| 282 | "glReadBuffer", |
| 283 | "glReadPixels", |
| 284 | "glRectd", |
| 285 | "glRectdv", |
| 286 | "glRectf", |
| 287 | "glRectfv", |
| 288 | "glRecti", |
| 289 | "glRectiv", |
| 290 | "glRects", |
| 291 | "glRectsv", |
| 292 | "glRenderMode", |
| 293 | "glRotated", |
| 294 | "glRotatef", |
| 295 | "glScaled", |
| 296 | "glScalef", |
| 297 | "glScissor", |
| 298 | "glSelectBuffer", |
| 299 | "glShadeModel", |
| 300 | "glStencilFunc", |
| 301 | "glStencilMask", |
| 302 | "glStencilOp", |
| 303 | "glTexCoord1d", |
| 304 | "glTexCoord1dv", |
| 305 | "glTexCoord1f", |
| 306 | "glTexCoord1fv", |
| 307 | "glTexCoord1i", |
| 308 | "glTexCoord1iv", |
| 309 | "glTexCoord1s", |
| 310 | "glTexCoord1sv", |
| 311 | "glTexCoord2d", |
| 312 | "glTexCoord2dv", |
| 313 | "glTexCoord2f", |
| 314 | "glTexCoord2fv", |
| 315 | "glTexCoord2i", |
| 316 | "glTexCoord2iv", |
| 317 | "glTexCoord2s", |
| 318 | "glTexCoord2sv", |
| 319 | "glTexCoord3d", |
| 320 | "glTexCoord3dv", |
| 321 | "glTexCoord3f", |
| 322 | "glTexCoord3fv", |
| 323 | "glTexCoord3i", |
| 324 | "glTexCoord3iv", |
| 325 | "glTexCoord3s", |
| 326 | "glTexCoord3sv", |
| 327 | "glTexCoord4d", |
| 328 | "glTexCoord4dv", |
| 329 | "glTexCoord4f", |
| 330 | "glTexCoord4fv", |
| 331 | "glTexCoord4i", |
| 332 | "glTexCoord4iv", |
| 333 | "glTexCoord4s", |
| 334 | "glTexCoord4sv", |
| 335 | "glTexCoordPointer", |
| 336 | "glTexEnvf", |
| 337 | "glTexEnvfv", |
| 338 | "glTexEnvi", |
| 339 | "glTexEnviv", |
| 340 | "glTexGend", |
| 341 | "glTexGendv", |
| 342 | "glTexGenf", |
| 343 | "glTexGenfv", |
| 344 | "glTexGeni", |
| 345 | "glTexGeniv", |
| 346 | "glTexImage1D", |
| 347 | "glTexImage2D", |
| 348 | "glTexParameterf", |
| 349 | "glTexParameterfv", |
| 350 | "glTexParameteri", |
| 351 | "glTexParameteriv", |
| 352 | "glTexSubImage1D", |
| 353 | "glTexSubImage2D", |
| 354 | "glTranslated", |
| 355 | "glTranslatef", |
| 356 | "glVertex2d", |
| 357 | "glVertex2dv", |
| 358 | "glVertex2f", |
| 359 | "glVertex2fv", |
| 360 | "glVertex2i", |
| 361 | "glVertex2iv", |
| 362 | "glVertex2s", |
| 363 | "glVertex2sv", |
| 364 | "glVertex3d", |
| 365 | "glVertex3dv", |
| 366 | "glVertex3f", |
| 367 | "glVertex3fv", |
| 368 | "glVertex3i", |
| 369 | "glVertex3iv", |
| 370 | "glVertex3s", |
| 371 | "glVertex3sv", |
| 372 | "glVertex4d", |
| 373 | "glVertex4dv", |
| 374 | "glVertex4f", |
| 375 | "glVertex4fv", |
| 376 | "glVertex4i", |
| 377 | "glVertex4iv", |
| 378 | "glVertex4s", |
| 379 | "glVertex4sv", |
| 380 | "glVertexPointer", |
| 381 | "glViewport", |
José Fonseca | 68ec412 | 2011-02-20 11:25:25 +0000 | [diff] [blame] | 382 | |
José Fonseca | b87c229 | 2011-10-09 14:56:16 +0100 | [diff] [blame] | 383 | # GLX 1.3 and GLX_ARB_get_proc_address |
| 384 | "glXChooseVisual", |
| 385 | "glXCreateContext", |
| 386 | "glXDestroyContext", |
| 387 | "glXMakeCurrent", |
| 388 | "glXCopyContext", |
| 389 | "glXSwapBuffers", |
| 390 | "glXCreateGLXPixmap", |
| 391 | "glXDestroyGLXPixmap", |
| 392 | "glXQueryExtension", |
| 393 | "glXQueryVersion", |
| 394 | "glXIsDirect", |
| 395 | "glXGetConfig", |
| 396 | "glXGetCurrentContext", |
| 397 | "glXGetCurrentDrawable", |
| 398 | "glXWaitGL", |
| 399 | "glXWaitX", |
| 400 | "glXUseXFont", |
| 401 | "glXQueryExtensionsString", |
| 402 | "glXQueryServerString", |
| 403 | "glXGetClientString", |
| 404 | "glXGetCurrentDisplay", |
| 405 | "glXChooseFBConfig", |
| 406 | "glXGetFBConfigAttrib", |
| 407 | "glXGetFBConfigs", |
| 408 | "glXGetVisualFromFBConfig", |
| 409 | "glXCreateWindow", |
| 410 | "glXDestroyWindow", |
| 411 | "glXCreatePixmap", |
| 412 | "glXDestroyPixmap", |
| 413 | "glXCreatePbuffer", |
| 414 | "glXDestroyPbuffer", |
| 415 | "glXQueryDrawable", |
| 416 | "glXCreateNewContext", |
| 417 | "glXMakeContextCurrent", |
| 418 | "glXGetCurrentReadDrawable", |
| 419 | "glXQueryContext", |
| 420 | "glXSelectEvent", |
| 421 | "glXGetSelectedEvent", |
José Fonseca | 68ec412 | 2011-02-20 11:25:25 +0000 | [diff] [blame] | 422 | "glXGetProcAddressARB", |
| 423 | "glXGetProcAddress", |
José Fonseca | b87c229 | 2011-10-09 14:56:16 +0100 | [diff] [blame] | 424 | |
| 425 | # WGL |
| 426 | #"glDebugEntry", |
| 427 | "wglChoosePixelFormat", |
| 428 | "wglCopyContext", |
| 429 | "wglCreateContext", |
| 430 | "wglCreateLayerContext", |
| 431 | "wglDeleteContext", |
| 432 | "wglDescribeLayerPlane", |
| 433 | "wglDescribePixelFormat", |
| 434 | "wglGetCurrentContext", |
| 435 | "wglGetCurrentDC", |
| 436 | "wglGetDefaultProcAddress", |
| 437 | "wglGetLayerPaletteEntries", |
| 438 | "wglGetPixelFormat", |
| 439 | "wglGetProcAddress", |
| 440 | "wglMakeCurrent", |
| 441 | "wglRealizeLayerPalette", |
| 442 | "wglSetLayerPaletteEntries", |
| 443 | "wglSetPixelFormat", |
| 444 | "wglShareLists", |
| 445 | "wglSwapBuffers", |
| 446 | "wglSwapLayerBuffers", |
| 447 | "wglSwapMultipleBuffers", |
| 448 | "wglUseFontBitmapsA", |
| 449 | "wglUseFontBitmapsW", |
| 450 | "wglUseFontOutlinesA", |
| 451 | "wglUseFontOutlinesW", |
| 452 | |
José Fonseca | c6b49ce | 2010-11-28 16:43:04 +0000 | [diff] [blame] | 453 | ]) |
| 454 | |
Chia-I Wu | e50c14b | 2011-11-03 12:24:53 +0800 | [diff] [blame] | 455 | # EGL 1.4 |
| 456 | public_symbols.update([ |
| 457 | "eglBindAPI", |
| 458 | "eglBindTexImage", |
| 459 | "eglChooseConfig", |
| 460 | "eglCopyBuffers", |
| 461 | "eglCreateContext", |
| 462 | "eglCreatePbufferFromClientBuffer", |
| 463 | "eglCreatePbufferSurface", |
| 464 | "eglCreatePixmapSurface", |
| 465 | "eglCreateWindowSurface", |
| 466 | "eglDestroyContext", |
| 467 | "eglDestroySurface", |
| 468 | "eglGetConfigAttrib", |
| 469 | "eglGetConfigs", |
| 470 | "eglGetCurrentContext", |
| 471 | "eglGetCurrentDisplay", |
| 472 | "eglGetCurrentSurface", |
| 473 | "eglGetDisplay", |
| 474 | "eglGetError", |
| 475 | "eglGetProcAddress", |
| 476 | "eglInitialize", |
| 477 | "eglMakeCurrent", |
| 478 | "eglQueryAPI", |
| 479 | "eglQueryContext", |
| 480 | "eglQueryString", |
| 481 | "eglQuerySurface", |
| 482 | "eglReleaseTexImage", |
| 483 | "eglReleaseThread", |
| 484 | "eglSurfaceAttrib", |
| 485 | "eglSwapBuffers", |
| 486 | "eglSwapInterval", |
| 487 | "eglTerminate", |
| 488 | "eglWaitClient", |
| 489 | "eglWaitGL", |
| 490 | "eglWaitNative", |
| 491 | ]) |
José Fonseca | c6b49ce | 2010-11-28 16:43:04 +0000 | [diff] [blame] | 492 | |
José Fonseca | 68ec412 | 2011-02-20 11:25:25 +0000 | [diff] [blame] | 493 | class GlDispatcher(Dispatcher): |
| 494 | |
José Fonseca | 8130193 | 2012-11-11 00:10:20 +0000 | [diff] [blame] | 495 | def isFunctionPublic(self, module, function): |
José Fonseca | 3bcb33c | 2011-05-27 20:14:31 +0100 | [diff] [blame] | 496 | return function.name in public_symbols or function.name.startswith('CGL') |
José Fonseca | c6b49ce | 2010-11-28 16:43:04 +0000 | [diff] [blame] | 497 | |
José Fonseca | 7989f93 | 2014-07-17 19:45:15 +0100 | [diff] [blame] | 498 | def getProcAddressName(self, module, function): |
| 499 | if self.isFunctionPublic(module, function): |
| 500 | return '_getPublicProcAddress' |
| 501 | else: |
| 502 | return '_getPrivateProcAddress' |
| 503 | |
Peter Lohrmann | 9d9eb81 | 2013-07-12 16:15:25 -0400 | [diff] [blame] | 504 | def failFunction(self, function): |
Jose Fonseca | d277370 | 2016-09-02 18:15:32 +0100 | [diff] [blame] | 505 | # Fallback to EXT_debug_label on MacOSX, some enums need to be translated. |
| 506 | if function.name in ('glObjectLabel', 'glObjectLabelKHR'): |
Piotr Podsiadły | 0b8b019 | 2019-01-03 20:39:55 +0100 | [diff] [blame] | 507 | print(r'#ifdef __APPLE__') |
| 508 | print(r' if (translateDebugLabelIdentifier(identifier)) {') |
| 509 | print(r' _glLabelObjectEXT(identifier, name, length < 0 ? 0 : length, length == 0 ? "" : label);') |
| 510 | print(r' return;') |
| 511 | print(r' }') |
| 512 | print(r'#endif') |
Jose Fonseca | d277370 | 2016-09-02 18:15:32 +0100 | [diff] [blame] | 513 | if function.name in ('glGetObjectLabel', 'glGetObjectLabelKHR'): |
Piotr Podsiadły | 0b8b019 | 2019-01-03 20:39:55 +0100 | [diff] [blame] | 514 | print(r'#ifdef __APPLE__') |
| 515 | print(r' if (translateDebugLabelIdentifier(identifier)) {') |
| 516 | print(r' _glGetObjectLabelEXT(identifier, name, bufSize, length, label);') |
| 517 | print(r' return;') |
| 518 | print(r' }') |
| 519 | print(r'#endif') |
Jose Fonseca | d277370 | 2016-09-02 18:15:32 +0100 | [diff] [blame] | 520 | |
José Fonseca | 71f5a35 | 2014-07-28 12:19:50 +0100 | [diff] [blame] | 521 | # We fake these when they are not available |
| 522 | if function.name in ( |
| 523 | # GL_KHR_debug |
| 524 | 'glDebugMessageControl', |
| 525 | 'glDebugMessageInsert', |
| 526 | 'glDebugMessageCallback', |
| 527 | 'glPushDebugGroup', |
| 528 | 'glPopDebugGroup', |
| 529 | 'glObjectLabel', |
| 530 | 'glObjectPtrLabel', |
Jose Fonseca | e01aa3b | 2015-06-27 11:07:05 +0100 | [diff] [blame] | 531 | # GL_KHR_debug (OpenGL ES) |
| 532 | 'glDebugMessageControlKHR', |
| 533 | 'glDebugMessageInsertKHR', |
| 534 | 'glDebugMessageCallbackKHR', |
| 535 | 'glPushDebugGroupKHR', |
| 536 | 'glPopDebugGroupKHR', |
| 537 | 'glObjectLabelKHR', |
| 538 | 'glObjectPtrLabelKHR', |
José Fonseca | 71f5a35 | 2014-07-28 12:19:50 +0100 | [diff] [blame] | 539 | # GL_ARB_debug_output |
| 540 | 'glDebugMessageControlARB', |
| 541 | 'glDebugMessageInsertARB', |
| 542 | 'glDebugMessageCallbackARB', |
| 543 | # GL_AMD_debug_output |
| 544 | 'glDebugMessageEnableAMD', |
| 545 | 'glDebugMessageInsertAMD', |
| 546 | 'glDebugMessageCallbackAMD', |
| 547 | # GL_EXT_debug_label |
| 548 | 'glLabelObjectEXT', |
| 549 | # GL_EXT_debug_marker |
| 550 | 'glInsertEventMarkerEXT', |
| 551 | 'glPushGroupMarkerEXT', |
| 552 | 'glPopGroupMarkerEXT', |
| 553 | ): |
| 554 | return |
Jose Fonseca | e01aa3b | 2015-06-27 11:07:05 +0100 | [diff] [blame] | 555 | if function.name.startswith('glGetObjectLabel'): |
Piotr Podsiadły | 0b8b019 | 2019-01-03 20:39:55 +0100 | [diff] [blame] | 556 | print(r' if (length != 0) *length = 0;') |
| 557 | print(r' if (label != 0 && bufSize > 0) *label = 0;') |
Peter Lohrmann | 9d9eb81 | 2013-07-12 16:15:25 -0400 | [diff] [blame] | 558 | return |
Jose Fonseca | e01aa3b | 2015-06-27 11:07:05 +0100 | [diff] [blame] | 559 | if function.name == 'glGetDebugMessageLogAMD': |
Piotr Podsiadły | 0b8b019 | 2019-01-03 20:39:55 +0100 | [diff] [blame] | 560 | print(r' if (categories != 0) *categories = 0;') |
| 561 | print(r' if (ids != 0) *ids = 0;') |
| 562 | print(r' if (severities != 0) *severities = 0;') |
| 563 | print(r' if (lengths != 0) *lengths = 0;') |
| 564 | print(r' if (message != 0 && bufsize > 0) *message = 0;') |
| 565 | print(r' return 0;') |
Jose Fonseca | e01aa3b | 2015-06-27 11:07:05 +0100 | [diff] [blame] | 566 | return |
| 567 | if function.name.startswith('glGetDebugMessageLog'): |
Piotr Podsiadły | 0b8b019 | 2019-01-03 20:39:55 +0100 | [diff] [blame] | 568 | print(r' if (sources != 0) *sources = 0;') |
| 569 | print(r' if (types != 0) *types = 0;') |
| 570 | print(r' if (ids != 0) *ids = 0;') |
| 571 | print(r' if (severities != 0) *severities = 0;') |
| 572 | print(r' if (lengths != 0) *lengths = 0;') |
| 573 | print(r' if (messageLog != 0 && bufsize > 0) *messageLog = 0;') |
| 574 | print(r' return 0;') |
Peter Lohrmann | 9d9eb81 | 2013-07-12 16:15:25 -0400 | [diff] [blame] | 575 | return |
Peter Lohrmann | 9d9eb81 | 2013-07-12 16:15:25 -0400 | [diff] [blame] | 576 | |
| 577 | Dispatcher.failFunction(self, function) |
| 578 | |
José Fonseca | c6b49ce | 2010-11-28 16:43:04 +0000 | [diff] [blame] | 579 | |
| 580 | if __name__ == '__main__': |
José Fonseca | e91f5bc | 2014-07-17 20:42:35 +0100 | [diff] [blame] | 581 | decl, impl = sys.argv[1:] |
| 582 | |
| 583 | sys.stdout = open(decl, 'wt') |
Piotr Podsiadły | 0b8b019 | 2019-01-03 20:39:55 +0100 | [diff] [blame] | 584 | print() |
| 585 | print('#pragma once') |
| 586 | print() |
| 587 | print('#include "glimports.hpp"') |
| 588 | print() |
| 589 | print('#if defined(_WIN32)') |
| 590 | print('extern HMODULE _libGlHandle;') |
| 591 | print('#else') |
| 592 | print('extern void * _libGlHandle;') |
| 593 | print('#endif') |
| 594 | print() |
| 595 | print('void * _getPublicProcAddress(const char *procName);') |
| 596 | print('void * _getPrivateProcAddress(const char *procName);') |
| 597 | print() |
José Fonseca | e91f5bc | 2014-07-17 20:42:35 +0100 | [diff] [blame] | 598 | dispatcher = GlDispatcher() |
Piotr Podsiadły | 0b8b019 | 2019-01-03 20:39:55 +0100 | [diff] [blame] | 599 | print() |
José Fonseca | e91f5bc | 2014-07-17 20:42:35 +0100 | [diff] [blame] | 600 | dispatcher.dispatchModuleDecl(eglapi) |
Piotr Podsiadły | 0b8b019 | 2019-01-03 20:39:55 +0100 | [diff] [blame] | 601 | print() |
| 602 | print('#if defined(_WIN32)') |
| 603 | print() |
José Fonseca | e91f5bc | 2014-07-17 20:42:35 +0100 | [diff] [blame] | 604 | dispatcher.dispatchModuleDecl(wglapi) |
Piotr Podsiadły | 0b8b019 | 2019-01-03 20:39:55 +0100 | [diff] [blame] | 605 | print() |
| 606 | print('#elif defined(__APPLE__)') |
| 607 | print() |
José Fonseca | e91f5bc | 2014-07-17 20:42:35 +0100 | [diff] [blame] | 608 | dispatcher.dispatchModuleDecl(cglapi) |
Piotr Podsiadły | 0b8b019 | 2019-01-03 20:39:55 +0100 | [diff] [blame] | 609 | print() |
| 610 | print('#elif defined(HAVE_X11)') |
| 611 | print() |
José Fonseca | e91f5bc | 2014-07-17 20:42:35 +0100 | [diff] [blame] | 612 | dispatcher.dispatchModuleDecl(glxapi) |
Piotr Podsiadły | 0b8b019 | 2019-01-03 20:39:55 +0100 | [diff] [blame] | 613 | print() |
| 614 | print('#endif') |
| 615 | print() |
José Fonseca | e91f5bc | 2014-07-17 20:42:35 +0100 | [diff] [blame] | 616 | dispatcher.dispatchModuleDecl(glapi) |
Piotr Podsiadły | 0b8b019 | 2019-01-03 20:39:55 +0100 | [diff] [blame] | 617 | print() |
José Fonseca | e91f5bc | 2014-07-17 20:42:35 +0100 | [diff] [blame] | 618 | |
| 619 | sys.stdout = open(impl, 'wt') |
Piotr Podsiadły | 0b8b019 | 2019-01-03 20:39:55 +0100 | [diff] [blame] | 620 | print() |
| 621 | print('#include "glproc.hpp"') |
| 622 | print('#include "os.hpp"') |
| 623 | print() |
José Fonseca | 68ec412 | 2011-02-20 11:25:25 +0000 | [diff] [blame] | 624 | dispatcher = GlDispatcher() |
Piotr Podsiadły | 0b8b019 | 2019-01-03 20:39:55 +0100 | [diff] [blame] | 625 | print() |
José Fonseca | e91f5bc | 2014-07-17 20:42:35 +0100 | [diff] [blame] | 626 | dispatcher.dispatchModuleImpl(eglapi) |
Piotr Podsiadły | 0b8b019 | 2019-01-03 20:39:55 +0100 | [diff] [blame] | 627 | print() |
| 628 | print('#if defined(_WIN32)') |
| 629 | print() |
José Fonseca | e91f5bc | 2014-07-17 20:42:35 +0100 | [diff] [blame] | 630 | dispatcher.dispatchModuleImpl(wglapi) |
Piotr Podsiadły | 0b8b019 | 2019-01-03 20:39:55 +0100 | [diff] [blame] | 631 | print() |
| 632 | print('#elif defined(__APPLE__)') |
| 633 | print() |
| 634 | print('static inline bool') |
| 635 | print('translateDebugLabelIdentifier(GLenum & identifier)') |
| 636 | print('{') |
| 637 | print(' switch (identifier) {') |
| 638 | print(' case GL_TEXTURE:') |
| 639 | print(' case GL_FRAMEBUFFER:') |
| 640 | print(' case GL_RENDERBUFFER:') |
| 641 | print(' case GL_SAMPLER:') |
| 642 | print(' case GL_TRANSFORM_FEEDBACK:') |
| 643 | print(' return true;') |
| 644 | print(' case GL_BUFFER:') |
| 645 | print(' identifier = GL_BUFFER_OBJECT_EXT;') |
| 646 | print(' return true;') |
| 647 | print(' case GL_SHADER:') |
| 648 | print(' identifier = GL_SHADER_OBJECT_EXT;') |
| 649 | print(' return true;') |
| 650 | print(' case GL_PROGRAM:') |
| 651 | print(' identifier = GL_PROGRAM_OBJECT_EXT;') |
| 652 | print(' return true;') |
| 653 | print(' case GL_VERTEX_ARRAY:') |
| 654 | print(' identifier = GL_VERTEX_ARRAY_OBJECT_EXT;') |
| 655 | print(' return true;') |
| 656 | print(' case GL_QUERY:') |
| 657 | print(' identifier = GL_QUERY_OBJECT_EXT;') |
| 658 | print(' return true;') |
| 659 | print(' case GL_PROGRAM_PIPELINE:') |
| 660 | print(' identifier = GL_PROGRAM_PIPELINE_OBJECT_EXT;') |
| 661 | print(' return true;') |
| 662 | print(' default:') |
| 663 | print(' return false;') |
| 664 | print(' }') |
| 665 | print('}') |
| 666 | print() |
José Fonseca | e91f5bc | 2014-07-17 20:42:35 +0100 | [diff] [blame] | 667 | dispatcher.dispatchModuleImpl(cglapi) |
Piotr Podsiadły | 0b8b019 | 2019-01-03 20:39:55 +0100 | [diff] [blame] | 668 | print() |
| 669 | print('#elif defined(HAVE_X11)') |
| 670 | print() |
José Fonseca | e91f5bc | 2014-07-17 20:42:35 +0100 | [diff] [blame] | 671 | dispatcher.dispatchModuleImpl(glxapi) |
Piotr Podsiadły | 0b8b019 | 2019-01-03 20:39:55 +0100 | [diff] [blame] | 672 | print() |
| 673 | print('#endif') |
| 674 | print() |
José Fonseca | e91f5bc | 2014-07-17 20:42:35 +0100 | [diff] [blame] | 675 | dispatcher.dispatchModuleImpl(glapi) |
Piotr Podsiadły | 0b8b019 | 2019-01-03 20:39:55 +0100 | [diff] [blame] | 676 | print() |