├── .gitattributes ├── .gitignore ├── AUTHORS.mkd ├── LICENSE.mkd ├── Makefile ├── README.mkd ├── amd └── amd.go ├── arb └── arb.go ├── ati └── ati.go ├── download.go ├── enumreader.go ├── enumreader_test.go ├── examples └── gopher │ ├── README.md │ ├── gopher.go │ ├── gopher.png │ ├── gopher.png.go │ ├── gopher_linux.png │ └── gopher_windows.png ├── ext └── ext.go ├── funcreader.go ├── funcreader_test.go ├── generator.go ├── gl21 └── gl21.go ├── gl32 └── gl32.go ├── gl33 └── gl33.go ├── gl42 └── gl42.go ├── gl43 └── gl43.go ├── glx └── glx.go ├── group.go ├── group_test.go ├── main.go ├── nv └── nv.go ├── structs.go ├── structs_test.go ├── tmreader.go ├── tmreader_test.go ├── util.go ├── util_test.go └── wgl └── wgl.go /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | GoGL 2 | *.[568] 3 | *.out 4 | _testmain.go 5 | _obj 6 | _test 7 | alfonse_specs/ 8 | khronos_specs/ 9 | -------------------------------------------------------------------------------- /AUTHORS.mkd: -------------------------------------------------------------------------------- 1 | Authors 2 | ======= 3 | 4 | This is the official list of *GoGL* authors for copyright purposes. 5 | 6 | Names should be added to this file as: 7 | 8 | * *Name or Organization < email address >* 9 | 10 | The email address is not required for organizations. 11 | 12 | Please keep the list sorted. 13 | 14 | *** 15 | 16 | * Christoph Schunk <> 17 | * J. Bates <> 18 | 19 | -------------------------------------------------------------------------------- /LICENSE.mkd: -------------------------------------------------------------------------------- 1 | License 2 | ======= 3 | 4 | Copyright (c) 2011, The *GoGL* authors. All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | * Neither the name of the *GoGL* authors nor the 15 | names of its contributors may be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY 22 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | bindings: 2 | go build 3 | ./gogl dlspec 4 | ./gogl gen 5 | make install_bindings 6 | 7 | install_bindings: 8 | go install ./gl21 9 | # go install ./gl30 10 | go install ./gl31 11 | # go install ./gl31c 12 | # go install ./gl32 13 | # go install ./gl32c 14 | # go install ./gl32 15 | # go install ./gl32c 16 | go install ./gl33 17 | # go install ./gl33c 18 | # go install ./gl40 19 | # go install ./gl41c 20 | go install ./gl42 21 | # go install ./gl42c 22 | go install ./gl43 23 | go install ./arb 24 | go install ./ext 25 | go install ./ati 26 | go install ./amd 27 | go install ./nv 28 | # go install ./glx 29 | # go install ./wgl 30 | -------------------------------------------------------------------------------- /README.mkd: -------------------------------------------------------------------------------- 1 | GoGL 2 | ==== 3 | 4 | GoGL is an OpenGL binding generator for Go. 5 | No external dependencies like GLEW are needed. 6 | 7 | Install the OpenGL bindings 8 | --------------------------- 9 | 10 | For example, OpenGL 2.1 bindings can be installed using the go command: 11 | 12 | go get github.com/chsc/gogl/gl21 13 | 14 | Documentation 15 | ------------- 16 | 17 | Khronos documentation: 18 | 19 | * [OpenGL 1.X - 2.X](http://www.opengl.org/sdk/docs/man) 20 | * [OpenGL 3.X](http://www.opengl.org/sdk/docs/man3) 21 | * [OpenGL 4.X](http://www.opengl.org/sdk/docs/man4) 22 | 23 | Package documentation: 24 | 25 | * [OpenGL 2.1](http://godoc.org/github.com/chsc/gogl/gl21) 26 | * [OpenGL 3.3](http://godoc.org/github.com/chsc/gogl/gl33) 27 | * [OpenGL 4.2](http://godoc.org/github.com/chsc/gogl/gl42) 28 | * [OpenGL 4.3](http://godoc.org/github.com/chsc/gogl/gl43) 29 | 30 | * [AMD](http://godoc.org/github.com/chsc/gogl/amd), 31 | [ATI](http://godoc.org/github.com/chsc/gogl/ati), 32 | [ARB](http://godoc.org/github.com/chsc/gogl/arb), 33 | [EXT](http://godoc.org/github.com/chsc/gogl/ext), 34 | [NV](http://godoc.org/github.com/chsc/gogl/nv) 35 | 36 | GoGL specific docs and usage examples: 37 | 38 | * [Wiki](https://github.com/chsc/gogl/wiki) 39 | 40 | Examples 41 | -------- 42 | 43 | To test the installed bindings, build and install the "spinning gopher" example: 44 | 45 | go get github.com/chsc/gogl/examples/gopher 46 | 47 | and run it from your command line. 48 | 49 | Manually build & install the binding generator 50 | ---------------------------------------------- 51 | 52 | If you want to create your own bindings: 53 | 54 | clone the repository: 55 | 56 | git clone http://github.com/chsc/gogl.git 57 | 58 | or use the go command: 59 | 60 | go get github.com/chsc/gogl 61 | 62 | To generate the bindings (the fast way), simply type: 63 | 64 | make bindings 65 | 66 | This will download, build and install the latest OpenGL bindings. 67 | 68 | Use 69 | 70 | gogl -help 71 | 72 | for more information about GoGL's command line arguments. 73 | 74 | Corrected spec files 75 | -------------------- 76 | 77 | The original spec files from Khronos have errors in them. 78 | Jason McKesson (alfonse) maintains corrected spec files in his bitbucket repository. 79 | You can find them here: [GL XML Specs](https://bitbucket.org/alfonse/gl-xml-specs). 80 | 81 | TODO 82 | ---- 83 | 84 | * Better spec parser 85 | * ... 86 | -------------------------------------------------------------------------------- /amd/amd.go: -------------------------------------------------------------------------------- 1 | // Automatically generated OpenGL binding. 2 | // 3 | // Categories in this package: 4 | // 5 | // AMD_debug_output: https://www.opengl.org/registry/specs/AMD/debug_output.txt 6 | // 7 | // AMD_draw_buffers_blend: https://www.opengl.org/registry/specs/AMD/draw_buffers_blend.txt 8 | // 9 | // AMD_multi_draw_indirect: https://www.opengl.org/registry/specs/AMD/multi_draw_indirect.txt 10 | // 11 | // AMD_name_gen_delete: https://www.opengl.org/registry/specs/AMD/name_gen_delete.txt 12 | // 13 | // AMD_performance_monitor: https://www.opengl.org/registry/specs/AMD/performance_monitor.txt 14 | // 15 | // AMD_sample_positions: https://www.opengl.org/registry/specs/AMD/sample_positions.txt 16 | // 17 | // AMD_sparse_texture: https://www.opengl.org/registry/specs/AMD/sparse_texture.txt 18 | // 19 | // AMD_stencil_operation_extended: https://www.opengl.org/registry/specs/AMD/stencil_operation_extended.txt 20 | // 21 | // AMD_vertex_shader_tessellator: https://www.opengl.org/registry/specs/AMD/vertex_shader_tessellator.txt 22 | // 23 | package amd 24 | 25 | // #cgo darwin LDFLAGS: -framework OpenGL 26 | // #cgo linux LDFLAGS: -lGL 27 | // #cgo windows LDFLAGS: -lopengl32 28 | // 29 | // #include 30 | // #if defined(__APPLE__) 31 | // #include 32 | // #elif defined(_WIN32) 33 | // #define WIN32_LEAN_AND_MEAN 1 34 | // #include 35 | // #else 36 | // #include 37 | // #include 38 | // #endif 39 | // 40 | // #ifndef APIENTRY 41 | // #define APIENTRY 42 | // #endif 43 | // #ifndef APIENTRYP 44 | // #define APIENTRYP APIENTRY * 45 | // #endif 46 | // #ifndef GLAPI 47 | // #define GLAPI extern 48 | // #endif 49 | // 50 | // typedef unsigned int GLenum; 51 | // typedef unsigned char GLboolean; 52 | // typedef unsigned int GLbitfield; 53 | // typedef signed char GLbyte; 54 | // typedef short GLshort; 55 | // typedef int GLint; 56 | // typedef int GLsizei; 57 | // typedef unsigned char GLubyte; 58 | // typedef unsigned short GLushort; 59 | // typedef unsigned int GLuint; 60 | // typedef unsigned short GLhalf; 61 | // typedef float GLfloat; 62 | // typedef float GLclampf; 63 | // typedef double GLdouble; 64 | // typedef double GLclampd; 65 | // typedef void GLvoid; 66 | // 67 | // #include 68 | // #ifndef GL_VERSION_2_0 69 | // /* GL type for program/shader text */ 70 | // typedef char GLchar; 71 | // #endif 72 | // 73 | // #ifndef GL_VERSION_1_5 74 | // /* GL types for handling large vertex buffer objects */ 75 | // typedef ptrdiff_t GLintptr; 76 | // typedef ptrdiff_t GLsizeiptr; 77 | // #endif 78 | // 79 | // #ifndef GL_ARB_vertex_buffer_object 80 | // /* GL types for handling large vertex buffer objects */ 81 | // typedef ptrdiff_t GLintptrARB; 82 | // typedef ptrdiff_t GLsizeiptrARB; 83 | // #endif 84 | // 85 | // #ifndef GL_ARB_shader_objects 86 | // /* GL types for program/shader text and shader object handles */ 87 | // typedef char GLcharARB; 88 | // typedef unsigned int GLhandleARB; 89 | // #endif 90 | // 91 | // /* GL type for "half" precision (s10e5) float data in host memory */ 92 | // #ifndef GL_ARB_half_float_pixel 93 | // typedef unsigned short GLhalfARB; 94 | // #endif 95 | // 96 | // #ifndef GL_NV_half_float 97 | // typedef unsigned short GLhalfNV; 98 | // #endif 99 | // 100 | // #ifndef GLEXT_64_TYPES_DEFINED 101 | // /* This code block is duplicated in glxext.h, so must be protected */ 102 | // #define GLEXT_64_TYPES_DEFINED 103 | // /* Define int32_t, int64_t, and uint64_t types for UST/MSC */ 104 | // /* (as used in the GL_EXT_timer_query extension). */ 105 | // #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L 106 | // #include 107 | // #elif defined(__sun__) || defined(__digital__) 108 | // #include 109 | // #if defined(__STDC__) 110 | // #if defined(__arch64__) || defined(_LP64) 111 | // typedef long int int64_t; 112 | // typedef unsigned long int uint64_t; 113 | // #else 114 | // typedef long long int int64_t; 115 | // typedef unsigned long long int uint64_t; 116 | // #endif /* __arch64__ */ 117 | // #endif /* __STDC__ */ 118 | // #elif defined( __VMS ) || defined(__sgi) 119 | // #include 120 | // #elif defined(__SCO__) || defined(__USLC__) 121 | // #include 122 | // #elif defined(__UNIXOS2__) || defined(__SOL64__) 123 | // typedef long int int32_t; 124 | // typedef long long int int64_t; 125 | // typedef unsigned long long int uint64_t; 126 | // #elif defined(_WIN32) && defined(__GNUC__) 127 | // #include 128 | // #elif defined(_WIN32) 129 | // typedef __int32 int32_t; 130 | // typedef __int64 int64_t; 131 | // typedef unsigned __int64 uint64_t; 132 | // #else 133 | // /* Fallback if nothing above works */ 134 | // #include 135 | // #endif 136 | // #endif 137 | // 138 | // #ifndef GL_EXT_timer_query 139 | // typedef int64_t GLint64EXT; 140 | // typedef uint64_t GLuint64EXT; 141 | // #endif 142 | // 143 | // #ifndef GL_ARB_sync 144 | // typedef int64_t GLint64; 145 | // typedef uint64_t GLuint64; 146 | // typedef struct __GLsync *GLsync; 147 | // #endif 148 | // 149 | // #ifndef GL_ARB_cl_event 150 | // /* These incomplete types let us declare types compatible with OpenCL's cl_context and cl_event */ 151 | // struct _cl_context; 152 | // struct _cl_event; 153 | // #endif 154 | // 155 | // #ifndef GL_ARB_debug_output 156 | // typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); 157 | // #endif 158 | // 159 | // #ifndef GL_AMD_debug_output 160 | // typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); 161 | // #endif 162 | // 163 | // #ifndef GL_KHR_debug 164 | // typedef void (APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); 165 | // #endif 166 | // 167 | // #ifndef GL_NV_vdpau_interop 168 | // typedef GLintptr GLvdpauSurfaceNV; 169 | // #endif 170 | // 171 | // #ifdef _WIN32 172 | // static HMODULE opengl32 = NULL; 173 | // #endif 174 | // 175 | // static void* goglGetProcAddress(const char* name) { 176 | // #ifdef __APPLE__ 177 | // return dlsym(RTLD_DEFAULT, name); 178 | // #elif _WIN32 179 | // void* pf = wglGetProcAddress((LPCSTR)name); 180 | // if(pf) { 181 | // return pf; 182 | // } 183 | // if(opengl32 == NULL) { 184 | // opengl32 = LoadLibraryA("opengl32.dll"); 185 | // } 186 | // return GetProcAddress(opengl32, (LPCSTR)name); 187 | // #else 188 | // return glXGetProcAddress((const GLubyte*)name); 189 | // #endif 190 | // } 191 | // 192 | // // AMD_debug_output 193 | // void (APIENTRYP ptrglDebugMessageEnableAMD)(GLenum category, GLenum severity, GLsizei count, GLuint* ids, GLboolean enabled); 194 | // void (APIENTRYP ptrglDebugMessageInsertAMD)(GLenum category, GLenum severity, GLuint id, GLsizei length, GLchar* buf); 195 | // void (APIENTRYP ptrglDebugMessageCallbackAMD)(GLDEBUGPROCAMD callback, GLvoid* userParam); 196 | // GLuint (APIENTRYP ptrglGetDebugMessageLogAMD)(GLuint count, GLsizei bufsize, GLenum* categories, GLuint* severities, GLuint* ids, GLsizei* lengths, GLchar* message); 197 | // // AMD_draw_buffers_blend 198 | // void (APIENTRYP ptrglBlendFuncIndexedAMD)(GLuint buf, GLenum src, GLenum dst); 199 | // void (APIENTRYP ptrglBlendFuncSeparateIndexedAMD)(GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); 200 | // void (APIENTRYP ptrglBlendEquationIndexedAMD)(GLuint buf, GLenum mode); 201 | // void (APIENTRYP ptrglBlendEquationSeparateIndexedAMD)(GLuint buf, GLenum modeRGB, GLenum modeAlpha); 202 | // // AMD_multi_draw_indirect 203 | // void (APIENTRYP ptrglMultiDrawArraysIndirectAMD)(GLenum mode, GLvoid* indirect, GLsizei primcount, GLsizei stride); 204 | // void (APIENTRYP ptrglMultiDrawElementsIndirectAMD)(GLenum mode, GLenum type, GLvoid* indirect, GLsizei primcount, GLsizei stride); 205 | // // AMD_name_gen_delete 206 | // void (APIENTRYP ptrglGenNamesAMD)(GLenum identifier, GLuint num, GLuint* names); 207 | // void (APIENTRYP ptrglDeleteNamesAMD)(GLenum identifier, GLuint num, GLuint* names); 208 | // GLboolean (APIENTRYP ptrglIsNameAMD)(GLenum identifier, GLuint name); 209 | // // AMD_performance_monitor 210 | // void (APIENTRYP ptrglGetPerfMonitorGroupsAMD)(GLint* numGroups, GLsizei groupsSize, GLuint* groups); 211 | // void (APIENTRYP ptrglGetPerfMonitorCountersAMD)(GLuint group, GLint* numCounters, GLint* maxActiveCounters, GLsizei counterSize, GLuint* counters); 212 | // void (APIENTRYP ptrglGetPerfMonitorGroupStringAMD)(GLuint group, GLsizei bufSize, GLsizei* length, GLchar* groupString); 213 | // void (APIENTRYP ptrglGetPerfMonitorCounterStringAMD)(GLuint group, GLuint counter, GLsizei bufSize, GLsizei* length, GLchar* counterString); 214 | // void (APIENTRYP ptrglGetPerfMonitorCounterInfoAMD)(GLuint group, GLuint counter, GLenum pname, GLvoid* data); 215 | // void (APIENTRYP ptrglGenPerfMonitorsAMD)(GLsizei n, GLuint* monitors); 216 | // void (APIENTRYP ptrglDeletePerfMonitorsAMD)(GLsizei n, GLuint* monitors); 217 | // void (APIENTRYP ptrglSelectPerfMonitorCountersAMD)(GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint* counterList); 218 | // void (APIENTRYP ptrglBeginPerfMonitorAMD)(GLuint monitor); 219 | // void (APIENTRYP ptrglEndPerfMonitorAMD)(GLuint monitor); 220 | // void (APIENTRYP ptrglGetPerfMonitorCounterDataAMD)(GLuint monitor, GLenum pname, GLsizei dataSize, GLuint* data, GLint* bytesWritten); 221 | // // AMD_sample_positions 222 | // void (APIENTRYP ptrglSetMultisamplefvAMD)(GLenum pname, GLuint index, GLfloat* val); 223 | // // AMD_sparse_texture 224 | // void (APIENTRYP ptrglTexStorageSparseAMD)(GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); 225 | // void (APIENTRYP ptrglTextureStorageSparseAMD)(GLuint texture, GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); 226 | // // AMD_stencil_operation_extended 227 | // void (APIENTRYP ptrglStencilOpValueAMD)(GLenum face, GLuint value); 228 | // // AMD_vertex_shader_tessellator 229 | // void (APIENTRYP ptrglTessellationFactorAMD)(GLfloat factor); 230 | // void (APIENTRYP ptrglTessellationModeAMD)(GLenum mode); 231 | // 232 | // // AMD_debug_output 233 | // void goglDebugMessageEnableAMD(GLenum category, GLenum severity, GLsizei count, GLuint* ids, GLboolean enabled) { 234 | // (*ptrglDebugMessageEnableAMD)(category, severity, count, ids, enabled); 235 | // } 236 | // void goglDebugMessageInsertAMD(GLenum category, GLenum severity, GLuint id, GLsizei length, GLchar* buf) { 237 | // (*ptrglDebugMessageInsertAMD)(category, severity, id, length, buf); 238 | // } 239 | // void goglDebugMessageCallbackAMD(GLDEBUGPROCAMD callback, GLvoid* userParam) { 240 | // (*ptrglDebugMessageCallbackAMD)(callback, userParam); 241 | // } 242 | // GLuint goglGetDebugMessageLogAMD(GLuint count, GLsizei bufsize, GLenum* categories, GLuint* severities, GLuint* ids, GLsizei* lengths, GLchar* message) { 243 | // return (*ptrglGetDebugMessageLogAMD)(count, bufsize, categories, severities, ids, lengths, message); 244 | // } 245 | // // AMD_draw_buffers_blend 246 | // void goglBlendFuncIndexedAMD(GLuint buf, GLenum src, GLenum dst) { 247 | // (*ptrglBlendFuncIndexedAMD)(buf, src, dst); 248 | // } 249 | // void goglBlendFuncSeparateIndexedAMD(GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) { 250 | // (*ptrglBlendFuncSeparateIndexedAMD)(buf, srcRGB, dstRGB, srcAlpha, dstAlpha); 251 | // } 252 | // void goglBlendEquationIndexedAMD(GLuint buf, GLenum mode) { 253 | // (*ptrglBlendEquationIndexedAMD)(buf, mode); 254 | // } 255 | // void goglBlendEquationSeparateIndexedAMD(GLuint buf, GLenum modeRGB, GLenum modeAlpha) { 256 | // (*ptrglBlendEquationSeparateIndexedAMD)(buf, modeRGB, modeAlpha); 257 | // } 258 | // // AMD_multi_draw_indirect 259 | // void goglMultiDrawArraysIndirectAMD(GLenum mode, GLvoid* indirect, GLsizei primcount, GLsizei stride) { 260 | // (*ptrglMultiDrawArraysIndirectAMD)(mode, indirect, primcount, stride); 261 | // } 262 | // void goglMultiDrawElementsIndirectAMD(GLenum mode, GLenum type_, GLvoid* indirect, GLsizei primcount, GLsizei stride) { 263 | // (*ptrglMultiDrawElementsIndirectAMD)(mode, type_, indirect, primcount, stride); 264 | // } 265 | // // AMD_name_gen_delete 266 | // void goglGenNamesAMD(GLenum identifier, GLuint num, GLuint* names) { 267 | // (*ptrglGenNamesAMD)(identifier, num, names); 268 | // } 269 | // void goglDeleteNamesAMD(GLenum identifier, GLuint num, GLuint* names) { 270 | // (*ptrglDeleteNamesAMD)(identifier, num, names); 271 | // } 272 | // GLboolean goglIsNameAMD(GLenum identifier, GLuint name) { 273 | // return (*ptrglIsNameAMD)(identifier, name); 274 | // } 275 | // // AMD_performance_monitor 276 | // void goglGetPerfMonitorGroupsAMD(GLint* numGroups, GLsizei groupsSize, GLuint* groups) { 277 | // (*ptrglGetPerfMonitorGroupsAMD)(numGroups, groupsSize, groups); 278 | // } 279 | // void goglGetPerfMonitorCountersAMD(GLuint group, GLint* numCounters, GLint* maxActiveCounters, GLsizei counterSize, GLuint* counters) { 280 | // (*ptrglGetPerfMonitorCountersAMD)(group, numCounters, maxActiveCounters, counterSize, counters); 281 | // } 282 | // void goglGetPerfMonitorGroupStringAMD(GLuint group, GLsizei bufSize, GLsizei* length, GLchar* groupString) { 283 | // (*ptrglGetPerfMonitorGroupStringAMD)(group, bufSize, length, groupString); 284 | // } 285 | // void goglGetPerfMonitorCounterStringAMD(GLuint group, GLuint counter, GLsizei bufSize, GLsizei* length, GLchar* counterString) { 286 | // (*ptrglGetPerfMonitorCounterStringAMD)(group, counter, bufSize, length, counterString); 287 | // } 288 | // void goglGetPerfMonitorCounterInfoAMD(GLuint group, GLuint counter, GLenum pname, GLvoid* data) { 289 | // (*ptrglGetPerfMonitorCounterInfoAMD)(group, counter, pname, data); 290 | // } 291 | // void goglGenPerfMonitorsAMD(GLsizei n, GLuint* monitors) { 292 | // (*ptrglGenPerfMonitorsAMD)(n, monitors); 293 | // } 294 | // void goglDeletePerfMonitorsAMD(GLsizei n, GLuint* monitors) { 295 | // (*ptrglDeletePerfMonitorsAMD)(n, monitors); 296 | // } 297 | // void goglSelectPerfMonitorCountersAMD(GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint* counterList) { 298 | // (*ptrglSelectPerfMonitorCountersAMD)(monitor, enable, group, numCounters, counterList); 299 | // } 300 | // void goglBeginPerfMonitorAMD(GLuint monitor) { 301 | // (*ptrglBeginPerfMonitorAMD)(monitor); 302 | // } 303 | // void goglEndPerfMonitorAMD(GLuint monitor) { 304 | // (*ptrglEndPerfMonitorAMD)(monitor); 305 | // } 306 | // void goglGetPerfMonitorCounterDataAMD(GLuint monitor, GLenum pname, GLsizei dataSize, GLuint* data, GLint* bytesWritten) { 307 | // (*ptrglGetPerfMonitorCounterDataAMD)(monitor, pname, dataSize, data, bytesWritten); 308 | // } 309 | // // AMD_sample_positions 310 | // void goglSetMultisamplefvAMD(GLenum pname, GLuint index, GLfloat* val) { 311 | // (*ptrglSetMultisamplefvAMD)(pname, index, val); 312 | // } 313 | // // AMD_sparse_texture 314 | // void goglTexStorageSparseAMD(GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags) { 315 | // (*ptrglTexStorageSparseAMD)(target, internalFormat, width, height, depth, layers, flags); 316 | // } 317 | // void goglTextureStorageSparseAMD(GLuint texture, GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags) { 318 | // (*ptrglTextureStorageSparseAMD)(texture, target, internalFormat, width, height, depth, layers, flags); 319 | // } 320 | // // AMD_stencil_operation_extended 321 | // void goglStencilOpValueAMD(GLenum face, GLuint value) { 322 | // (*ptrglStencilOpValueAMD)(face, value); 323 | // } 324 | // // AMD_vertex_shader_tessellator 325 | // void goglTessellationFactorAMD(GLfloat factor) { 326 | // (*ptrglTessellationFactorAMD)(factor); 327 | // } 328 | // void goglTessellationModeAMD(GLenum mode) { 329 | // (*ptrglTessellationModeAMD)(mode); 330 | // } 331 | // 332 | // int init_AMD_debug_output() { 333 | // ptrglDebugMessageEnableAMD = goglGetProcAddress("glDebugMessageEnableAMD"); 334 | // if(ptrglDebugMessageEnableAMD == NULL) return 1; 335 | // ptrglDebugMessageInsertAMD = goglGetProcAddress("glDebugMessageInsertAMD"); 336 | // if(ptrglDebugMessageInsertAMD == NULL) return 1; 337 | // ptrglDebugMessageCallbackAMD = goglGetProcAddress("glDebugMessageCallbackAMD"); 338 | // if(ptrglDebugMessageCallbackAMD == NULL) return 1; 339 | // ptrglGetDebugMessageLogAMD = goglGetProcAddress("glGetDebugMessageLogAMD"); 340 | // if(ptrglGetDebugMessageLogAMD == NULL) return 1; 341 | // return 0; 342 | // } 343 | // int init_AMD_draw_buffers_blend() { 344 | // ptrglBlendFuncIndexedAMD = goglGetProcAddress("glBlendFuncIndexedAMD"); 345 | // if(ptrglBlendFuncIndexedAMD == NULL) return 1; 346 | // ptrglBlendFuncSeparateIndexedAMD = goglGetProcAddress("glBlendFuncSeparateIndexedAMD"); 347 | // if(ptrglBlendFuncSeparateIndexedAMD == NULL) return 1; 348 | // ptrglBlendEquationIndexedAMD = goglGetProcAddress("glBlendEquationIndexedAMD"); 349 | // if(ptrglBlendEquationIndexedAMD == NULL) return 1; 350 | // ptrglBlendEquationSeparateIndexedAMD = goglGetProcAddress("glBlendEquationSeparateIndexedAMD"); 351 | // if(ptrglBlendEquationSeparateIndexedAMD == NULL) return 1; 352 | // return 0; 353 | // } 354 | // int init_AMD_multi_draw_indirect() { 355 | // ptrglMultiDrawArraysIndirectAMD = goglGetProcAddress("glMultiDrawArraysIndirectAMD"); 356 | // if(ptrglMultiDrawArraysIndirectAMD == NULL) return 1; 357 | // ptrglMultiDrawElementsIndirectAMD = goglGetProcAddress("glMultiDrawElementsIndirectAMD"); 358 | // if(ptrglMultiDrawElementsIndirectAMD == NULL) return 1; 359 | // return 0; 360 | // } 361 | // int init_AMD_name_gen_delete() { 362 | // ptrglGenNamesAMD = goglGetProcAddress("glGenNamesAMD"); 363 | // if(ptrglGenNamesAMD == NULL) return 1; 364 | // ptrglDeleteNamesAMD = goglGetProcAddress("glDeleteNamesAMD"); 365 | // if(ptrglDeleteNamesAMD == NULL) return 1; 366 | // ptrglIsNameAMD = goglGetProcAddress("glIsNameAMD"); 367 | // if(ptrglIsNameAMD == NULL) return 1; 368 | // return 0; 369 | // } 370 | // int init_AMD_performance_monitor() { 371 | // ptrglGetPerfMonitorGroupsAMD = goglGetProcAddress("glGetPerfMonitorGroupsAMD"); 372 | // if(ptrglGetPerfMonitorGroupsAMD == NULL) return 1; 373 | // ptrglGetPerfMonitorCountersAMD = goglGetProcAddress("glGetPerfMonitorCountersAMD"); 374 | // if(ptrglGetPerfMonitorCountersAMD == NULL) return 1; 375 | // ptrglGetPerfMonitorGroupStringAMD = goglGetProcAddress("glGetPerfMonitorGroupStringAMD"); 376 | // if(ptrglGetPerfMonitorGroupStringAMD == NULL) return 1; 377 | // ptrglGetPerfMonitorCounterStringAMD = goglGetProcAddress("glGetPerfMonitorCounterStringAMD"); 378 | // if(ptrglGetPerfMonitorCounterStringAMD == NULL) return 1; 379 | // ptrglGetPerfMonitorCounterInfoAMD = goglGetProcAddress("glGetPerfMonitorCounterInfoAMD"); 380 | // if(ptrglGetPerfMonitorCounterInfoAMD == NULL) return 1; 381 | // ptrglGenPerfMonitorsAMD = goglGetProcAddress("glGenPerfMonitorsAMD"); 382 | // if(ptrglGenPerfMonitorsAMD == NULL) return 1; 383 | // ptrglDeletePerfMonitorsAMD = goglGetProcAddress("glDeletePerfMonitorsAMD"); 384 | // if(ptrglDeletePerfMonitorsAMD == NULL) return 1; 385 | // ptrglSelectPerfMonitorCountersAMD = goglGetProcAddress("glSelectPerfMonitorCountersAMD"); 386 | // if(ptrglSelectPerfMonitorCountersAMD == NULL) return 1; 387 | // ptrglBeginPerfMonitorAMD = goglGetProcAddress("glBeginPerfMonitorAMD"); 388 | // if(ptrglBeginPerfMonitorAMD == NULL) return 1; 389 | // ptrglEndPerfMonitorAMD = goglGetProcAddress("glEndPerfMonitorAMD"); 390 | // if(ptrglEndPerfMonitorAMD == NULL) return 1; 391 | // ptrglGetPerfMonitorCounterDataAMD = goglGetProcAddress("glGetPerfMonitorCounterDataAMD"); 392 | // if(ptrglGetPerfMonitorCounterDataAMD == NULL) return 1; 393 | // return 0; 394 | // } 395 | // int init_AMD_sample_positions() { 396 | // ptrglSetMultisamplefvAMD = goglGetProcAddress("glSetMultisamplefvAMD"); 397 | // if(ptrglSetMultisamplefvAMD == NULL) return 1; 398 | // return 0; 399 | // } 400 | // int init_AMD_sparse_texture() { 401 | // ptrglTexStorageSparseAMD = goglGetProcAddress("glTexStorageSparseAMD"); 402 | // if(ptrglTexStorageSparseAMD == NULL) return 1; 403 | // ptrglTextureStorageSparseAMD = goglGetProcAddress("glTextureStorageSparseAMD"); 404 | // if(ptrglTextureStorageSparseAMD == NULL) return 1; 405 | // return 0; 406 | // } 407 | // int init_AMD_stencil_operation_extended() { 408 | // ptrglStencilOpValueAMD = goglGetProcAddress("glStencilOpValueAMD"); 409 | // if(ptrglStencilOpValueAMD == NULL) return 1; 410 | // return 0; 411 | // } 412 | // int init_AMD_vertex_shader_tessellator() { 413 | // ptrglTessellationFactorAMD = goglGetProcAddress("glTessellationFactorAMD"); 414 | // if(ptrglTessellationFactorAMD == NULL) return 1; 415 | // ptrglTessellationModeAMD = goglGetProcAddress("glTessellationModeAMD"); 416 | // if(ptrglTessellationModeAMD == NULL) return 1; 417 | // return 0; 418 | // } 419 | // 420 | import "C" 421 | import "unsafe" 422 | import "errors" 423 | 424 | type ( 425 | Enum C.GLenum 426 | Boolean C.GLboolean 427 | Bitfield C.GLbitfield 428 | Byte C.GLbyte 429 | Short C.GLshort 430 | Int C.GLint 431 | Sizei C.GLsizei 432 | Ubyte C.GLubyte 433 | Ushort C.GLushort 434 | Uint C.GLuint 435 | Half C.GLhalf 436 | Float C.GLfloat 437 | Clampf C.GLclampf 438 | Double C.GLdouble 439 | Clampd C.GLclampd 440 | Char C.GLchar 441 | Pointer unsafe.Pointer 442 | Sync C.GLsync 443 | Int64 C.GLint64 444 | Uint64 C.GLuint64 445 | Intptr C.GLintptr 446 | Sizeiptr C.GLsizeiptr 447 | ) 448 | 449 | // AMD_blend_minmax_factor 450 | const ( 451 | FACTOR_MAX_AMD = 0x901D 452 | FACTOR_MIN_AMD = 0x901C 453 | ) 454 | // AMD_conservative_depth 455 | const ( 456 | ) 457 | // AMD_debug_output 458 | const ( 459 | DEBUG_CATEGORY_API_ERROR_AMD = 0x9149 460 | DEBUG_CATEGORY_APPLICATION_AMD = 0x914F 461 | DEBUG_CATEGORY_DEPRECATION_AMD = 0x914B 462 | DEBUG_CATEGORY_OTHER_AMD = 0x9150 463 | DEBUG_CATEGORY_PERFORMANCE_AMD = 0x914D 464 | DEBUG_CATEGORY_SHADER_COMPILER_AMD = 0x914E 465 | DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD = 0x914C 466 | DEBUG_CATEGORY_WINDOW_SYSTEM_AMD = 0x914A 467 | DEBUG_LOGGED_MESSAGES_AMD = 0x9145 468 | DEBUG_SEVERITY_HIGH_AMD = 0x9146 469 | DEBUG_SEVERITY_LOW_AMD = 0x9148 470 | DEBUG_SEVERITY_MEDIUM_AMD = 0x9147 471 | MAX_DEBUG_LOGGED_MESSAGES_AMD = 0x9144 472 | MAX_DEBUG_MESSAGE_LENGTH_AMD = 0x9143 473 | ) 474 | // AMD_depth_clamp_separate 475 | const ( 476 | DEPTH_CLAMP_FAR_AMD = 0x901F 477 | DEPTH_CLAMP_NEAR_AMD = 0x901E 478 | ) 479 | // AMD_draw_buffers_blend 480 | const ( 481 | ) 482 | // AMD_multi_draw_indirect 483 | const ( 484 | ) 485 | // AMD_name_gen_delete 486 | const ( 487 | DATA_BUFFER_AMD = 0x9151 488 | PERFORMANCE_MONITOR_AMD = 0x9152 489 | QUERY_OBJECT_AMD = 0x9153 490 | SAMPLER_OBJECT_AMD = 0x9155 491 | VERTEX_ARRAY_OBJECT_AMD = 0x9154 492 | ) 493 | // AMD_performance_monitor 494 | const ( 495 | COUNTER_RANGE_AMD = 0x8BC1 496 | COUNTER_TYPE_AMD = 0x8BC0 497 | PERCENTAGE_AMD = 0x8BC3 498 | PERFMON_RESULT_AMD = 0x8BC6 499 | PERFMON_RESULT_AVAILABLE_AMD = 0x8BC4 500 | PERFMON_RESULT_SIZE_AMD = 0x8BC5 501 | UNSIGNED_INT64_AMD = 0x8BC2 502 | ) 503 | // AMD_pinned_memory 504 | const ( 505 | EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD = 0x9160 506 | ) 507 | // AMD_query_buffer_object 508 | const ( 509 | QUERY_BUFFER_AMD = 0x9192 510 | QUERY_BUFFER_BINDING_AMD = 0x9193 511 | QUERY_RESULT_NO_WAIT_AMD = 0x9194 512 | ) 513 | // AMD_sample_positions 514 | const ( 515 | SUBSAMPLE_DISTANCE_AMD = 0x883F 516 | ) 517 | // AMD_seamless_cubemap_per_texture 518 | const ( 519 | TEXTURE_CUBE_MAP_SEAMLESS = 0x884F 520 | ) 521 | // AMD_shader_stencil_export 522 | const ( 523 | ) 524 | // AMD_sparse_texture 525 | const ( 526 | MAX_SPARSE_3D_TEXTURE_SIZE_AMD = 0x9199 527 | MAX_SPARSE_ARRAY_TEXTURE_LAYERS = 0x919A 528 | MAX_SPARSE_TEXTURE_SIZE_AMD = 0x9198 529 | MIN_LOD_WARNING_AMD = 0x919C 530 | MIN_SPARSE_LEVEL_AMD = 0x919B 531 | TEXTURE_STORAGE_SPARSE_BIT_AMD = 0x00000001 532 | VIRTUAL_PAGE_SIZE_X_AMD = 0x9195 533 | VIRTUAL_PAGE_SIZE_Y_AMD = 0x9196 534 | VIRTUAL_PAGE_SIZE_Z_AMD = 0x9197 535 | ) 536 | // AMD_stencil_operation_extended 537 | const ( 538 | REPLACE_VALUE_AMD = 0x874B 539 | SET_AMD = 0x874A 540 | STENCIL_BACK_OP_VALUE_AMD = 0x874D 541 | STENCIL_OP_VALUE_AMD = 0x874C 542 | ) 543 | // AMD_texture_texture4 544 | const ( 545 | ) 546 | // AMD_transform_feedback3_lines_triangles 547 | const ( 548 | ) 549 | // AMD_vertex_shader_layer 550 | const ( 551 | ) 552 | // AMD_vertex_shader_tessellator 553 | const ( 554 | CONTINUOUS_AMD = 0x9007 555 | DISCRETE_AMD = 0x9006 556 | INT_SAMPLER_BUFFER_AMD = 0x9002 557 | SAMPLER_BUFFER_AMD = 0x9001 558 | TESSELLATION_FACTOR_AMD = 0x9005 559 | TESSELLATION_MODE_AMD = 0x9004 560 | UNSIGNED_INT_SAMPLER_BUFFER_AMD = 0x9003 561 | ) 562 | // AMD_vertex_shader_viewport_index 563 | const ( 564 | ) 565 | // AMD_debug_output 566 | 567 | func DebugMessageEnableAMD(category Enum, severity Enum, count Sizei, ids *Uint, enabled Boolean) { 568 | C.goglDebugMessageEnableAMD((C.GLenum)(category), (C.GLenum)(severity), (C.GLsizei)(count), (*C.GLuint)(ids), (C.GLboolean)(enabled)) 569 | } 570 | func DebugMessageInsertAMD(category Enum, severity Enum, id Uint, length Sizei, buf *Char) { 571 | C.goglDebugMessageInsertAMD((C.GLenum)(category), (C.GLenum)(severity), (C.GLuint)(id), (C.GLsizei)(length), (*C.GLchar)(buf)) 572 | } 573 | func DebugMessageCallbackAMD(callback Pointer, userParam Pointer) { 574 | C.goglDebugMessageCallbackAMD((*[0]byte)(callback), (unsafe.Pointer)(userParam)) 575 | } 576 | func GetDebugMessageLogAMD(count Uint, bufsize Sizei, categories *Enum, severities *Uint, ids *Uint, lengths *Sizei, message *Char) Uint { 577 | return (Uint)(C.goglGetDebugMessageLogAMD((C.GLuint)(count), (C.GLsizei)(bufsize), (*C.GLenum)(categories), (*C.GLuint)(severities), (*C.GLuint)(ids), (*C.GLsizei)(lengths), (*C.GLchar)(message))) 578 | } 579 | // AMD_draw_buffers_blend 580 | 581 | func BlendFuncIndexedAMD(buf Uint, src Enum, dst Enum) { 582 | C.goglBlendFuncIndexedAMD((C.GLuint)(buf), (C.GLenum)(src), (C.GLenum)(dst)) 583 | } 584 | func BlendFuncSeparateIndexedAMD(buf Uint, srcRGB Enum, dstRGB Enum, srcAlpha Enum, dstAlpha Enum) { 585 | C.goglBlendFuncSeparateIndexedAMD((C.GLuint)(buf), (C.GLenum)(srcRGB), (C.GLenum)(dstRGB), (C.GLenum)(srcAlpha), (C.GLenum)(dstAlpha)) 586 | } 587 | func BlendEquationIndexedAMD(buf Uint, mode Enum) { 588 | C.goglBlendEquationIndexedAMD((C.GLuint)(buf), (C.GLenum)(mode)) 589 | } 590 | func BlendEquationSeparateIndexedAMD(buf Uint, modeRGB Enum, modeAlpha Enum) { 591 | C.goglBlendEquationSeparateIndexedAMD((C.GLuint)(buf), (C.GLenum)(modeRGB), (C.GLenum)(modeAlpha)) 592 | } 593 | // AMD_multi_draw_indirect 594 | 595 | func MultiDrawArraysIndirectAMD(mode Enum, indirect Pointer, primcount Sizei, stride Sizei) { 596 | C.goglMultiDrawArraysIndirectAMD((C.GLenum)(mode), (unsafe.Pointer)(indirect), (C.GLsizei)(primcount), (C.GLsizei)(stride)) 597 | } 598 | func MultiDrawElementsIndirectAMD(mode Enum, type_ Enum, indirect Pointer, primcount Sizei, stride Sizei) { 599 | C.goglMultiDrawElementsIndirectAMD((C.GLenum)(mode), (C.GLenum)(type_), (unsafe.Pointer)(indirect), (C.GLsizei)(primcount), (C.GLsizei)(stride)) 600 | } 601 | // AMD_name_gen_delete 602 | 603 | func GenNamesAMD(identifier Enum, num Uint, names *Uint) { 604 | C.goglGenNamesAMD((C.GLenum)(identifier), (C.GLuint)(num), (*C.GLuint)(names)) 605 | } 606 | func DeleteNamesAMD(identifier Enum, num Uint, names *Uint) { 607 | C.goglDeleteNamesAMD((C.GLenum)(identifier), (C.GLuint)(num), (*C.GLuint)(names)) 608 | } 609 | func IsNameAMD(identifier Enum, name Uint) Boolean { 610 | return (Boolean)(C.goglIsNameAMD((C.GLenum)(identifier), (C.GLuint)(name))) 611 | } 612 | // AMD_performance_monitor 613 | 614 | func GetPerfMonitorGroupsAMD(numGroups *Int, groupsSize Sizei, groups *Uint) { 615 | C.goglGetPerfMonitorGroupsAMD((*C.GLint)(numGroups), (C.GLsizei)(groupsSize), (*C.GLuint)(groups)) 616 | } 617 | func GetPerfMonitorCountersAMD(group Uint, numCounters *Int, maxActiveCounters *Int, counterSize Sizei, counters *Uint) { 618 | C.goglGetPerfMonitorCountersAMD((C.GLuint)(group), (*C.GLint)(numCounters), (*C.GLint)(maxActiveCounters), (C.GLsizei)(counterSize), (*C.GLuint)(counters)) 619 | } 620 | func GetPerfMonitorGroupStringAMD(group Uint, bufSize Sizei, length *Sizei, groupString *Char) { 621 | C.goglGetPerfMonitorGroupStringAMD((C.GLuint)(group), (C.GLsizei)(bufSize), (*C.GLsizei)(length), (*C.GLchar)(groupString)) 622 | } 623 | func GetPerfMonitorCounterStringAMD(group Uint, counter Uint, bufSize Sizei, length *Sizei, counterString *Char) { 624 | C.goglGetPerfMonitorCounterStringAMD((C.GLuint)(group), (C.GLuint)(counter), (C.GLsizei)(bufSize), (*C.GLsizei)(length), (*C.GLchar)(counterString)) 625 | } 626 | func GetPerfMonitorCounterInfoAMD(group Uint, counter Uint, pname Enum, data Pointer) { 627 | C.goglGetPerfMonitorCounterInfoAMD((C.GLuint)(group), (C.GLuint)(counter), (C.GLenum)(pname), (unsafe.Pointer)(data)) 628 | } 629 | func GenPerfMonitorsAMD(n Sizei, monitors *Uint) { 630 | C.goglGenPerfMonitorsAMD((C.GLsizei)(n), (*C.GLuint)(monitors)) 631 | } 632 | func DeletePerfMonitorsAMD(n Sizei, monitors *Uint) { 633 | C.goglDeletePerfMonitorsAMD((C.GLsizei)(n), (*C.GLuint)(monitors)) 634 | } 635 | func SelectPerfMonitorCountersAMD(monitor Uint, enable Boolean, group Uint, numCounters Int, counterList *Uint) { 636 | C.goglSelectPerfMonitorCountersAMD((C.GLuint)(monitor), (C.GLboolean)(enable), (C.GLuint)(group), (C.GLint)(numCounters), (*C.GLuint)(counterList)) 637 | } 638 | func BeginPerfMonitorAMD(monitor Uint) { 639 | C.goglBeginPerfMonitorAMD((C.GLuint)(monitor)) 640 | } 641 | func EndPerfMonitorAMD(monitor Uint) { 642 | C.goglEndPerfMonitorAMD((C.GLuint)(monitor)) 643 | } 644 | func GetPerfMonitorCounterDataAMD(monitor Uint, pname Enum, dataSize Sizei, data *Uint, bytesWritten *Int) { 645 | C.goglGetPerfMonitorCounterDataAMD((C.GLuint)(monitor), (C.GLenum)(pname), (C.GLsizei)(dataSize), (*C.GLuint)(data), (*C.GLint)(bytesWritten)) 646 | } 647 | // AMD_sample_positions 648 | 649 | func SetMultisamplefvAMD(pname Enum, index Uint, val *Float) { 650 | C.goglSetMultisamplefvAMD((C.GLenum)(pname), (C.GLuint)(index), (*C.GLfloat)(val)) 651 | } 652 | // AMD_sparse_texture 653 | 654 | func TexStorageSparseAMD(target Enum, internalFormat Enum, width Sizei, height Sizei, depth Sizei, layers Sizei, flags Bitfield) { 655 | C.goglTexStorageSparseAMD((C.GLenum)(target), (C.GLenum)(internalFormat), (C.GLsizei)(width), (C.GLsizei)(height), (C.GLsizei)(depth), (C.GLsizei)(layers), (C.GLbitfield)(flags)) 656 | } 657 | func TextureStorageSparseAMD(texture Uint, target Enum, internalFormat Enum, width Sizei, height Sizei, depth Sizei, layers Sizei, flags Bitfield) { 658 | C.goglTextureStorageSparseAMD((C.GLuint)(texture), (C.GLenum)(target), (C.GLenum)(internalFormat), (C.GLsizei)(width), (C.GLsizei)(height), (C.GLsizei)(depth), (C.GLsizei)(layers), (C.GLbitfield)(flags)) 659 | } 660 | // AMD_stencil_operation_extended 661 | 662 | func StencilOpValueAMD(face Enum, value Uint) { 663 | C.goglStencilOpValueAMD((C.GLenum)(face), (C.GLuint)(value)) 664 | } 665 | // AMD_vertex_shader_tessellator 666 | 667 | func TessellationFactorAMD(factor Float) { 668 | C.goglTessellationFactorAMD((C.GLfloat)(factor)) 669 | } 670 | func TessellationModeAMD(mode Enum) { 671 | C.goglTessellationModeAMD((C.GLenum)(mode)) 672 | } 673 | func InitAmdDebugOutput() error { 674 | var ret C.int 675 | if ret = C.init_AMD_debug_output(); ret != 0 { 676 | return errors.New("unable to initialize AMD_debug_output") 677 | } 678 | return nil 679 | } 680 | func InitAmdDrawBuffersBlend() error { 681 | var ret C.int 682 | if ret = C.init_AMD_draw_buffers_blend(); ret != 0 { 683 | return errors.New("unable to initialize AMD_draw_buffers_blend") 684 | } 685 | return nil 686 | } 687 | func InitAmdMultiDrawIndirect() error { 688 | var ret C.int 689 | if ret = C.init_AMD_multi_draw_indirect(); ret != 0 { 690 | return errors.New("unable to initialize AMD_multi_draw_indirect") 691 | } 692 | return nil 693 | } 694 | func InitAmdNameGenDelete() error { 695 | var ret C.int 696 | if ret = C.init_AMD_name_gen_delete(); ret != 0 { 697 | return errors.New("unable to initialize AMD_name_gen_delete") 698 | } 699 | return nil 700 | } 701 | func InitAmdPerformanceMonitor() error { 702 | var ret C.int 703 | if ret = C.init_AMD_performance_monitor(); ret != 0 { 704 | return errors.New("unable to initialize AMD_performance_monitor") 705 | } 706 | return nil 707 | } 708 | func InitAmdSamplePositions() error { 709 | var ret C.int 710 | if ret = C.init_AMD_sample_positions(); ret != 0 { 711 | return errors.New("unable to initialize AMD_sample_positions") 712 | } 713 | return nil 714 | } 715 | func InitAmdSparseTexture() error { 716 | var ret C.int 717 | if ret = C.init_AMD_sparse_texture(); ret != 0 { 718 | return errors.New("unable to initialize AMD_sparse_texture") 719 | } 720 | return nil 721 | } 722 | func InitAmdStencilOperationExtended() error { 723 | var ret C.int 724 | if ret = C.init_AMD_stencil_operation_extended(); ret != 0 { 725 | return errors.New("unable to initialize AMD_stencil_operation_extended") 726 | } 727 | return nil 728 | } 729 | func InitAmdVertexShaderTessellator() error { 730 | var ret C.int 731 | if ret = C.init_AMD_vertex_shader_tessellator(); ret != 0 { 732 | return errors.New("unable to initialize AMD_vertex_shader_tessellator") 733 | } 734 | return nil 735 | } 736 | // EOF -------------------------------------------------------------------------------- /ati/ati.go: -------------------------------------------------------------------------------- 1 | // Automatically generated OpenGL binding. 2 | // 3 | // Categories in this package: 4 | // 5 | // ATI_draw_buffers: https://www.opengl.org/registry/specs/ATI/draw_buffers.txt 6 | // 7 | // ATI_element_array: https://www.opengl.org/registry/specs/ATI/element_array.txt 8 | // 9 | // ATI_envmap_bumpmap: https://www.opengl.org/registry/specs/ATI/envmap_bumpmap.txt 10 | // 11 | // ATI_fragment_shader: https://www.opengl.org/registry/specs/ATI/fragment_shader.txt 12 | // 13 | // ATI_map_object_buffer: https://www.opengl.org/registry/specs/ATI/map_object_buffer.txt 14 | // 15 | // ATI_pn_triangles: https://www.opengl.org/registry/specs/ATI/pn_triangles.txt 16 | // 17 | // ATI_separate_stencil: https://www.opengl.org/registry/specs/ATI/separate_stencil.txt 18 | // 19 | // ATI_vertex_array_object: https://www.opengl.org/registry/specs/ATI/vertex_array_object.txt 20 | // 21 | // ATI_vertex_attrib_array_object: https://www.opengl.org/registry/specs/ATI/vertex_attrib_array_object.txt 22 | // 23 | // ATI_vertex_streams: https://www.opengl.org/registry/specs/ATI/vertex_streams.txt 24 | // 25 | package ati 26 | 27 | // #cgo darwin LDFLAGS: -framework OpenGL 28 | // #cgo linux LDFLAGS: -lGL 29 | // #cgo windows LDFLAGS: -lopengl32 30 | // 31 | // #include 32 | // #if defined(__APPLE__) 33 | // #include 34 | // #elif defined(_WIN32) 35 | // #define WIN32_LEAN_AND_MEAN 1 36 | // #include 37 | // #else 38 | // #include 39 | // #include 40 | // #endif 41 | // 42 | // #ifndef APIENTRY 43 | // #define APIENTRY 44 | // #endif 45 | // #ifndef APIENTRYP 46 | // #define APIENTRYP APIENTRY * 47 | // #endif 48 | // #ifndef GLAPI 49 | // #define GLAPI extern 50 | // #endif 51 | // 52 | // typedef unsigned int GLenum; 53 | // typedef unsigned char GLboolean; 54 | // typedef unsigned int GLbitfield; 55 | // typedef signed char GLbyte; 56 | // typedef short GLshort; 57 | // typedef int GLint; 58 | // typedef int GLsizei; 59 | // typedef unsigned char GLubyte; 60 | // typedef unsigned short GLushort; 61 | // typedef unsigned int GLuint; 62 | // typedef unsigned short GLhalf; 63 | // typedef float GLfloat; 64 | // typedef float GLclampf; 65 | // typedef double GLdouble; 66 | // typedef double GLclampd; 67 | // typedef void GLvoid; 68 | // 69 | // #include 70 | // #ifndef GL_VERSION_2_0 71 | // /* GL type for program/shader text */ 72 | // typedef char GLchar; 73 | // #endif 74 | // 75 | // #ifndef GL_VERSION_1_5 76 | // /* GL types for handling large vertex buffer objects */ 77 | // typedef ptrdiff_t GLintptr; 78 | // typedef ptrdiff_t GLsizeiptr; 79 | // #endif 80 | // 81 | // #ifndef GL_ARB_vertex_buffer_object 82 | // /* GL types for handling large vertex buffer objects */ 83 | // typedef ptrdiff_t GLintptrARB; 84 | // typedef ptrdiff_t GLsizeiptrARB; 85 | // #endif 86 | // 87 | // #ifndef GL_ARB_shader_objects 88 | // /* GL types for program/shader text and shader object handles */ 89 | // typedef char GLcharARB; 90 | // typedef unsigned int GLhandleARB; 91 | // #endif 92 | // 93 | // /* GL type for "half" precision (s10e5) float data in host memory */ 94 | // #ifndef GL_ARB_half_float_pixel 95 | // typedef unsigned short GLhalfARB; 96 | // #endif 97 | // 98 | // #ifndef GL_NV_half_float 99 | // typedef unsigned short GLhalfNV; 100 | // #endif 101 | // 102 | // #ifndef GLEXT_64_TYPES_DEFINED 103 | // /* This code block is duplicated in glxext.h, so must be protected */ 104 | // #define GLEXT_64_TYPES_DEFINED 105 | // /* Define int32_t, int64_t, and uint64_t types for UST/MSC */ 106 | // /* (as used in the GL_EXT_timer_query extension). */ 107 | // #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L 108 | // #include 109 | // #elif defined(__sun__) || defined(__digital__) 110 | // #include 111 | // #if defined(__STDC__) 112 | // #if defined(__arch64__) || defined(_LP64) 113 | // typedef long int int64_t; 114 | // typedef unsigned long int uint64_t; 115 | // #else 116 | // typedef long long int int64_t; 117 | // typedef unsigned long long int uint64_t; 118 | // #endif /* __arch64__ */ 119 | // #endif /* __STDC__ */ 120 | // #elif defined( __VMS ) || defined(__sgi) 121 | // #include 122 | // #elif defined(__SCO__) || defined(__USLC__) 123 | // #include 124 | // #elif defined(__UNIXOS2__) || defined(__SOL64__) 125 | // typedef long int int32_t; 126 | // typedef long long int int64_t; 127 | // typedef unsigned long long int uint64_t; 128 | // #elif defined(_WIN32) && defined(__GNUC__) 129 | // #include 130 | // #elif defined(_WIN32) 131 | // typedef __int32 int32_t; 132 | // typedef __int64 int64_t; 133 | // typedef unsigned __int64 uint64_t; 134 | // #else 135 | // /* Fallback if nothing above works */ 136 | // #include 137 | // #endif 138 | // #endif 139 | // 140 | // #ifndef GL_EXT_timer_query 141 | // typedef int64_t GLint64EXT; 142 | // typedef uint64_t GLuint64EXT; 143 | // #endif 144 | // 145 | // #ifndef GL_ARB_sync 146 | // typedef int64_t GLint64; 147 | // typedef uint64_t GLuint64; 148 | // typedef struct __GLsync *GLsync; 149 | // #endif 150 | // 151 | // #ifndef GL_ARB_cl_event 152 | // /* These incomplete types let us declare types compatible with OpenCL's cl_context and cl_event */ 153 | // struct _cl_context; 154 | // struct _cl_event; 155 | // #endif 156 | // 157 | // #ifndef GL_ARB_debug_output 158 | // typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); 159 | // #endif 160 | // 161 | // #ifndef GL_AMD_debug_output 162 | // typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); 163 | // #endif 164 | // 165 | // #ifndef GL_KHR_debug 166 | // typedef void (APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); 167 | // #endif 168 | // 169 | // #ifndef GL_NV_vdpau_interop 170 | // typedef GLintptr GLvdpauSurfaceNV; 171 | // #endif 172 | // 173 | // #ifdef _WIN32 174 | // static HMODULE opengl32 = NULL; 175 | // #endif 176 | // 177 | // static void* goglGetProcAddress(const char* name) { 178 | // #ifdef __APPLE__ 179 | // return dlsym(RTLD_DEFAULT, name); 180 | // #elif _WIN32 181 | // void* pf = wglGetProcAddress((LPCSTR)name); 182 | // if(pf) { 183 | // return pf; 184 | // } 185 | // if(opengl32 == NULL) { 186 | // opengl32 = LoadLibraryA("opengl32.dll"); 187 | // } 188 | // return GetProcAddress(opengl32, (LPCSTR)name); 189 | // #else 190 | // return glXGetProcAddress((const GLubyte*)name); 191 | // #endif 192 | // } 193 | // 194 | // // ATI_draw_buffers 195 | // void (APIENTRYP ptrglDrawBuffersATI)(GLsizei n, GLenum* bufs); 196 | // // ATI_element_array 197 | // void (APIENTRYP ptrglElementPointerATI)(GLenum type, GLvoid* pointer); 198 | // void (APIENTRYP ptrglDrawElementArrayATI)(GLenum mode, GLsizei count); 199 | // void (APIENTRYP ptrglDrawRangeElementArrayATI)(GLenum mode, GLuint start, GLuint end, GLsizei count); 200 | // // ATI_envmap_bumpmap 201 | // void (APIENTRYP ptrglTexBumpParameterivATI)(GLenum pname, GLint* param); 202 | // void (APIENTRYP ptrglTexBumpParameterfvATI)(GLenum pname, GLfloat* param); 203 | // void (APIENTRYP ptrglGetTexBumpParameterivATI)(GLenum pname, GLint* param); 204 | // void (APIENTRYP ptrglGetTexBumpParameterfvATI)(GLenum pname, GLfloat* param); 205 | // // ATI_fragment_shader 206 | // GLuint (APIENTRYP ptrglGenFragmentShadersATI)(GLuint range); 207 | // void (APIENTRYP ptrglBindFragmentShaderATI)(GLuint id); 208 | // void (APIENTRYP ptrglDeleteFragmentShaderATI)(GLuint id); 209 | // void (APIENTRYP ptrglBeginFragmentShaderATI)(); 210 | // void (APIENTRYP ptrglEndFragmentShaderATI)(); 211 | // void (APIENTRYP ptrglPassTexCoordATI)(GLuint dst, GLuint coord, GLenum swizzle); 212 | // void (APIENTRYP ptrglSampleMapATI)(GLuint dst, GLuint interp, GLenum swizzle); 213 | // void (APIENTRYP ptrglColorFragmentOp1ATI)(GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); 214 | // void (APIENTRYP ptrglColorFragmentOp2ATI)(GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); 215 | // void (APIENTRYP ptrglColorFragmentOp3ATI)(GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); 216 | // void (APIENTRYP ptrglAlphaFragmentOp1ATI)(GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); 217 | // void (APIENTRYP ptrglAlphaFragmentOp2ATI)(GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); 218 | // void (APIENTRYP ptrglAlphaFragmentOp3ATI)(GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); 219 | // void (APIENTRYP ptrglSetFragmentShaderConstantATI)(GLuint dst, GLfloat* value); 220 | // // ATI_map_object_buffer 221 | // GLvoid* (APIENTRYP ptrglMapObjectBufferATI)(GLuint buffer); 222 | // void (APIENTRYP ptrglUnmapObjectBufferATI)(GLuint buffer); 223 | // // ATI_pn_triangles 224 | // void (APIENTRYP ptrglPNTrianglesiATI)(GLenum pname, GLint param); 225 | // void (APIENTRYP ptrglPNTrianglesfATI)(GLenum pname, GLfloat param); 226 | // // ATI_separate_stencil 227 | // void (APIENTRYP ptrglStencilOpSeparateATI)(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); 228 | // void (APIENTRYP ptrglStencilFuncSeparateATI)(GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); 229 | // // ATI_vertex_array_object 230 | // GLuint (APIENTRYP ptrglNewObjectBufferATI)(GLsizei size, GLvoid* pointer, GLenum usage); 231 | // GLboolean (APIENTRYP ptrglIsObjectBufferATI)(GLuint buffer); 232 | // void (APIENTRYP ptrglUpdateObjectBufferATI)(GLuint buffer, GLuint offset, GLsizei size, GLvoid* pointer, GLenum preserve); 233 | // void (APIENTRYP ptrglGetObjectBufferfvATI)(GLuint buffer, GLenum pname, GLfloat* params); 234 | // void (APIENTRYP ptrglGetObjectBufferivATI)(GLuint buffer, GLenum pname, GLint* params); 235 | // void (APIENTRYP ptrglFreeObjectBufferATI)(GLuint buffer); 236 | // void (APIENTRYP ptrglArrayObjectATI)(GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); 237 | // void (APIENTRYP ptrglGetArrayObjectfvATI)(GLenum array, GLenum pname, GLfloat* params); 238 | // void (APIENTRYP ptrglGetArrayObjectivATI)(GLenum array, GLenum pname, GLint* params); 239 | // void (APIENTRYP ptrglVariantArrayObjectATI)(GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); 240 | // void (APIENTRYP ptrglGetVariantArrayObjectfvATI)(GLuint id, GLenum pname, GLfloat* params); 241 | // void (APIENTRYP ptrglGetVariantArrayObjectivATI)(GLuint id, GLenum pname, GLint* params); 242 | // // ATI_vertex_attrib_array_object 243 | // void (APIENTRYP ptrglVertexAttribArrayObjectATI)(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); 244 | // void (APIENTRYP ptrglGetVertexAttribArrayObjectfvATI)(GLuint index, GLenum pname, GLfloat* params); 245 | // void (APIENTRYP ptrglGetVertexAttribArrayObjectivATI)(GLuint index, GLenum pname, GLint* params); 246 | // // ATI_vertex_streams 247 | // void (APIENTRYP ptrglVertexStream1sATI)(GLenum stream, GLshort x); 248 | // void (APIENTRYP ptrglVertexStream1svATI)(GLenum stream, GLshort* coords); 249 | // void (APIENTRYP ptrglVertexStream1iATI)(GLenum stream, GLint x); 250 | // void (APIENTRYP ptrglVertexStream1ivATI)(GLenum stream, GLint* coords); 251 | // void (APIENTRYP ptrglVertexStream1fATI)(GLenum stream, GLfloat x); 252 | // void (APIENTRYP ptrglVertexStream1fvATI)(GLenum stream, GLfloat* coords); 253 | // void (APIENTRYP ptrglVertexStream1dATI)(GLenum stream, GLdouble x); 254 | // void (APIENTRYP ptrglVertexStream1dvATI)(GLenum stream, GLdouble* coords); 255 | // void (APIENTRYP ptrglVertexStream2sATI)(GLenum stream, GLshort x, GLshort y); 256 | // void (APIENTRYP ptrglVertexStream2svATI)(GLenum stream, GLshort* coords); 257 | // void (APIENTRYP ptrglVertexStream2iATI)(GLenum stream, GLint x, GLint y); 258 | // void (APIENTRYP ptrglVertexStream2ivATI)(GLenum stream, GLint* coords); 259 | // void (APIENTRYP ptrglVertexStream2fATI)(GLenum stream, GLfloat x, GLfloat y); 260 | // void (APIENTRYP ptrglVertexStream2fvATI)(GLenum stream, GLfloat* coords); 261 | // void (APIENTRYP ptrglVertexStream2dATI)(GLenum stream, GLdouble x, GLdouble y); 262 | // void (APIENTRYP ptrglVertexStream2dvATI)(GLenum stream, GLdouble* coords); 263 | // void (APIENTRYP ptrglVertexStream3sATI)(GLenum stream, GLshort x, GLshort y, GLshort z); 264 | // void (APIENTRYP ptrglVertexStream3svATI)(GLenum stream, GLshort* coords); 265 | // void (APIENTRYP ptrglVertexStream3iATI)(GLenum stream, GLint x, GLint y, GLint z); 266 | // void (APIENTRYP ptrglVertexStream3ivATI)(GLenum stream, GLint* coords); 267 | // void (APIENTRYP ptrglVertexStream3fATI)(GLenum stream, GLfloat x, GLfloat y, GLfloat z); 268 | // void (APIENTRYP ptrglVertexStream3fvATI)(GLenum stream, GLfloat* coords); 269 | // void (APIENTRYP ptrglVertexStream3dATI)(GLenum stream, GLdouble x, GLdouble y, GLdouble z); 270 | // void (APIENTRYP ptrglVertexStream3dvATI)(GLenum stream, GLdouble* coords); 271 | // void (APIENTRYP ptrglVertexStream4sATI)(GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); 272 | // void (APIENTRYP ptrglVertexStream4svATI)(GLenum stream, GLshort* coords); 273 | // void (APIENTRYP ptrglVertexStream4iATI)(GLenum stream, GLint x, GLint y, GLint z, GLint w); 274 | // void (APIENTRYP ptrglVertexStream4ivATI)(GLenum stream, GLint* coords); 275 | // void (APIENTRYP ptrglVertexStream4fATI)(GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); 276 | // void (APIENTRYP ptrglVertexStream4fvATI)(GLenum stream, GLfloat* coords); 277 | // void (APIENTRYP ptrglVertexStream4dATI)(GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); 278 | // void (APIENTRYP ptrglVertexStream4dvATI)(GLenum stream, GLdouble* coords); 279 | // void (APIENTRYP ptrglNormalStream3bATI)(GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); 280 | // void (APIENTRYP ptrglNormalStream3bvATI)(GLenum stream, GLbyte* coords); 281 | // void (APIENTRYP ptrglNormalStream3sATI)(GLenum stream, GLshort nx, GLshort ny, GLshort nz); 282 | // void (APIENTRYP ptrglNormalStream3svATI)(GLenum stream, GLshort* coords); 283 | // void (APIENTRYP ptrglNormalStream3iATI)(GLenum stream, GLint nx, GLint ny, GLint nz); 284 | // void (APIENTRYP ptrglNormalStream3ivATI)(GLenum stream, GLint* coords); 285 | // void (APIENTRYP ptrglNormalStream3fATI)(GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); 286 | // void (APIENTRYP ptrglNormalStream3fvATI)(GLenum stream, GLfloat* coords); 287 | // void (APIENTRYP ptrglNormalStream3dATI)(GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); 288 | // void (APIENTRYP ptrglNormalStream3dvATI)(GLenum stream, GLdouble* coords); 289 | // void (APIENTRYP ptrglClientActiveVertexStreamATI)(GLenum stream); 290 | // void (APIENTRYP ptrglVertexBlendEnviATI)(GLenum pname, GLint param); 291 | // void (APIENTRYP ptrglVertexBlendEnvfATI)(GLenum pname, GLfloat param); 292 | // 293 | // // ATI_draw_buffers 294 | // void goglDrawBuffersATI(GLsizei n, GLenum* bufs) { 295 | // (*ptrglDrawBuffersATI)(n, bufs); 296 | // } 297 | // // ATI_element_array 298 | // void goglElementPointerATI(GLenum type_, GLvoid* pointer) { 299 | // (*ptrglElementPointerATI)(type_, pointer); 300 | // } 301 | // void goglDrawElementArrayATI(GLenum mode, GLsizei count) { 302 | // (*ptrglDrawElementArrayATI)(mode, count); 303 | // } 304 | // void goglDrawRangeElementArrayATI(GLenum mode, GLuint start, GLuint end, GLsizei count) { 305 | // (*ptrglDrawRangeElementArrayATI)(mode, start, end, count); 306 | // } 307 | // // ATI_envmap_bumpmap 308 | // void goglTexBumpParameterivATI(GLenum pname, GLint* param) { 309 | // (*ptrglTexBumpParameterivATI)(pname, param); 310 | // } 311 | // void goglTexBumpParameterfvATI(GLenum pname, GLfloat* param) { 312 | // (*ptrglTexBumpParameterfvATI)(pname, param); 313 | // } 314 | // void goglGetTexBumpParameterivATI(GLenum pname, GLint* param) { 315 | // (*ptrglGetTexBumpParameterivATI)(pname, param); 316 | // } 317 | // void goglGetTexBumpParameterfvATI(GLenum pname, GLfloat* param) { 318 | // (*ptrglGetTexBumpParameterfvATI)(pname, param); 319 | // } 320 | // // ATI_fragment_shader 321 | // GLuint goglGenFragmentShadersATI(GLuint range_) { 322 | // return (*ptrglGenFragmentShadersATI)(range_); 323 | // } 324 | // void goglBindFragmentShaderATI(GLuint id) { 325 | // (*ptrglBindFragmentShaderATI)(id); 326 | // } 327 | // void goglDeleteFragmentShaderATI(GLuint id) { 328 | // (*ptrglDeleteFragmentShaderATI)(id); 329 | // } 330 | // void goglBeginFragmentShaderATI() { 331 | // (*ptrglBeginFragmentShaderATI)(); 332 | // } 333 | // void goglEndFragmentShaderATI() { 334 | // (*ptrglEndFragmentShaderATI)(); 335 | // } 336 | // void goglPassTexCoordATI(GLuint dst, GLuint coord, GLenum swizzle) { 337 | // (*ptrglPassTexCoordATI)(dst, coord, swizzle); 338 | // } 339 | // void goglSampleMapATI(GLuint dst, GLuint interp, GLenum swizzle) { 340 | // (*ptrglSampleMapATI)(dst, interp, swizzle); 341 | // } 342 | // void goglColorFragmentOp1ATI(GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod) { 343 | // (*ptrglColorFragmentOp1ATI)(op, dst, dstMask, dstMod, arg1, arg1Rep, arg1Mod); 344 | // } 345 | // void goglColorFragmentOp2ATI(GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod) { 346 | // (*ptrglColorFragmentOp2ATI)(op, dst, dstMask, dstMod, arg1, arg1Rep, arg1Mod, arg2, arg2Rep, arg2Mod); 347 | // } 348 | // void goglColorFragmentOp3ATI(GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod) { 349 | // (*ptrglColorFragmentOp3ATI)(op, dst, dstMask, dstMod, arg1, arg1Rep, arg1Mod, arg2, arg2Rep, arg2Mod, arg3, arg3Rep, arg3Mod); 350 | // } 351 | // void goglAlphaFragmentOp1ATI(GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod) { 352 | // (*ptrglAlphaFragmentOp1ATI)(op, dst, dstMod, arg1, arg1Rep, arg1Mod); 353 | // } 354 | // void goglAlphaFragmentOp2ATI(GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod) { 355 | // (*ptrglAlphaFragmentOp2ATI)(op, dst, dstMod, arg1, arg1Rep, arg1Mod, arg2, arg2Rep, arg2Mod); 356 | // } 357 | // void goglAlphaFragmentOp3ATI(GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod) { 358 | // (*ptrglAlphaFragmentOp3ATI)(op, dst, dstMod, arg1, arg1Rep, arg1Mod, arg2, arg2Rep, arg2Mod, arg3, arg3Rep, arg3Mod); 359 | // } 360 | // void goglSetFragmentShaderConstantATI(GLuint dst, GLfloat* value) { 361 | // (*ptrglSetFragmentShaderConstantATI)(dst, value); 362 | // } 363 | // // ATI_map_object_buffer 364 | // GLvoid* goglMapObjectBufferATI(GLuint buffer) { 365 | // return (*ptrglMapObjectBufferATI)(buffer); 366 | // } 367 | // void goglUnmapObjectBufferATI(GLuint buffer) { 368 | // (*ptrglUnmapObjectBufferATI)(buffer); 369 | // } 370 | // // ATI_pn_triangles 371 | // void goglPNTrianglesiATI(GLenum pname, GLint param) { 372 | // (*ptrglPNTrianglesiATI)(pname, param); 373 | // } 374 | // void goglPNTrianglesfATI(GLenum pname, GLfloat param) { 375 | // (*ptrglPNTrianglesfATI)(pname, param); 376 | // } 377 | // // ATI_separate_stencil 378 | // void goglStencilOpSeparateATI(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass) { 379 | // (*ptrglStencilOpSeparateATI)(face, sfail, dpfail, dppass); 380 | // } 381 | // void goglStencilFuncSeparateATI(GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask) { 382 | // (*ptrglStencilFuncSeparateATI)(frontfunc, backfunc, ref, mask); 383 | // } 384 | // // ATI_vertex_array_object 385 | // GLuint goglNewObjectBufferATI(GLsizei size, GLvoid* pointer, GLenum usage) { 386 | // return (*ptrglNewObjectBufferATI)(size, pointer, usage); 387 | // } 388 | // GLboolean goglIsObjectBufferATI(GLuint buffer) { 389 | // return (*ptrglIsObjectBufferATI)(buffer); 390 | // } 391 | // void goglUpdateObjectBufferATI(GLuint buffer, GLuint offset, GLsizei size, GLvoid* pointer, GLenum preserve) { 392 | // (*ptrglUpdateObjectBufferATI)(buffer, offset, size, pointer, preserve); 393 | // } 394 | // void goglGetObjectBufferfvATI(GLuint buffer, GLenum pname, GLfloat* params) { 395 | // (*ptrglGetObjectBufferfvATI)(buffer, pname, params); 396 | // } 397 | // void goglGetObjectBufferivATI(GLuint buffer, GLenum pname, GLint* params) { 398 | // (*ptrglGetObjectBufferivATI)(buffer, pname, params); 399 | // } 400 | // void goglFreeObjectBufferATI(GLuint buffer) { 401 | // (*ptrglFreeObjectBufferATI)(buffer); 402 | // } 403 | // void goglArrayObjectATI(GLenum array, GLint size, GLenum type_, GLsizei stride, GLuint buffer, GLuint offset) { 404 | // (*ptrglArrayObjectATI)(array, size, type_, stride, buffer, offset); 405 | // } 406 | // void goglGetArrayObjectfvATI(GLenum array, GLenum pname, GLfloat* params) { 407 | // (*ptrglGetArrayObjectfvATI)(array, pname, params); 408 | // } 409 | // void goglGetArrayObjectivATI(GLenum array, GLenum pname, GLint* params) { 410 | // (*ptrglGetArrayObjectivATI)(array, pname, params); 411 | // } 412 | // void goglVariantArrayObjectATI(GLuint id, GLenum type_, GLsizei stride, GLuint buffer, GLuint offset) { 413 | // (*ptrglVariantArrayObjectATI)(id, type_, stride, buffer, offset); 414 | // } 415 | // void goglGetVariantArrayObjectfvATI(GLuint id, GLenum pname, GLfloat* params) { 416 | // (*ptrglGetVariantArrayObjectfvATI)(id, pname, params); 417 | // } 418 | // void goglGetVariantArrayObjectivATI(GLuint id, GLenum pname, GLint* params) { 419 | // (*ptrglGetVariantArrayObjectivATI)(id, pname, params); 420 | // } 421 | // // ATI_vertex_attrib_array_object 422 | // void goglVertexAttribArrayObjectATI(GLuint index, GLint size, GLenum type_, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset) { 423 | // (*ptrglVertexAttribArrayObjectATI)(index, size, type_, normalized, stride, buffer, offset); 424 | // } 425 | // void goglGetVertexAttribArrayObjectfvATI(GLuint index, GLenum pname, GLfloat* params) { 426 | // (*ptrglGetVertexAttribArrayObjectfvATI)(index, pname, params); 427 | // } 428 | // void goglGetVertexAttribArrayObjectivATI(GLuint index, GLenum pname, GLint* params) { 429 | // (*ptrglGetVertexAttribArrayObjectivATI)(index, pname, params); 430 | // } 431 | // // ATI_vertex_streams 432 | // void goglVertexStream1sATI(GLenum stream, GLshort x) { 433 | // (*ptrglVertexStream1sATI)(stream, x); 434 | // } 435 | // void goglVertexStream1svATI(GLenum stream, GLshort* coords) { 436 | // (*ptrglVertexStream1svATI)(stream, coords); 437 | // } 438 | // void goglVertexStream1iATI(GLenum stream, GLint x) { 439 | // (*ptrglVertexStream1iATI)(stream, x); 440 | // } 441 | // void goglVertexStream1ivATI(GLenum stream, GLint* coords) { 442 | // (*ptrglVertexStream1ivATI)(stream, coords); 443 | // } 444 | // void goglVertexStream1fATI(GLenum stream, GLfloat x) { 445 | // (*ptrglVertexStream1fATI)(stream, x); 446 | // } 447 | // void goglVertexStream1fvATI(GLenum stream, GLfloat* coords) { 448 | // (*ptrglVertexStream1fvATI)(stream, coords); 449 | // } 450 | // void goglVertexStream1dATI(GLenum stream, GLdouble x) { 451 | // (*ptrglVertexStream1dATI)(stream, x); 452 | // } 453 | // void goglVertexStream1dvATI(GLenum stream, GLdouble* coords) { 454 | // (*ptrglVertexStream1dvATI)(stream, coords); 455 | // } 456 | // void goglVertexStream2sATI(GLenum stream, GLshort x, GLshort y) { 457 | // (*ptrglVertexStream2sATI)(stream, x, y); 458 | // } 459 | // void goglVertexStream2svATI(GLenum stream, GLshort* coords) { 460 | // (*ptrglVertexStream2svATI)(stream, coords); 461 | // } 462 | // void goglVertexStream2iATI(GLenum stream, GLint x, GLint y) { 463 | // (*ptrglVertexStream2iATI)(stream, x, y); 464 | // } 465 | // void goglVertexStream2ivATI(GLenum stream, GLint* coords) { 466 | // (*ptrglVertexStream2ivATI)(stream, coords); 467 | // } 468 | // void goglVertexStream2fATI(GLenum stream, GLfloat x, GLfloat y) { 469 | // (*ptrglVertexStream2fATI)(stream, x, y); 470 | // } 471 | // void goglVertexStream2fvATI(GLenum stream, GLfloat* coords) { 472 | // (*ptrglVertexStream2fvATI)(stream, coords); 473 | // } 474 | // void goglVertexStream2dATI(GLenum stream, GLdouble x, GLdouble y) { 475 | // (*ptrglVertexStream2dATI)(stream, x, y); 476 | // } 477 | // void goglVertexStream2dvATI(GLenum stream, GLdouble* coords) { 478 | // (*ptrglVertexStream2dvATI)(stream, coords); 479 | // } 480 | // void goglVertexStream3sATI(GLenum stream, GLshort x, GLshort y, GLshort z) { 481 | // (*ptrglVertexStream3sATI)(stream, x, y, z); 482 | // } 483 | // void goglVertexStream3svATI(GLenum stream, GLshort* coords) { 484 | // (*ptrglVertexStream3svATI)(stream, coords); 485 | // } 486 | // void goglVertexStream3iATI(GLenum stream, GLint x, GLint y, GLint z) { 487 | // (*ptrglVertexStream3iATI)(stream, x, y, z); 488 | // } 489 | // void goglVertexStream3ivATI(GLenum stream, GLint* coords) { 490 | // (*ptrglVertexStream3ivATI)(stream, coords); 491 | // } 492 | // void goglVertexStream3fATI(GLenum stream, GLfloat x, GLfloat y, GLfloat z) { 493 | // (*ptrglVertexStream3fATI)(stream, x, y, z); 494 | // } 495 | // void goglVertexStream3fvATI(GLenum stream, GLfloat* coords) { 496 | // (*ptrglVertexStream3fvATI)(stream, coords); 497 | // } 498 | // void goglVertexStream3dATI(GLenum stream, GLdouble x, GLdouble y, GLdouble z) { 499 | // (*ptrglVertexStream3dATI)(stream, x, y, z); 500 | // } 501 | // void goglVertexStream3dvATI(GLenum stream, GLdouble* coords) { 502 | // (*ptrglVertexStream3dvATI)(stream, coords); 503 | // } 504 | // void goglVertexStream4sATI(GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w) { 505 | // (*ptrglVertexStream4sATI)(stream, x, y, z, w); 506 | // } 507 | // void goglVertexStream4svATI(GLenum stream, GLshort* coords) { 508 | // (*ptrglVertexStream4svATI)(stream, coords); 509 | // } 510 | // void goglVertexStream4iATI(GLenum stream, GLint x, GLint y, GLint z, GLint w) { 511 | // (*ptrglVertexStream4iATI)(stream, x, y, z, w); 512 | // } 513 | // void goglVertexStream4ivATI(GLenum stream, GLint* coords) { 514 | // (*ptrglVertexStream4ivATI)(stream, coords); 515 | // } 516 | // void goglVertexStream4fATI(GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w) { 517 | // (*ptrglVertexStream4fATI)(stream, x, y, z, w); 518 | // } 519 | // void goglVertexStream4fvATI(GLenum stream, GLfloat* coords) { 520 | // (*ptrglVertexStream4fvATI)(stream, coords); 521 | // } 522 | // void goglVertexStream4dATI(GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w) { 523 | // (*ptrglVertexStream4dATI)(stream, x, y, z, w); 524 | // } 525 | // void goglVertexStream4dvATI(GLenum stream, GLdouble* coords) { 526 | // (*ptrglVertexStream4dvATI)(stream, coords); 527 | // } 528 | // void goglNormalStream3bATI(GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz) { 529 | // (*ptrglNormalStream3bATI)(stream, nx, ny, nz); 530 | // } 531 | // void goglNormalStream3bvATI(GLenum stream, GLbyte* coords) { 532 | // (*ptrglNormalStream3bvATI)(stream, coords); 533 | // } 534 | // void goglNormalStream3sATI(GLenum stream, GLshort nx, GLshort ny, GLshort nz) { 535 | // (*ptrglNormalStream3sATI)(stream, nx, ny, nz); 536 | // } 537 | // void goglNormalStream3svATI(GLenum stream, GLshort* coords) { 538 | // (*ptrglNormalStream3svATI)(stream, coords); 539 | // } 540 | // void goglNormalStream3iATI(GLenum stream, GLint nx, GLint ny, GLint nz) { 541 | // (*ptrglNormalStream3iATI)(stream, nx, ny, nz); 542 | // } 543 | // void goglNormalStream3ivATI(GLenum stream, GLint* coords) { 544 | // (*ptrglNormalStream3ivATI)(stream, coords); 545 | // } 546 | // void goglNormalStream3fATI(GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz) { 547 | // (*ptrglNormalStream3fATI)(stream, nx, ny, nz); 548 | // } 549 | // void goglNormalStream3fvATI(GLenum stream, GLfloat* coords) { 550 | // (*ptrglNormalStream3fvATI)(stream, coords); 551 | // } 552 | // void goglNormalStream3dATI(GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz) { 553 | // (*ptrglNormalStream3dATI)(stream, nx, ny, nz); 554 | // } 555 | // void goglNormalStream3dvATI(GLenum stream, GLdouble* coords) { 556 | // (*ptrglNormalStream3dvATI)(stream, coords); 557 | // } 558 | // void goglClientActiveVertexStreamATI(GLenum stream) { 559 | // (*ptrglClientActiveVertexStreamATI)(stream); 560 | // } 561 | // void goglVertexBlendEnviATI(GLenum pname, GLint param) { 562 | // (*ptrglVertexBlendEnviATI)(pname, param); 563 | // } 564 | // void goglVertexBlendEnvfATI(GLenum pname, GLfloat param) { 565 | // (*ptrglVertexBlendEnvfATI)(pname, param); 566 | // } 567 | // 568 | // int init_ATI_draw_buffers() { 569 | // ptrglDrawBuffersATI = goglGetProcAddress("glDrawBuffersATI"); 570 | // if(ptrglDrawBuffersATI == NULL) return 1; 571 | // return 0; 572 | // } 573 | // int init_ATI_element_array() { 574 | // ptrglElementPointerATI = goglGetProcAddress("glElementPointerATI"); 575 | // if(ptrglElementPointerATI == NULL) return 1; 576 | // ptrglDrawElementArrayATI = goglGetProcAddress("glDrawElementArrayATI"); 577 | // if(ptrglDrawElementArrayATI == NULL) return 1; 578 | // ptrglDrawRangeElementArrayATI = goglGetProcAddress("glDrawRangeElementArrayATI"); 579 | // if(ptrglDrawRangeElementArrayATI == NULL) return 1; 580 | // return 0; 581 | // } 582 | // int init_ATI_envmap_bumpmap() { 583 | // ptrglTexBumpParameterivATI = goglGetProcAddress("glTexBumpParameterivATI"); 584 | // if(ptrglTexBumpParameterivATI == NULL) return 1; 585 | // ptrglTexBumpParameterfvATI = goglGetProcAddress("glTexBumpParameterfvATI"); 586 | // if(ptrglTexBumpParameterfvATI == NULL) return 1; 587 | // ptrglGetTexBumpParameterivATI = goglGetProcAddress("glGetTexBumpParameterivATI"); 588 | // if(ptrglGetTexBumpParameterivATI == NULL) return 1; 589 | // ptrglGetTexBumpParameterfvATI = goglGetProcAddress("glGetTexBumpParameterfvATI"); 590 | // if(ptrglGetTexBumpParameterfvATI == NULL) return 1; 591 | // return 0; 592 | // } 593 | // int init_ATI_fragment_shader() { 594 | // ptrglGenFragmentShadersATI = goglGetProcAddress("glGenFragmentShadersATI"); 595 | // if(ptrglGenFragmentShadersATI == NULL) return 1; 596 | // ptrglBindFragmentShaderATI = goglGetProcAddress("glBindFragmentShaderATI"); 597 | // if(ptrglBindFragmentShaderATI == NULL) return 1; 598 | // ptrglDeleteFragmentShaderATI = goglGetProcAddress("glDeleteFragmentShaderATI"); 599 | // if(ptrglDeleteFragmentShaderATI == NULL) return 1; 600 | // ptrglBeginFragmentShaderATI = goglGetProcAddress("glBeginFragmentShaderATI"); 601 | // if(ptrglBeginFragmentShaderATI == NULL) return 1; 602 | // ptrglEndFragmentShaderATI = goglGetProcAddress("glEndFragmentShaderATI"); 603 | // if(ptrglEndFragmentShaderATI == NULL) return 1; 604 | // ptrglPassTexCoordATI = goglGetProcAddress("glPassTexCoordATI"); 605 | // if(ptrglPassTexCoordATI == NULL) return 1; 606 | // ptrglSampleMapATI = goglGetProcAddress("glSampleMapATI"); 607 | // if(ptrglSampleMapATI == NULL) return 1; 608 | // ptrglColorFragmentOp1ATI = goglGetProcAddress("glColorFragmentOp1ATI"); 609 | // if(ptrglColorFragmentOp1ATI == NULL) return 1; 610 | // ptrglColorFragmentOp2ATI = goglGetProcAddress("glColorFragmentOp2ATI"); 611 | // if(ptrglColorFragmentOp2ATI == NULL) return 1; 612 | // ptrglColorFragmentOp3ATI = goglGetProcAddress("glColorFragmentOp3ATI"); 613 | // if(ptrglColorFragmentOp3ATI == NULL) return 1; 614 | // ptrglAlphaFragmentOp1ATI = goglGetProcAddress("glAlphaFragmentOp1ATI"); 615 | // if(ptrglAlphaFragmentOp1ATI == NULL) return 1; 616 | // ptrglAlphaFragmentOp2ATI = goglGetProcAddress("glAlphaFragmentOp2ATI"); 617 | // if(ptrglAlphaFragmentOp2ATI == NULL) return 1; 618 | // ptrglAlphaFragmentOp3ATI = goglGetProcAddress("glAlphaFragmentOp3ATI"); 619 | // if(ptrglAlphaFragmentOp3ATI == NULL) return 1; 620 | // ptrglSetFragmentShaderConstantATI = goglGetProcAddress("glSetFragmentShaderConstantATI"); 621 | // if(ptrglSetFragmentShaderConstantATI == NULL) return 1; 622 | // return 0; 623 | // } 624 | // int init_ATI_map_object_buffer() { 625 | // ptrglMapObjectBufferATI = goglGetProcAddress("glMapObjectBufferATI"); 626 | // if(ptrglMapObjectBufferATI == NULL) return 1; 627 | // ptrglUnmapObjectBufferATI = goglGetProcAddress("glUnmapObjectBufferATI"); 628 | // if(ptrglUnmapObjectBufferATI == NULL) return 1; 629 | // return 0; 630 | // } 631 | // int init_ATI_pn_triangles() { 632 | // ptrglPNTrianglesiATI = goglGetProcAddress("glPNTrianglesiATI"); 633 | // if(ptrglPNTrianglesiATI == NULL) return 1; 634 | // ptrglPNTrianglesfATI = goglGetProcAddress("glPNTrianglesfATI"); 635 | // if(ptrglPNTrianglesfATI == NULL) return 1; 636 | // return 0; 637 | // } 638 | // int init_ATI_separate_stencil() { 639 | // ptrglStencilOpSeparateATI = goglGetProcAddress("glStencilOpSeparateATI"); 640 | // if(ptrglStencilOpSeparateATI == NULL) return 1; 641 | // ptrglStencilFuncSeparateATI = goglGetProcAddress("glStencilFuncSeparateATI"); 642 | // if(ptrglStencilFuncSeparateATI == NULL) return 1; 643 | // return 0; 644 | // } 645 | // int init_ATI_vertex_array_object() { 646 | // ptrglNewObjectBufferATI = goglGetProcAddress("glNewObjectBufferATI"); 647 | // if(ptrglNewObjectBufferATI == NULL) return 1; 648 | // ptrglIsObjectBufferATI = goglGetProcAddress("glIsObjectBufferATI"); 649 | // if(ptrglIsObjectBufferATI == NULL) return 1; 650 | // ptrglUpdateObjectBufferATI = goglGetProcAddress("glUpdateObjectBufferATI"); 651 | // if(ptrglUpdateObjectBufferATI == NULL) return 1; 652 | // ptrglGetObjectBufferfvATI = goglGetProcAddress("glGetObjectBufferfvATI"); 653 | // if(ptrglGetObjectBufferfvATI == NULL) return 1; 654 | // ptrglGetObjectBufferivATI = goglGetProcAddress("glGetObjectBufferivATI"); 655 | // if(ptrglGetObjectBufferivATI == NULL) return 1; 656 | // ptrglFreeObjectBufferATI = goglGetProcAddress("glFreeObjectBufferATI"); 657 | // if(ptrglFreeObjectBufferATI == NULL) return 1; 658 | // ptrglArrayObjectATI = goglGetProcAddress("glArrayObjectATI"); 659 | // if(ptrglArrayObjectATI == NULL) return 1; 660 | // ptrglGetArrayObjectfvATI = goglGetProcAddress("glGetArrayObjectfvATI"); 661 | // if(ptrglGetArrayObjectfvATI == NULL) return 1; 662 | // ptrglGetArrayObjectivATI = goglGetProcAddress("glGetArrayObjectivATI"); 663 | // if(ptrglGetArrayObjectivATI == NULL) return 1; 664 | // ptrglVariantArrayObjectATI = goglGetProcAddress("glVariantArrayObjectATI"); 665 | // if(ptrglVariantArrayObjectATI == NULL) return 1; 666 | // ptrglGetVariantArrayObjectfvATI = goglGetProcAddress("glGetVariantArrayObjectfvATI"); 667 | // if(ptrglGetVariantArrayObjectfvATI == NULL) return 1; 668 | // ptrglGetVariantArrayObjectivATI = goglGetProcAddress("glGetVariantArrayObjectivATI"); 669 | // if(ptrglGetVariantArrayObjectivATI == NULL) return 1; 670 | // return 0; 671 | // } 672 | // int init_ATI_vertex_attrib_array_object() { 673 | // ptrglVertexAttribArrayObjectATI = goglGetProcAddress("glVertexAttribArrayObjectATI"); 674 | // if(ptrglVertexAttribArrayObjectATI == NULL) return 1; 675 | // ptrglGetVertexAttribArrayObjectfvATI = goglGetProcAddress("glGetVertexAttribArrayObjectfvATI"); 676 | // if(ptrglGetVertexAttribArrayObjectfvATI == NULL) return 1; 677 | // ptrglGetVertexAttribArrayObjectivATI = goglGetProcAddress("glGetVertexAttribArrayObjectivATI"); 678 | // if(ptrglGetVertexAttribArrayObjectivATI == NULL) return 1; 679 | // return 0; 680 | // } 681 | // int init_ATI_vertex_streams() { 682 | // ptrglVertexStream1sATI = goglGetProcAddress("glVertexStream1sATI"); 683 | // if(ptrglVertexStream1sATI == NULL) return 1; 684 | // ptrglVertexStream1svATI = goglGetProcAddress("glVertexStream1svATI"); 685 | // if(ptrglVertexStream1svATI == NULL) return 1; 686 | // ptrglVertexStream1iATI = goglGetProcAddress("glVertexStream1iATI"); 687 | // if(ptrglVertexStream1iATI == NULL) return 1; 688 | // ptrglVertexStream1ivATI = goglGetProcAddress("glVertexStream1ivATI"); 689 | // if(ptrglVertexStream1ivATI == NULL) return 1; 690 | // ptrglVertexStream1fATI = goglGetProcAddress("glVertexStream1fATI"); 691 | // if(ptrglVertexStream1fATI == NULL) return 1; 692 | // ptrglVertexStream1fvATI = goglGetProcAddress("glVertexStream1fvATI"); 693 | // if(ptrglVertexStream1fvATI == NULL) return 1; 694 | // ptrglVertexStream1dATI = goglGetProcAddress("glVertexStream1dATI"); 695 | // if(ptrglVertexStream1dATI == NULL) return 1; 696 | // ptrglVertexStream1dvATI = goglGetProcAddress("glVertexStream1dvATI"); 697 | // if(ptrglVertexStream1dvATI == NULL) return 1; 698 | // ptrglVertexStream2sATI = goglGetProcAddress("glVertexStream2sATI"); 699 | // if(ptrglVertexStream2sATI == NULL) return 1; 700 | // ptrglVertexStream2svATI = goglGetProcAddress("glVertexStream2svATI"); 701 | // if(ptrglVertexStream2svATI == NULL) return 1; 702 | // ptrglVertexStream2iATI = goglGetProcAddress("glVertexStream2iATI"); 703 | // if(ptrglVertexStream2iATI == NULL) return 1; 704 | // ptrglVertexStream2ivATI = goglGetProcAddress("glVertexStream2ivATI"); 705 | // if(ptrglVertexStream2ivATI == NULL) return 1; 706 | // ptrglVertexStream2fATI = goglGetProcAddress("glVertexStream2fATI"); 707 | // if(ptrglVertexStream2fATI == NULL) return 1; 708 | // ptrglVertexStream2fvATI = goglGetProcAddress("glVertexStream2fvATI"); 709 | // if(ptrglVertexStream2fvATI == NULL) return 1; 710 | // ptrglVertexStream2dATI = goglGetProcAddress("glVertexStream2dATI"); 711 | // if(ptrglVertexStream2dATI == NULL) return 1; 712 | // ptrglVertexStream2dvATI = goglGetProcAddress("glVertexStream2dvATI"); 713 | // if(ptrglVertexStream2dvATI == NULL) return 1; 714 | // ptrglVertexStream3sATI = goglGetProcAddress("glVertexStream3sATI"); 715 | // if(ptrglVertexStream3sATI == NULL) return 1; 716 | // ptrglVertexStream3svATI = goglGetProcAddress("glVertexStream3svATI"); 717 | // if(ptrglVertexStream3svATI == NULL) return 1; 718 | // ptrglVertexStream3iATI = goglGetProcAddress("glVertexStream3iATI"); 719 | // if(ptrglVertexStream3iATI == NULL) return 1; 720 | // ptrglVertexStream3ivATI = goglGetProcAddress("glVertexStream3ivATI"); 721 | // if(ptrglVertexStream3ivATI == NULL) return 1; 722 | // ptrglVertexStream3fATI = goglGetProcAddress("glVertexStream3fATI"); 723 | // if(ptrglVertexStream3fATI == NULL) return 1; 724 | // ptrglVertexStream3fvATI = goglGetProcAddress("glVertexStream3fvATI"); 725 | // if(ptrglVertexStream3fvATI == NULL) return 1; 726 | // ptrglVertexStream3dATI = goglGetProcAddress("glVertexStream3dATI"); 727 | // if(ptrglVertexStream3dATI == NULL) return 1; 728 | // ptrglVertexStream3dvATI = goglGetProcAddress("glVertexStream3dvATI"); 729 | // if(ptrglVertexStream3dvATI == NULL) return 1; 730 | // ptrglVertexStream4sATI = goglGetProcAddress("glVertexStream4sATI"); 731 | // if(ptrglVertexStream4sATI == NULL) return 1; 732 | // ptrglVertexStream4svATI = goglGetProcAddress("glVertexStream4svATI"); 733 | // if(ptrglVertexStream4svATI == NULL) return 1; 734 | // ptrglVertexStream4iATI = goglGetProcAddress("glVertexStream4iATI"); 735 | // if(ptrglVertexStream4iATI == NULL) return 1; 736 | // ptrglVertexStream4ivATI = goglGetProcAddress("glVertexStream4ivATI"); 737 | // if(ptrglVertexStream4ivATI == NULL) return 1; 738 | // ptrglVertexStream4fATI = goglGetProcAddress("glVertexStream4fATI"); 739 | // if(ptrglVertexStream4fATI == NULL) return 1; 740 | // ptrglVertexStream4fvATI = goglGetProcAddress("glVertexStream4fvATI"); 741 | // if(ptrglVertexStream4fvATI == NULL) return 1; 742 | // ptrglVertexStream4dATI = goglGetProcAddress("glVertexStream4dATI"); 743 | // if(ptrglVertexStream4dATI == NULL) return 1; 744 | // ptrglVertexStream4dvATI = goglGetProcAddress("glVertexStream4dvATI"); 745 | // if(ptrglVertexStream4dvATI == NULL) return 1; 746 | // ptrglNormalStream3bATI = goglGetProcAddress("glNormalStream3bATI"); 747 | // if(ptrglNormalStream3bATI == NULL) return 1; 748 | // ptrglNormalStream3bvATI = goglGetProcAddress("glNormalStream3bvATI"); 749 | // if(ptrglNormalStream3bvATI == NULL) return 1; 750 | // ptrglNormalStream3sATI = goglGetProcAddress("glNormalStream3sATI"); 751 | // if(ptrglNormalStream3sATI == NULL) return 1; 752 | // ptrglNormalStream3svATI = goglGetProcAddress("glNormalStream3svATI"); 753 | // if(ptrglNormalStream3svATI == NULL) return 1; 754 | // ptrglNormalStream3iATI = goglGetProcAddress("glNormalStream3iATI"); 755 | // if(ptrglNormalStream3iATI == NULL) return 1; 756 | // ptrglNormalStream3ivATI = goglGetProcAddress("glNormalStream3ivATI"); 757 | // if(ptrglNormalStream3ivATI == NULL) return 1; 758 | // ptrglNormalStream3fATI = goglGetProcAddress("glNormalStream3fATI"); 759 | // if(ptrglNormalStream3fATI == NULL) return 1; 760 | // ptrglNormalStream3fvATI = goglGetProcAddress("glNormalStream3fvATI"); 761 | // if(ptrglNormalStream3fvATI == NULL) return 1; 762 | // ptrglNormalStream3dATI = goglGetProcAddress("glNormalStream3dATI"); 763 | // if(ptrglNormalStream3dATI == NULL) return 1; 764 | // ptrglNormalStream3dvATI = goglGetProcAddress("glNormalStream3dvATI"); 765 | // if(ptrglNormalStream3dvATI == NULL) return 1; 766 | // ptrglClientActiveVertexStreamATI = goglGetProcAddress("glClientActiveVertexStreamATI"); 767 | // if(ptrglClientActiveVertexStreamATI == NULL) return 1; 768 | // ptrglVertexBlendEnviATI = goglGetProcAddress("glVertexBlendEnviATI"); 769 | // if(ptrglVertexBlendEnviATI == NULL) return 1; 770 | // ptrglVertexBlendEnvfATI = goglGetProcAddress("glVertexBlendEnvfATI"); 771 | // if(ptrglVertexBlendEnvfATI == NULL) return 1; 772 | // return 0; 773 | // } 774 | // 775 | import "C" 776 | import "unsafe" 777 | import "errors" 778 | 779 | type ( 780 | Enum C.GLenum 781 | Boolean C.GLboolean 782 | Bitfield C.GLbitfield 783 | Byte C.GLbyte 784 | Short C.GLshort 785 | Int C.GLint 786 | Sizei C.GLsizei 787 | Ubyte C.GLubyte 788 | Ushort C.GLushort 789 | Uint C.GLuint 790 | Half C.GLhalf 791 | Float C.GLfloat 792 | Clampf C.GLclampf 793 | Double C.GLdouble 794 | Clampd C.GLclampd 795 | Char C.GLchar 796 | Pointer unsafe.Pointer 797 | Sync C.GLsync 798 | Int64 C.GLint64 799 | Uint64 C.GLuint64 800 | Intptr C.GLintptr 801 | Sizeiptr C.GLsizeiptr 802 | ) 803 | 804 | // ATI_draw_buffers 805 | const ( 806 | DRAW_BUFFER0_ATI = 0x8825 807 | DRAW_BUFFER10_ATI = 0x882F 808 | DRAW_BUFFER11_ATI = 0x8830 809 | DRAW_BUFFER12_ATI = 0x8831 810 | DRAW_BUFFER13_ATI = 0x8832 811 | DRAW_BUFFER14_ATI = 0x8833 812 | DRAW_BUFFER15_ATI = 0x8834 813 | DRAW_BUFFER1_ATI = 0x8826 814 | DRAW_BUFFER2_ATI = 0x8827 815 | DRAW_BUFFER3_ATI = 0x8828 816 | DRAW_BUFFER4_ATI = 0x8829 817 | DRAW_BUFFER5_ATI = 0x882A 818 | DRAW_BUFFER6_ATI = 0x882B 819 | DRAW_BUFFER7_ATI = 0x882C 820 | DRAW_BUFFER8_ATI = 0x882D 821 | DRAW_BUFFER9_ATI = 0x882E 822 | MAX_DRAW_BUFFERS_ATI = 0x8824 823 | ) 824 | // ATI_element_array 825 | const ( 826 | ELEMENT_ARRAY_ATI = 0x8768 827 | ELEMENT_ARRAY_POINTER_ATI = 0x876A 828 | ELEMENT_ARRAY_TYPE_ATI = 0x8769 829 | ) 830 | // ATI_envmap_bumpmap 831 | const ( 832 | BUMP_ENVMAP_ATI = 0x877B 833 | BUMP_NUM_TEX_UNITS_ATI = 0x8777 834 | BUMP_ROT_MATRIX_ATI = 0x8775 835 | BUMP_ROT_MATRIX_SIZE_ATI = 0x8776 836 | BUMP_TARGET_ATI = 0x877C 837 | BUMP_TEX_UNITS_ATI = 0x8778 838 | DU8DV8_ATI = 0x877A 839 | DUDV_ATI = 0x8779 840 | ) 841 | // ATI_fragment_shader 842 | const ( 843 | X2X_BIT_ATI = 0x00000001 844 | X4X_BIT_ATI = 0x00000002 845 | X8X_BIT_ATI = 0x00000004 846 | ADD_ATI = 0x8963 847 | BIAS_BIT_ATI = 0x00000008 848 | BLUE_BIT_ATI = 0x00000004 849 | CND0_ATI = 0x896B 850 | CND_ATI = 0x896A 851 | COLOR_ALPHA_PAIRING_ATI = 0x8975 852 | COMP_BIT_ATI = 0x00000002 853 | CON_0_ATI = 0x8941 854 | CON_10_ATI = 0x894B 855 | CON_11_ATI = 0x894C 856 | CON_12_ATI = 0x894D 857 | CON_13_ATI = 0x894E 858 | CON_14_ATI = 0x894F 859 | CON_15_ATI = 0x8950 860 | CON_16_ATI = 0x8951 861 | CON_17_ATI = 0x8952 862 | CON_18_ATI = 0x8953 863 | CON_19_ATI = 0x8954 864 | CON_1_ATI = 0x8942 865 | CON_20_ATI = 0x8955 866 | CON_21_ATI = 0x8956 867 | CON_22_ATI = 0x8957 868 | CON_23_ATI = 0x8958 869 | CON_24_ATI = 0x8959 870 | CON_25_ATI = 0x895A 871 | CON_26_ATI = 0x895B 872 | CON_27_ATI = 0x895C 873 | CON_28_ATI = 0x895D 874 | CON_29_ATI = 0x895E 875 | CON_2_ATI = 0x8943 876 | CON_30_ATI = 0x895F 877 | CON_31_ATI = 0x8960 878 | CON_3_ATI = 0x8944 879 | CON_4_ATI = 0x8945 880 | CON_5_ATI = 0x8946 881 | CON_6_ATI = 0x8947 882 | CON_7_ATI = 0x8948 883 | CON_8_ATI = 0x8949 884 | CON_9_ATI = 0x894A 885 | DOT2_ADD_ATI = 0x896C 886 | DOT3_ATI = 0x8966 887 | DOT4_ATI = 0x8967 888 | EIGHTH_BIT_ATI = 0x00000020 889 | FRAGMENT_SHADER_ATI = 0x8920 890 | GREEN_BIT_ATI = 0x00000002 891 | HALF_BIT_ATI = 0x00000008 892 | LERP_ATI = 0x8969 893 | MAD_ATI = 0x8968 894 | MOV_ATI = 0x8961 895 | MUL_ATI = 0x8964 896 | NEGATE_BIT_ATI = 0x00000004 897 | NUM_FRAGMENT_CONSTANTS_ATI = 0x896F 898 | NUM_FRAGMENT_REGISTERS_ATI = 0x896E 899 | NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI = 0x8973 900 | NUM_INSTRUCTIONS_PER_PASS_ATI = 0x8971 901 | NUM_INSTRUCTIONS_TOTAL_ATI = 0x8972 902 | NUM_LOOPBACK_COMPONENTS_ATI = 0x8974 903 | NUM_PASSES_ATI = 0x8970 904 | QUARTER_BIT_ATI = 0x00000010 905 | RED_BIT_ATI = 0x00000001 906 | REG_0_ATI = 0x8921 907 | REG_10_ATI = 0x892B 908 | REG_11_ATI = 0x892C 909 | REG_12_ATI = 0x892D 910 | REG_13_ATI = 0x892E 911 | REG_14_ATI = 0x892F 912 | REG_15_ATI = 0x8930 913 | REG_16_ATI = 0x8931 914 | REG_17_ATI = 0x8932 915 | REG_18_ATI = 0x8933 916 | REG_19_ATI = 0x8934 917 | REG_1_ATI = 0x8922 918 | REG_20_ATI = 0x8935 919 | REG_21_ATI = 0x8936 920 | REG_22_ATI = 0x8937 921 | REG_23_ATI = 0x8938 922 | REG_24_ATI = 0x8939 923 | REG_25_ATI = 0x893A 924 | REG_26_ATI = 0x893B 925 | REG_27_ATI = 0x893C 926 | REG_28_ATI = 0x893D 927 | REG_29_ATI = 0x893E 928 | REG_2_ATI = 0x8923 929 | REG_30_ATI = 0x893F 930 | REG_31_ATI = 0x8940 931 | REG_3_ATI = 0x8924 932 | REG_4_ATI = 0x8925 933 | REG_5_ATI = 0x8926 934 | REG_6_ATI = 0x8927 935 | REG_7_ATI = 0x8928 936 | REG_8_ATI = 0x8929 937 | REG_9_ATI = 0x892A 938 | SATURATE_BIT_ATI = 0x00000040 939 | SECONDARY_INTERPOLATOR_ATI = 0x896D 940 | SUB_ATI = 0x8965 941 | SWIZZLE_STQ_ATI = 0x8977 942 | SWIZZLE_STQ_DQ_ATI = 0x8979 943 | SWIZZLE_STRQ_ATI = 0x897A 944 | SWIZZLE_STRQ_DQ_ATI = 0x897B 945 | SWIZZLE_STR_ATI = 0x8976 946 | SWIZZLE_STR_DR_ATI = 0x8978 947 | ) 948 | // ATI_map_object_buffer 949 | const ( 950 | ) 951 | // ATI_meminfo 952 | const ( 953 | RENDERBUFFER_FREE_MEMORY_ATI = 0x87FD 954 | TEXTURE_FREE_MEMORY_ATI = 0x87FC 955 | VBO_FREE_MEMORY_ATI = 0x87FB 956 | ) 957 | // ATI_pixel_format_float 958 | const ( 959 | COLOR_CLEAR_UNCLAMPED_VALUE_ATI = 0x8835 960 | RGBA_FLOAT_MODE_ATI = 0x8820 961 | ) 962 | // ATI_pn_triangles 963 | const ( 964 | MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI = 0x87F1 965 | PN_TRIANGLES_ATI = 0x87F0 966 | PN_TRIANGLES_NORMAL_MODE_ATI = 0x87F3 967 | PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI = 0x87F7 968 | PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI = 0x87F8 969 | PN_TRIANGLES_POINT_MODE_ATI = 0x87F2 970 | PN_TRIANGLES_POINT_MODE_CUBIC_ATI = 0x87F6 971 | PN_TRIANGLES_POINT_MODE_LINEAR_ATI = 0x87F5 972 | PN_TRIANGLES_TESSELATION_LEVEL_ATI = 0x87F4 973 | ) 974 | // ATI_separate_stencil 975 | const ( 976 | STENCIL_BACK_FAIL_ATI = 0x8801 977 | STENCIL_BACK_FUNC_ATI = 0x8800 978 | STENCIL_BACK_PASS_DEPTH_FAIL_ATI = 0x8802 979 | STENCIL_BACK_PASS_DEPTH_PASS_ATI = 0x8803 980 | ) 981 | // ATI_text_fragment_shader 982 | const ( 983 | TEXT_FRAGMENT_SHADER_ATI = 0x8200 984 | ) 985 | // ATI_texture_env_combine3 986 | const ( 987 | MODULATE_ADD_ATI = 0x8744 988 | MODULATE_SIGNED_ADD_ATI = 0x8745 989 | MODULATE_SUBTRACT_ATI = 0x8746 990 | ) 991 | // ATI_texture_float 992 | const ( 993 | ALPHA_FLOAT16_ATI = 0x881C 994 | ALPHA_FLOAT32_ATI = 0x8816 995 | INTENSITY_FLOAT16_ATI = 0x881D 996 | INTENSITY_FLOAT32_ATI = 0x8817 997 | LUMINANCE_ALPHA_FLOAT16_ATI = 0x881F 998 | LUMINANCE_ALPHA_FLOAT32_ATI = 0x8819 999 | LUMINANCE_FLOAT16_ATI = 0x881E 1000 | LUMINANCE_FLOAT32_ATI = 0x8818 1001 | RGBA_FLOAT16_ATI = 0x881A 1002 | RGBA_FLOAT32_ATI = 0x8814 1003 | RGB_FLOAT16_ATI = 0x881B 1004 | RGB_FLOAT32_ATI = 0x8815 1005 | ) 1006 | // ATI_texture_mirror_once 1007 | const ( 1008 | MIRROR_CLAMP_ATI = 0x8742 1009 | MIRROR_CLAMP_TO_EDGE_ATI = 0x8743 1010 | ) 1011 | // ATI_vertex_array_object 1012 | const ( 1013 | ARRAY_OBJECT_BUFFER_ATI = 0x8766 1014 | ARRAY_OBJECT_OFFSET_ATI = 0x8767 1015 | DISCARD_ATI = 0x8763 1016 | DYNAMIC_ATI = 0x8761 1017 | OBJECT_BUFFER_SIZE_ATI = 0x8764 1018 | OBJECT_BUFFER_USAGE_ATI = 0x8765 1019 | PRESERVE_ATI = 0x8762 1020 | STATIC_ATI = 0x8760 1021 | ) 1022 | // ATI_vertex_attrib_array_object 1023 | const ( 1024 | ) 1025 | // ATI_vertex_streams 1026 | const ( 1027 | MAX_VERTEX_STREAMS_ATI = 0x876B 1028 | VERTEX_SOURCE_ATI = 0x8774 1029 | VERTEX_STREAM0_ATI = 0x876C 1030 | VERTEX_STREAM1_ATI = 0x876D 1031 | VERTEX_STREAM2_ATI = 0x876E 1032 | VERTEX_STREAM3_ATI = 0x876F 1033 | VERTEX_STREAM4_ATI = 0x8770 1034 | VERTEX_STREAM5_ATI = 0x8771 1035 | VERTEX_STREAM6_ATI = 0x8772 1036 | VERTEX_STREAM7_ATI = 0x8773 1037 | ) 1038 | // ATI_draw_buffers 1039 | 1040 | func DrawBuffersATI(n Sizei, bufs *Enum) { 1041 | C.goglDrawBuffersATI((C.GLsizei)(n), (*C.GLenum)(bufs)) 1042 | } 1043 | // ATI_element_array 1044 | 1045 | func ElementPointerATI(type_ Enum, pointer Pointer) { 1046 | C.goglElementPointerATI((C.GLenum)(type_), (unsafe.Pointer)(pointer)) 1047 | } 1048 | func DrawElementArrayATI(mode Enum, count Sizei) { 1049 | C.goglDrawElementArrayATI((C.GLenum)(mode), (C.GLsizei)(count)) 1050 | } 1051 | func DrawRangeElementArrayATI(mode Enum, start Uint, end Uint, count Sizei) { 1052 | C.goglDrawRangeElementArrayATI((C.GLenum)(mode), (C.GLuint)(start), (C.GLuint)(end), (C.GLsizei)(count)) 1053 | } 1054 | // ATI_envmap_bumpmap 1055 | 1056 | func TexBumpParameterivATI(pname Enum, param *Int) { 1057 | C.goglTexBumpParameterivATI((C.GLenum)(pname), (*C.GLint)(param)) 1058 | } 1059 | func TexBumpParameterfvATI(pname Enum, param *Float) { 1060 | C.goglTexBumpParameterfvATI((C.GLenum)(pname), (*C.GLfloat)(param)) 1061 | } 1062 | func GetTexBumpParameterivATI(pname Enum, param *Int) { 1063 | C.goglGetTexBumpParameterivATI((C.GLenum)(pname), (*C.GLint)(param)) 1064 | } 1065 | func GetTexBumpParameterfvATI(pname Enum, param *Float) { 1066 | C.goglGetTexBumpParameterfvATI((C.GLenum)(pname), (*C.GLfloat)(param)) 1067 | } 1068 | // ATI_fragment_shader 1069 | 1070 | func GenFragmentShadersATI(range_ Uint) Uint { 1071 | return (Uint)(C.goglGenFragmentShadersATI((C.GLuint)(range_))) 1072 | } 1073 | func BindFragmentShaderATI(id Uint) { 1074 | C.goglBindFragmentShaderATI((C.GLuint)(id)) 1075 | } 1076 | func DeleteFragmentShaderATI(id Uint) { 1077 | C.goglDeleteFragmentShaderATI((C.GLuint)(id)) 1078 | } 1079 | func BeginFragmentShaderATI() { 1080 | C.goglBeginFragmentShaderATI() 1081 | } 1082 | func EndFragmentShaderATI() { 1083 | C.goglEndFragmentShaderATI() 1084 | } 1085 | func PassTexCoordATI(dst Uint, coord Uint, swizzle Enum) { 1086 | C.goglPassTexCoordATI((C.GLuint)(dst), (C.GLuint)(coord), (C.GLenum)(swizzle)) 1087 | } 1088 | func SampleMapATI(dst Uint, interp Uint, swizzle Enum) { 1089 | C.goglSampleMapATI((C.GLuint)(dst), (C.GLuint)(interp), (C.GLenum)(swizzle)) 1090 | } 1091 | func ColorFragmentOp1ATI(op Enum, dst Uint, dstMask Uint, dstMod Uint, arg1 Uint, arg1Rep Uint, arg1Mod Uint) { 1092 | C.goglColorFragmentOp1ATI((C.GLenum)(op), (C.GLuint)(dst), (C.GLuint)(dstMask), (C.GLuint)(dstMod), (C.GLuint)(arg1), (C.GLuint)(arg1Rep), (C.GLuint)(arg1Mod)) 1093 | } 1094 | func ColorFragmentOp2ATI(op Enum, dst Uint, dstMask Uint, dstMod Uint, arg1 Uint, arg1Rep Uint, arg1Mod Uint, arg2 Uint, arg2Rep Uint, arg2Mod Uint) { 1095 | C.goglColorFragmentOp2ATI((C.GLenum)(op), (C.GLuint)(dst), (C.GLuint)(dstMask), (C.GLuint)(dstMod), (C.GLuint)(arg1), (C.GLuint)(arg1Rep), (C.GLuint)(arg1Mod), (C.GLuint)(arg2), (C.GLuint)(arg2Rep), (C.GLuint)(arg2Mod)) 1096 | } 1097 | func ColorFragmentOp3ATI(op Enum, dst Uint, dstMask Uint, dstMod Uint, arg1 Uint, arg1Rep Uint, arg1Mod Uint, arg2 Uint, arg2Rep Uint, arg2Mod Uint, arg3 Uint, arg3Rep Uint, arg3Mod Uint) { 1098 | C.goglColorFragmentOp3ATI((C.GLenum)(op), (C.GLuint)(dst), (C.GLuint)(dstMask), (C.GLuint)(dstMod), (C.GLuint)(arg1), (C.GLuint)(arg1Rep), (C.GLuint)(arg1Mod), (C.GLuint)(arg2), (C.GLuint)(arg2Rep), (C.GLuint)(arg2Mod), (C.GLuint)(arg3), (C.GLuint)(arg3Rep), (C.GLuint)(arg3Mod)) 1099 | } 1100 | func AlphaFragmentOp1ATI(op Enum, dst Uint, dstMod Uint, arg1 Uint, arg1Rep Uint, arg1Mod Uint) { 1101 | C.goglAlphaFragmentOp1ATI((C.GLenum)(op), (C.GLuint)(dst), (C.GLuint)(dstMod), (C.GLuint)(arg1), (C.GLuint)(arg1Rep), (C.GLuint)(arg1Mod)) 1102 | } 1103 | func AlphaFragmentOp2ATI(op Enum, dst Uint, dstMod Uint, arg1 Uint, arg1Rep Uint, arg1Mod Uint, arg2 Uint, arg2Rep Uint, arg2Mod Uint) { 1104 | C.goglAlphaFragmentOp2ATI((C.GLenum)(op), (C.GLuint)(dst), (C.GLuint)(dstMod), (C.GLuint)(arg1), (C.GLuint)(arg1Rep), (C.GLuint)(arg1Mod), (C.GLuint)(arg2), (C.GLuint)(arg2Rep), (C.GLuint)(arg2Mod)) 1105 | } 1106 | func AlphaFragmentOp3ATI(op Enum, dst Uint, dstMod Uint, arg1 Uint, arg1Rep Uint, arg1Mod Uint, arg2 Uint, arg2Rep Uint, arg2Mod Uint, arg3 Uint, arg3Rep Uint, arg3Mod Uint) { 1107 | C.goglAlphaFragmentOp3ATI((C.GLenum)(op), (C.GLuint)(dst), (C.GLuint)(dstMod), (C.GLuint)(arg1), (C.GLuint)(arg1Rep), (C.GLuint)(arg1Mod), (C.GLuint)(arg2), (C.GLuint)(arg2Rep), (C.GLuint)(arg2Mod), (C.GLuint)(arg3), (C.GLuint)(arg3Rep), (C.GLuint)(arg3Mod)) 1108 | } 1109 | func SetFragmentShaderConstantATI(dst Uint, value *Float) { 1110 | C.goglSetFragmentShaderConstantATI((C.GLuint)(dst), (*C.GLfloat)(value)) 1111 | } 1112 | // ATI_map_object_buffer 1113 | 1114 | func MapObjectBufferATI(buffer Uint) Pointer { 1115 | return (Pointer)(C.goglMapObjectBufferATI((C.GLuint)(buffer))) 1116 | } 1117 | func UnmapObjectBufferATI(buffer Uint) { 1118 | C.goglUnmapObjectBufferATI((C.GLuint)(buffer)) 1119 | } 1120 | // ATI_pn_triangles 1121 | 1122 | func PNTrianglesiATI(pname Enum, param Int) { 1123 | C.goglPNTrianglesiATI((C.GLenum)(pname), (C.GLint)(param)) 1124 | } 1125 | func PNTrianglesfATI(pname Enum, param Float) { 1126 | C.goglPNTrianglesfATI((C.GLenum)(pname), (C.GLfloat)(param)) 1127 | } 1128 | // ATI_separate_stencil 1129 | 1130 | func StencilOpSeparateATI(face Enum, sfail Enum, dpfail Enum, dppass Enum) { 1131 | C.goglStencilOpSeparateATI((C.GLenum)(face), (C.GLenum)(sfail), (C.GLenum)(dpfail), (C.GLenum)(dppass)) 1132 | } 1133 | func StencilFuncSeparateATI(frontfunc Enum, backfunc Enum, ref Int, mask Uint) { 1134 | C.goglStencilFuncSeparateATI((C.GLenum)(frontfunc), (C.GLenum)(backfunc), (C.GLint)(ref), (C.GLuint)(mask)) 1135 | } 1136 | // ATI_vertex_array_object 1137 | 1138 | func NewObjectBufferATI(size Sizei, pointer Pointer, usage Enum) Uint { 1139 | return (Uint)(C.goglNewObjectBufferATI((C.GLsizei)(size), (unsafe.Pointer)(pointer), (C.GLenum)(usage))) 1140 | } 1141 | func IsObjectBufferATI(buffer Uint) Boolean { 1142 | return (Boolean)(C.goglIsObjectBufferATI((C.GLuint)(buffer))) 1143 | } 1144 | func UpdateObjectBufferATI(buffer Uint, offset Uint, size Sizei, pointer Pointer, preserve Enum) { 1145 | C.goglUpdateObjectBufferATI((C.GLuint)(buffer), (C.GLuint)(offset), (C.GLsizei)(size), (unsafe.Pointer)(pointer), (C.GLenum)(preserve)) 1146 | } 1147 | func GetObjectBufferfvATI(buffer Uint, pname Enum, params *Float) { 1148 | C.goglGetObjectBufferfvATI((C.GLuint)(buffer), (C.GLenum)(pname), (*C.GLfloat)(params)) 1149 | } 1150 | func GetObjectBufferivATI(buffer Uint, pname Enum, params *Int) { 1151 | C.goglGetObjectBufferivATI((C.GLuint)(buffer), (C.GLenum)(pname), (*C.GLint)(params)) 1152 | } 1153 | func FreeObjectBufferATI(buffer Uint) { 1154 | C.goglFreeObjectBufferATI((C.GLuint)(buffer)) 1155 | } 1156 | func ArrayObjectATI(array Enum, size Int, type_ Enum, stride Sizei, buffer Uint, offset Uint) { 1157 | C.goglArrayObjectATI((C.GLenum)(array), (C.GLint)(size), (C.GLenum)(type_), (C.GLsizei)(stride), (C.GLuint)(buffer), (C.GLuint)(offset)) 1158 | } 1159 | func GetArrayObjectfvATI(array Enum, pname Enum, params *Float) { 1160 | C.goglGetArrayObjectfvATI((C.GLenum)(array), (C.GLenum)(pname), (*C.GLfloat)(params)) 1161 | } 1162 | func GetArrayObjectivATI(array Enum, pname Enum, params *Int) { 1163 | C.goglGetArrayObjectivATI((C.GLenum)(array), (C.GLenum)(pname), (*C.GLint)(params)) 1164 | } 1165 | func VariantArrayObjectATI(id Uint, type_ Enum, stride Sizei, buffer Uint, offset Uint) { 1166 | C.goglVariantArrayObjectATI((C.GLuint)(id), (C.GLenum)(type_), (C.GLsizei)(stride), (C.GLuint)(buffer), (C.GLuint)(offset)) 1167 | } 1168 | func GetVariantArrayObjectfvATI(id Uint, pname Enum, params *Float) { 1169 | C.goglGetVariantArrayObjectfvATI((C.GLuint)(id), (C.GLenum)(pname), (*C.GLfloat)(params)) 1170 | } 1171 | func GetVariantArrayObjectivATI(id Uint, pname Enum, params *Int) { 1172 | C.goglGetVariantArrayObjectivATI((C.GLuint)(id), (C.GLenum)(pname), (*C.GLint)(params)) 1173 | } 1174 | // ATI_vertex_attrib_array_object 1175 | 1176 | func VertexAttribArrayObjectATI(index Uint, size Int, type_ Enum, normalized Boolean, stride Sizei, buffer Uint, offset Uint) { 1177 | C.goglVertexAttribArrayObjectATI((C.GLuint)(index), (C.GLint)(size), (C.GLenum)(type_), (C.GLboolean)(normalized), (C.GLsizei)(stride), (C.GLuint)(buffer), (C.GLuint)(offset)) 1178 | } 1179 | func GetVertexAttribArrayObjectfvATI(index Uint, pname Enum, params *Float) { 1180 | C.goglGetVertexAttribArrayObjectfvATI((C.GLuint)(index), (C.GLenum)(pname), (*C.GLfloat)(params)) 1181 | } 1182 | func GetVertexAttribArrayObjectivATI(index Uint, pname Enum, params *Int) { 1183 | C.goglGetVertexAttribArrayObjectivATI((C.GLuint)(index), (C.GLenum)(pname), (*C.GLint)(params)) 1184 | } 1185 | // ATI_vertex_streams 1186 | 1187 | func VertexStream1sATI(stream Enum, x Short) { 1188 | C.goglVertexStream1sATI((C.GLenum)(stream), (C.GLshort)(x)) 1189 | } 1190 | func VertexStream1svATI(stream Enum, coords *Short) { 1191 | C.goglVertexStream1svATI((C.GLenum)(stream), (*C.GLshort)(coords)) 1192 | } 1193 | func VertexStream1iATI(stream Enum, x Int) { 1194 | C.goglVertexStream1iATI((C.GLenum)(stream), (C.GLint)(x)) 1195 | } 1196 | func VertexStream1ivATI(stream Enum, coords *Int) { 1197 | C.goglVertexStream1ivATI((C.GLenum)(stream), (*C.GLint)(coords)) 1198 | } 1199 | func VertexStream1fATI(stream Enum, x Float) { 1200 | C.goglVertexStream1fATI((C.GLenum)(stream), (C.GLfloat)(x)) 1201 | } 1202 | func VertexStream1fvATI(stream Enum, coords *Float) { 1203 | C.goglVertexStream1fvATI((C.GLenum)(stream), (*C.GLfloat)(coords)) 1204 | } 1205 | func VertexStream1dATI(stream Enum, x Double) { 1206 | C.goglVertexStream1dATI((C.GLenum)(stream), (C.GLdouble)(x)) 1207 | } 1208 | func VertexStream1dvATI(stream Enum, coords *Double) { 1209 | C.goglVertexStream1dvATI((C.GLenum)(stream), (*C.GLdouble)(coords)) 1210 | } 1211 | func VertexStream2sATI(stream Enum, x Short, y Short) { 1212 | C.goglVertexStream2sATI((C.GLenum)(stream), (C.GLshort)(x), (C.GLshort)(y)) 1213 | } 1214 | func VertexStream2svATI(stream Enum, coords *Short) { 1215 | C.goglVertexStream2svATI((C.GLenum)(stream), (*C.GLshort)(coords)) 1216 | } 1217 | func VertexStream2iATI(stream Enum, x Int, y Int) { 1218 | C.goglVertexStream2iATI((C.GLenum)(stream), (C.GLint)(x), (C.GLint)(y)) 1219 | } 1220 | func VertexStream2ivATI(stream Enum, coords *Int) { 1221 | C.goglVertexStream2ivATI((C.GLenum)(stream), (*C.GLint)(coords)) 1222 | } 1223 | func VertexStream2fATI(stream Enum, x Float, y Float) { 1224 | C.goglVertexStream2fATI((C.GLenum)(stream), (C.GLfloat)(x), (C.GLfloat)(y)) 1225 | } 1226 | func VertexStream2fvATI(stream Enum, coords *Float) { 1227 | C.goglVertexStream2fvATI((C.GLenum)(stream), (*C.GLfloat)(coords)) 1228 | } 1229 | func VertexStream2dATI(stream Enum, x Double, y Double) { 1230 | C.goglVertexStream2dATI((C.GLenum)(stream), (C.GLdouble)(x), (C.GLdouble)(y)) 1231 | } 1232 | func VertexStream2dvATI(stream Enum, coords *Double) { 1233 | C.goglVertexStream2dvATI((C.GLenum)(stream), (*C.GLdouble)(coords)) 1234 | } 1235 | func VertexStream3sATI(stream Enum, x Short, y Short, z Short) { 1236 | C.goglVertexStream3sATI((C.GLenum)(stream), (C.GLshort)(x), (C.GLshort)(y), (C.GLshort)(z)) 1237 | } 1238 | func VertexStream3svATI(stream Enum, coords *Short) { 1239 | C.goglVertexStream3svATI((C.GLenum)(stream), (*C.GLshort)(coords)) 1240 | } 1241 | func VertexStream3iATI(stream Enum, x Int, y Int, z Int) { 1242 | C.goglVertexStream3iATI((C.GLenum)(stream), (C.GLint)(x), (C.GLint)(y), (C.GLint)(z)) 1243 | } 1244 | func VertexStream3ivATI(stream Enum, coords *Int) { 1245 | C.goglVertexStream3ivATI((C.GLenum)(stream), (*C.GLint)(coords)) 1246 | } 1247 | func VertexStream3fATI(stream Enum, x Float, y Float, z Float) { 1248 | C.goglVertexStream3fATI((C.GLenum)(stream), (C.GLfloat)(x), (C.GLfloat)(y), (C.GLfloat)(z)) 1249 | } 1250 | func VertexStream3fvATI(stream Enum, coords *Float) { 1251 | C.goglVertexStream3fvATI((C.GLenum)(stream), (*C.GLfloat)(coords)) 1252 | } 1253 | func VertexStream3dATI(stream Enum, x Double, y Double, z Double) { 1254 | C.goglVertexStream3dATI((C.GLenum)(stream), (C.GLdouble)(x), (C.GLdouble)(y), (C.GLdouble)(z)) 1255 | } 1256 | func VertexStream3dvATI(stream Enum, coords *Double) { 1257 | C.goglVertexStream3dvATI((C.GLenum)(stream), (*C.GLdouble)(coords)) 1258 | } 1259 | func VertexStream4sATI(stream Enum, x Short, y Short, z Short, w Short) { 1260 | C.goglVertexStream4sATI((C.GLenum)(stream), (C.GLshort)(x), (C.GLshort)(y), (C.GLshort)(z), (C.GLshort)(w)) 1261 | } 1262 | func VertexStream4svATI(stream Enum, coords *Short) { 1263 | C.goglVertexStream4svATI((C.GLenum)(stream), (*C.GLshort)(coords)) 1264 | } 1265 | func VertexStream4iATI(stream Enum, x Int, y Int, z Int, w Int) { 1266 | C.goglVertexStream4iATI((C.GLenum)(stream), (C.GLint)(x), (C.GLint)(y), (C.GLint)(z), (C.GLint)(w)) 1267 | } 1268 | func VertexStream4ivATI(stream Enum, coords *Int) { 1269 | C.goglVertexStream4ivATI((C.GLenum)(stream), (*C.GLint)(coords)) 1270 | } 1271 | func VertexStream4fATI(stream Enum, x Float, y Float, z Float, w Float) { 1272 | C.goglVertexStream4fATI((C.GLenum)(stream), (C.GLfloat)(x), (C.GLfloat)(y), (C.GLfloat)(z), (C.GLfloat)(w)) 1273 | } 1274 | func VertexStream4fvATI(stream Enum, coords *Float) { 1275 | C.goglVertexStream4fvATI((C.GLenum)(stream), (*C.GLfloat)(coords)) 1276 | } 1277 | func VertexStream4dATI(stream Enum, x Double, y Double, z Double, w Double) { 1278 | C.goglVertexStream4dATI((C.GLenum)(stream), (C.GLdouble)(x), (C.GLdouble)(y), (C.GLdouble)(z), (C.GLdouble)(w)) 1279 | } 1280 | func VertexStream4dvATI(stream Enum, coords *Double) { 1281 | C.goglVertexStream4dvATI((C.GLenum)(stream), (*C.GLdouble)(coords)) 1282 | } 1283 | func NormalStream3bATI(stream Enum, nx Byte, ny Byte, nz Byte) { 1284 | C.goglNormalStream3bATI((C.GLenum)(stream), (C.GLbyte)(nx), (C.GLbyte)(ny), (C.GLbyte)(nz)) 1285 | } 1286 | func NormalStream3bvATI(stream Enum, coords *Byte) { 1287 | C.goglNormalStream3bvATI((C.GLenum)(stream), (*C.GLbyte)(coords)) 1288 | } 1289 | func NormalStream3sATI(stream Enum, nx Short, ny Short, nz Short) { 1290 | C.goglNormalStream3sATI((C.GLenum)(stream), (C.GLshort)(nx), (C.GLshort)(ny), (C.GLshort)(nz)) 1291 | } 1292 | func NormalStream3svATI(stream Enum, coords *Short) { 1293 | C.goglNormalStream3svATI((C.GLenum)(stream), (*C.GLshort)(coords)) 1294 | } 1295 | func NormalStream3iATI(stream Enum, nx Int, ny Int, nz Int) { 1296 | C.goglNormalStream3iATI((C.GLenum)(stream), (C.GLint)(nx), (C.GLint)(ny), (C.GLint)(nz)) 1297 | } 1298 | func NormalStream3ivATI(stream Enum, coords *Int) { 1299 | C.goglNormalStream3ivATI((C.GLenum)(stream), (*C.GLint)(coords)) 1300 | } 1301 | func NormalStream3fATI(stream Enum, nx Float, ny Float, nz Float) { 1302 | C.goglNormalStream3fATI((C.GLenum)(stream), (C.GLfloat)(nx), (C.GLfloat)(ny), (C.GLfloat)(nz)) 1303 | } 1304 | func NormalStream3fvATI(stream Enum, coords *Float) { 1305 | C.goglNormalStream3fvATI((C.GLenum)(stream), (*C.GLfloat)(coords)) 1306 | } 1307 | func NormalStream3dATI(stream Enum, nx Double, ny Double, nz Double) { 1308 | C.goglNormalStream3dATI((C.GLenum)(stream), (C.GLdouble)(nx), (C.GLdouble)(ny), (C.GLdouble)(nz)) 1309 | } 1310 | func NormalStream3dvATI(stream Enum, coords *Double) { 1311 | C.goglNormalStream3dvATI((C.GLenum)(stream), (*C.GLdouble)(coords)) 1312 | } 1313 | func ClientActiveVertexStreamATI(stream Enum) { 1314 | C.goglClientActiveVertexStreamATI((C.GLenum)(stream)) 1315 | } 1316 | func VertexBlendEnviATI(pname Enum, param Int) { 1317 | C.goglVertexBlendEnviATI((C.GLenum)(pname), (C.GLint)(param)) 1318 | } 1319 | func VertexBlendEnvfATI(pname Enum, param Float) { 1320 | C.goglVertexBlendEnvfATI((C.GLenum)(pname), (C.GLfloat)(param)) 1321 | } 1322 | func InitAtiDrawBuffers() error { 1323 | var ret C.int 1324 | if ret = C.init_ATI_draw_buffers(); ret != 0 { 1325 | return errors.New("unable to initialize ATI_draw_buffers") 1326 | } 1327 | return nil 1328 | } 1329 | func InitAtiElementArray() error { 1330 | var ret C.int 1331 | if ret = C.init_ATI_element_array(); ret != 0 { 1332 | return errors.New("unable to initialize ATI_element_array") 1333 | } 1334 | return nil 1335 | } 1336 | func InitAtiEnvmapBumpmap() error { 1337 | var ret C.int 1338 | if ret = C.init_ATI_envmap_bumpmap(); ret != 0 { 1339 | return errors.New("unable to initialize ATI_envmap_bumpmap") 1340 | } 1341 | return nil 1342 | } 1343 | func InitAtiFragmentShader() error { 1344 | var ret C.int 1345 | if ret = C.init_ATI_fragment_shader(); ret != 0 { 1346 | return errors.New("unable to initialize ATI_fragment_shader") 1347 | } 1348 | return nil 1349 | } 1350 | func InitAtiMapObjectBuffer() error { 1351 | var ret C.int 1352 | if ret = C.init_ATI_map_object_buffer(); ret != 0 { 1353 | return errors.New("unable to initialize ATI_map_object_buffer") 1354 | } 1355 | return nil 1356 | } 1357 | func InitAtiPnTriangles() error { 1358 | var ret C.int 1359 | if ret = C.init_ATI_pn_triangles(); ret != 0 { 1360 | return errors.New("unable to initialize ATI_pn_triangles") 1361 | } 1362 | return nil 1363 | } 1364 | func InitAtiSeparateStencil() error { 1365 | var ret C.int 1366 | if ret = C.init_ATI_separate_stencil(); ret != 0 { 1367 | return errors.New("unable to initialize ATI_separate_stencil") 1368 | } 1369 | return nil 1370 | } 1371 | func InitAtiVertexArrayObject() error { 1372 | var ret C.int 1373 | if ret = C.init_ATI_vertex_array_object(); ret != 0 { 1374 | return errors.New("unable to initialize ATI_vertex_array_object") 1375 | } 1376 | return nil 1377 | } 1378 | func InitAtiVertexAttribArrayObject() error { 1379 | var ret C.int 1380 | if ret = C.init_ATI_vertex_attrib_array_object(); ret != 0 { 1381 | return errors.New("unable to initialize ATI_vertex_attrib_array_object") 1382 | } 1383 | return nil 1384 | } 1385 | func InitAtiVertexStreams() error { 1386 | var ret C.int 1387 | if ret = C.init_ATI_vertex_streams(); ret != 0 { 1388 | return errors.New("unable to initialize ATI_vertex_streams") 1389 | } 1390 | return nil 1391 | } 1392 | // EOF -------------------------------------------------------------------------------- /download.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The GoGL Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE.mkd file. 4 | 5 | package main 6 | 7 | import ( 8 | "fmt" 9 | "io/ioutil" 10 | "net/http" 11 | "os" 12 | "path/filepath" 13 | ) 14 | 15 | const ( 16 | KhronosRegistryBaseURL = "https://www.opengl.org/registry/api" 17 | AlfonseSpecsBaseURL = "https://bitbucket.org/alfonse/gl-xml-specs/raw/tip/glspecs" 18 | OpenGLEnumSpecFile = "enum.spec" 19 | OpenGLEnumExtSpecFile = "enumext.spec" 20 | OpenGLSpecFile = "gl.spec" 21 | OpenGLTypeMapFile = "gl.tm" 22 | GLXEnumSpecFile = "glxenum.spec" 23 | GLXEnumExtSpecFile = "glxenumext.spec" 24 | GLXSpecFile = "glx.spec" 25 | GLXExtSpecFile = "glxext.spec" 26 | GLXTypeMapFile = "glx.tm" 27 | WGLEnumSpecFile = "wglenum.spec" 28 | WGLEnumExtSpecFile = "wglenumext.spec" 29 | WGLSpecFile = "wgl.spec" 30 | WGLExtSpecFile = "wglext.spec" 31 | WGLTypeMapFile = "wgl.tm" 32 | ) 33 | 34 | func makeURL(base, file string) string { 35 | return fmt.Sprintf("%s/%s", base, file) 36 | } 37 | 38 | func DownloadFile(baseURL, fileName, outDir string) error { 39 | fullURL := makeURL(baseURL, fileName) 40 | fmt.Printf("Downloading %s ...\n", fullURL) 41 | r, err := http.Get(fullURL) 42 | if err != nil { 43 | return err 44 | } 45 | defer r.Body.Close() 46 | data, err := ioutil.ReadAll(r.Body) 47 | if err != nil { 48 | return err 49 | } 50 | absPath, err := filepath.Abs(outDir) 51 | if err != nil { 52 | return err 53 | } 54 | err = os.MkdirAll(absPath, 0755) 55 | if err != nil { 56 | return err 57 | } 58 | err = ioutil.WriteFile(filepath.Join(absPath, fileName), data, 0644) 59 | if err != nil { 60 | return err 61 | } 62 | return nil 63 | } 64 | 65 | func DownloadOpenGLSpecs(baseURL, outDir string) { 66 | DownloadFile(baseURL, OpenGLEnumExtSpecFile, outDir) 67 | DownloadFile(baseURL, OpenGLSpecFile, outDir) 68 | DownloadFile(baseURL, OpenGLTypeMapFile, outDir) 69 | 70 | DownloadFile(baseURL, GLXEnumExtSpecFile, outDir) 71 | DownloadFile(baseURL, GLXSpecFile, outDir) 72 | DownloadFile(baseURL, GLXExtSpecFile, outDir) 73 | DownloadFile(baseURL, GLXTypeMapFile, outDir) 74 | 75 | DownloadFile(baseURL, WGLEnumExtSpecFile, outDir) 76 | DownloadFile(baseURL, WGLSpecFile, outDir) 77 | DownloadFile(baseURL, WGLExtSpecFile, outDir) 78 | DownloadFile(baseURL, WGLTypeMapFile, outDir) 79 | } 80 | -------------------------------------------------------------------------------- /enumreader.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The GoGL Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE.mkd file. 4 | 5 | package main 6 | 7 | import ( 8 | "bufio" 9 | "fmt" 10 | "io" 11 | "os" 12 | "regexp" 13 | "strings" 14 | ) 15 | 16 | // TODO: better regexps 17 | var ( 18 | enumCommentLineRE = regexp.MustCompile("^#.*") 19 | enumCategoryRE = regexp.MustCompile("^([_0-9A-Za-z]+)[ \\t]+enum:") 20 | enumRE = regexp.MustCompile("^([_0-9A-Za-z]+)[ \\t]*=[ \\t]*([\\-_0-9A-Za-z]+)") 21 | enumPassthruRE = regexp.MustCompile("^passthru:.*") 22 | enumUseRE = regexp.MustCompile("^use[ \\t]+([_0-9A-Za-z]+)[ \\t]+([_0-9A-Za-z]+)") 23 | ) 24 | 25 | func ReadEnumsFromFile(name string) (EnumCategories, error) { 26 | file, err := os.Open(name) 27 | if err != nil { 28 | return nil, err 29 | } 30 | defer file.Close() 31 | return ReadEnums(file) 32 | } 33 | 34 | func ReadEnums(r io.Reader) (EnumCategories, error) { 35 | categories := make(EnumCategories) 36 | deferredUseEnums := make(map[string]map[string]string) 37 | currentCategory := "" 38 | br := bufio.NewReader(r) 39 | 40 | for { 41 | line, err := br.ReadString('\n') 42 | if err == io.EOF { 43 | break 44 | } else if err != nil { 45 | return nil, err 46 | } 47 | line = strings.Trim(line, "\t\n\r ") 48 | 49 | if len(line) == 0 || enumCommentLineRE.MatchString(line) || enumPassthruRE.MatchString(line) { 50 | //fmt.Printf("Empty or comment line %s\n", line) 51 | continue 52 | } 53 | 54 | if category := enumCategoryRE.FindStringSubmatch(line); category != nil { 55 | //fmt.Printf("%v\n", category[1]) 56 | currentCategory = category[1] 57 | categories[currentCategory] = make(Enums) 58 | } else if enum := enumRE.FindStringSubmatch(line); enum != nil { 59 | //fmt.Printf("%v %v\n", enum[1], enum[2]) 60 | if strings.HasPrefix(enum[2], "GL_") { 61 | //fmt.Printf("Lookup %s in %s\n", enum[2][3:], enum[1]) 62 | ok, val := categories.LookUpDefinition(enum[2][3:]) 63 | if ok { 64 | categories[currentCategory][enum[1]] = val 65 | } else { 66 | fmt.Fprintf(os.Stderr, "ERROR: Unable to find %s.\n", enum[2][3:]) 67 | } 68 | } else if strings.HasPrefix(enum[2], "GLX_") { 69 | //fmt.Printf("Lookup %s in %s\n", enum[2][3:], enum[1]) 70 | ok, val := categories.LookUpDefinition(enum[2][4:]) 71 | if ok { 72 | categories[currentCategory][enum[1]] = val 73 | } else { 74 | fmt.Fprintf(os.Stderr, "ERROR: Unable to find %s.\n", enum[2][4:]) 75 | } 76 | } else if strings.HasSuffix(enum[2], "u") { 77 | categories[currentCategory][enum[1]] = enum[2][:len(enum[2])-1] 78 | } else if strings.HasSuffix(enum[2], "ull") { 79 | categories[currentCategory][enum[1]] = enum[2][:len(enum[2])-3] 80 | } else { 81 | categories[currentCategory][enum[1]] = enum[2] 82 | } 83 | } else if use := enumUseRE.FindStringSubmatch(line); use != nil { 84 | //fmt.Printf("%v %v\n", use[1], use[2]) 85 | if deferredUseEnums[currentCategory] == nil { 86 | deferredUseEnums[currentCategory] = make(map[string]string) 87 | } 88 | deferredUseEnums[currentCategory][use[2]] = use[1] 89 | } else { 90 | fmt.Fprintf(os.Stderr, "WARNING: Unable to parse line: '%s' (Ignoring)\n", line) 91 | } 92 | } 93 | 94 | for category, enums := range deferredUseEnums { 95 | for name, referencedCategory := range enums { 96 | if dereference, ok := categories[referencedCategory][name]; ok { 97 | categories[category][name] = dereference 98 | } else if dereference, ok := categories[referencedCategory+"_DEPRECATED"][name]; ok { 99 | categories[category][name] = dereference 100 | } else { 101 | fmt.Fprintf(os.Stderr, "WARNING: Failed to dereference %v: \"use %v %v\"\n", category, referencedCategory, name) 102 | } 103 | } 104 | } 105 | 106 | return categories, nil 107 | } 108 | -------------------------------------------------------------------------------- /enumreader_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The GoGL Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE.mkd file. 4 | 5 | package main 6 | 7 | import ( 8 | "strings" 9 | "testing" 10 | ) 11 | 12 | var testEnumsStr = "###########\n" + 13 | "\n" + 14 | "# comment 1\n" + 15 | " ### comment 2\n" + 16 | " #comment 3\n" + 17 | "cat_1 enum:\n" + 18 | "# comment\n" + 19 | "enum1 = 0x00000100 \n" + 20 | "enum2 = 0x00000200 # comment 2\n" + 21 | "passthru: /* passthru comment */\n" + 22 | "enum3 = 6 # comment 3\n" + 23 | "cat_2 enum:\n" + 24 | "# comment\n" + 25 | "enum1 = 0x00000600 # comment 1\n" + 26 | "enum2 = 0x00000800\n" + 27 | "passthru: /* passthru comment */\n" + 28 | "enum3 = 2 # comment 2\n" + 29 | "cat_3 enum:\n" + 30 | "# comment\n" + 31 | "use cat_2 enum2 # comment 1\n" 32 | 33 | func checkEnum(cat, en, value string, ecats EnumCategories, t *testing.T) { 34 | if enums, ok := ecats[cat]; ok { 35 | if e, ok := enums[en]; ok { 36 | if e.Value == value { 37 | t.Logf("Enum found: %v::%v = %v", cat, en, value) 38 | return 39 | } 40 | t.Errorf("Enums not equal: %v: %v != %v", cat, value, e.Value) 41 | return 42 | } 43 | t.Errorf("Enum not found: %v::%v", cat, en) 44 | return 45 | } 46 | t.Errorf("Category not found: %v", cat) 47 | } 48 | 49 | func TestReadEnums(t *testing.T) { 50 | r := strings.NewReader(testEnumsStr) 51 | e, err := ReadEnums(r) 52 | if err != nil { 53 | t.Fatalf("Read enums failed: %v", err) 54 | } 55 | t.Logf("%v", e) 56 | 57 | if len(e) != 3 { 58 | t.Errorf("Wrong number of categories.") 59 | } 60 | 61 | checkEnum("cat_1", "enum1", "0x00000100", e, t) 62 | checkEnum("cat_1", "enum2", "0x00000200", e, t) 63 | checkEnum("cat_1", "enum3", "6", e, t) 64 | checkEnum("cat_2", "enum1", "0x00000600", e, t) 65 | checkEnum("cat_2", "enum2", "0x00000800", e, t) 66 | checkEnum("cat_2", "enum3", "2", e, t) 67 | checkEnum("cat_3", "enum2", "0x00000800", e, t) 68 | } 69 | -------------------------------------------------------------------------------- /examples/gopher/README.md: -------------------------------------------------------------------------------- 1 | Spinning Gopher 2 | =============== 3 | 4 | Simple test program for GoGL. 5 | 6 | ### Linux ### 7 | 8 | ![gopherlinux](https://github.com/chsc/gogl/raw/master/examples/gopher/gopher_linux.png) 9 | 10 | ### Windows ### 11 | 12 | ![gopherwindows](https://github.com/chsc/gogl/raw/master/examples/gopher/gopher_windows.png) 13 | -------------------------------------------------------------------------------- /examples/gopher/gopher.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "bytes" 5 | "errors" 6 | "fmt" 7 | gl "github.com/chsc/gogl/gl21" 8 | "github.com/jteeuwen/glfw" 9 | "image" 10 | "image/png" 11 | "io" 12 | "os" 13 | ) 14 | 15 | const ( 16 | Title = "Spinning Gopher" 17 | Width = 640 18 | Height = 480 19 | ) 20 | 21 | var ( 22 | texture gl.Uint 23 | rotx, roty gl.Float 24 | ambient []gl.Float = []gl.Float{0.5, 0.5, 0.5, 1} 25 | diffuse []gl.Float = []gl.Float{1, 1, 1, 1} 26 | lightpos []gl.Float = []gl.Float{-5, 5, 10, 0} 27 | ) 28 | 29 | func main() { 30 | if err := glfw.Init(); err != nil { 31 | fmt.Fprintf(os.Stderr, "glfw: %s\n", err) 32 | return 33 | } 34 | defer glfw.Terminate() 35 | 36 | glfw.OpenWindowHint(glfw.WindowNoResize, 1) 37 | 38 | if err := glfw.OpenWindow(Width, Height, 0, 0, 0, 0, 16, 0, glfw.Windowed); err != nil { 39 | fmt.Fprintf(os.Stderr, "glfw: %s\n", err) 40 | return 41 | } 42 | defer glfw.CloseWindow() 43 | 44 | glfw.SetSwapInterval(1) 45 | glfw.SetWindowTitle(Title) 46 | 47 | if err := gl.Init(); err != nil { 48 | fmt.Fprintf(os.Stderr, "gl: %s\n", err) 49 | } 50 | 51 | if err := initScene(); err != nil { 52 | fmt.Fprintf(os.Stderr, "init: %s\n", err) 53 | return 54 | } 55 | defer destroyScene() 56 | 57 | for glfw.WindowParam(glfw.Opened) == 1 { 58 | drawScene() 59 | glfw.SwapBuffers() 60 | } 61 | } 62 | 63 | func createTexture(r io.Reader) (textureId gl.Uint, err error) { 64 | img, err := png.Decode(r) 65 | if err != nil { 66 | return 0, err 67 | } 68 | 69 | rgbaImg, ok := img.(*image.NRGBA) 70 | if !ok { 71 | return 0, errors.New("texture must be an NRGBA image") 72 | } 73 | 74 | gl.GenTextures(1, &textureId) 75 | gl.BindTexture(gl.TEXTURE_2D, textureId) 76 | gl.TexParameterf(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR) 77 | gl.TexParameterf(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR) 78 | 79 | // flip image: first pixel is lower left corner 80 | imgWidth, imgHeight := img.Bounds().Dx(), img.Bounds().Dy() 81 | data := make([]byte, imgWidth * imgHeight * 4) 82 | lineLen := imgWidth * 4 83 | dest := len(data)-lineLen 84 | for src := 0; src < len(rgbaImg.Pix); src+=rgbaImg.Stride { 85 | copy(data[dest:dest+lineLen], rgbaImg.Pix[src:src+rgbaImg.Stride]) 86 | dest-=lineLen 87 | } 88 | gl.TexImage2D(gl.TEXTURE_2D, 0, 4, gl.Sizei(imgWidth), gl.Sizei(imgHeight), 0, gl.RGBA, gl.UNSIGNED_BYTE, gl.Pointer(&data[0])) 89 | 90 | return textureId, nil 91 | } 92 | 93 | func createTextureFromBytes(data []byte) (gl.Uint, error) { 94 | r := bytes.NewBuffer(data) 95 | return createTexture(r) 96 | } 97 | 98 | func initScene() (err error) { 99 | gl.Enable(gl.TEXTURE_2D) 100 | gl.Enable(gl.DEPTH_TEST) 101 | gl.Enable(gl.LIGHTING) 102 | 103 | gl.ClearColor(0.5, 0.5, 0.5, 0.0) 104 | gl.ClearDepth(1) 105 | gl.DepthFunc(gl.LEQUAL) 106 | 107 | gl.Lightfv(gl.LIGHT0, gl.AMBIENT, &ambient[0]) 108 | gl.Lightfv(gl.LIGHT0, gl.DIFFUSE, &diffuse[0]) 109 | gl.Lightfv(gl.LIGHT0, gl.POSITION, &lightpos[0]) 110 | gl.Enable(gl.LIGHT0) 111 | 112 | gl.Viewport(0, 0, Width, Height) 113 | gl.MatrixMode(gl.PROJECTION) 114 | gl.LoadIdentity() 115 | gl.Frustum(-1, 1, -1, 1, 1.0, 10.0) 116 | gl.MatrixMode(gl.MODELVIEW) 117 | gl.LoadIdentity() 118 | 119 | texture, err = createTextureFromBytes(gopher_png[:]) 120 | return 121 | } 122 | 123 | func destroyScene() { 124 | gl.DeleteTextures(1, &texture) 125 | } 126 | 127 | func drawScene() { 128 | gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT) 129 | 130 | gl.MatrixMode(gl.MODELVIEW) 131 | gl.LoadIdentity() 132 | gl.Translatef(0, 0, -3.0) 133 | gl.Rotatef(rotx, 1, 0, 0) 134 | gl.Rotatef(roty, 0, 1, 0) 135 | 136 | rotx += 0.5 137 | roty += 0.5 138 | 139 | gl.BindTexture(gl.TEXTURE_2D, texture) 140 | 141 | gl.Color4f(1, 1, 1, 1) 142 | 143 | gl.Begin(gl.QUADS) 144 | 145 | gl.Normal3f(0, 0, 1) 146 | gl.TexCoord2f(0, 0) 147 | gl.Vertex3f(-1, -1, 1) 148 | gl.TexCoord2f(1, 0) 149 | gl.Vertex3f(1, -1, 1) 150 | gl.TexCoord2f(1, 1) 151 | gl.Vertex3f(1, 1, 1) 152 | gl.TexCoord2f(0, 1) 153 | gl.Vertex3f(-1, 1, 1) 154 | 155 | gl.Normal3f(0, 0, -1) 156 | gl.TexCoord2f(1, 0) 157 | gl.Vertex3f(-1, -1, -1) 158 | gl.TexCoord2f(1, 1) 159 | gl.Vertex3f(-1, 1, -1) 160 | gl.TexCoord2f(0, 1) 161 | gl.Vertex3f(1, 1, -1) 162 | gl.TexCoord2f(0, 0) 163 | gl.Vertex3f(1, -1, -1) 164 | 165 | gl.Normal3f(0, 1, 0) 166 | gl.TexCoord2f(0, 1) 167 | gl.Vertex3f(-1, 1, -1) 168 | gl.TexCoord2f(0, 0) 169 | gl.Vertex3f(-1, 1, 1) 170 | gl.TexCoord2f(1, 0) 171 | gl.Vertex3f(1, 1, 1) 172 | gl.TexCoord2f(1, 1) 173 | gl.Vertex3f(1, 1, -1) 174 | 175 | gl.Normal3f(0, -1, 0) 176 | gl.TexCoord2f(1, 1) 177 | gl.Vertex3f(-1, -1, -1) 178 | gl.TexCoord2f(0, 1) 179 | gl.Vertex3f(1, -1, -1) 180 | gl.TexCoord2f(0, 0) 181 | gl.Vertex3f(1, -1, 1) 182 | gl.TexCoord2f(1, 0) 183 | gl.Vertex3f(-1, -1, 1) 184 | 185 | gl.Normal3f(1, 0, 0) 186 | gl.TexCoord2f(1, 0) 187 | gl.Vertex3f(1, -1, -1) 188 | gl.TexCoord2f(1, 1) 189 | gl.Vertex3f(1, 1, -1) 190 | gl.TexCoord2f(0, 1) 191 | gl.Vertex3f(1, 1, 1) 192 | gl.TexCoord2f(0, 0) 193 | gl.Vertex3f(1, -1, 1) 194 | 195 | gl.Normal3f(-1, 0, 0) 196 | gl.TexCoord2f(0, 0) 197 | gl.Vertex3f(-1, -1, -1) 198 | gl.TexCoord2f(1, 0) 199 | gl.Vertex3f(-1, -1, 1) 200 | gl.TexCoord2f(1, 1) 201 | gl.Vertex3f(-1, 1, 1) 202 | gl.TexCoord2f(0, 1) 203 | gl.Vertex3f(-1, 1, -1) 204 | 205 | gl.End() 206 | } 207 | -------------------------------------------------------------------------------- /examples/gopher/gopher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chsc/gogl/c411acc846b6df1439cd317439b6392db6c3667d/examples/gopher/gopher.png -------------------------------------------------------------------------------- /examples/gopher/gopher_linux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chsc/gogl/c411acc846b6df1439cd317439b6392db6c3667d/examples/gopher/gopher_linux.png -------------------------------------------------------------------------------- /examples/gopher/gopher_windows.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chsc/gogl/c411acc846b6df1439cd317439b6392db6c3667d/examples/gopher/gopher_windows.png -------------------------------------------------------------------------------- /funcreader.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The GoGL Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE.mkd file. 4 | 5 | package main 6 | 7 | import ( 8 | "bufio" 9 | "fmt" 10 | "io" 11 | "os" 12 | "regexp" 13 | "strings" 14 | ) 15 | 16 | var ( 17 | funcCommentLineRE = regexp.MustCompile("^#") 18 | funcRE = regexp.MustCompile("^(\\w+)\\([\\w\\s,]*\\)") 19 | funcReturnRE = regexp.MustCompile("^return\\s+(\\w+)") 20 | funcParamRE = regexp.MustCompile("^param\\s+(\\w+)\\s+(\\w+)\\s+(in|out)\\s+(array|value|reference)") 21 | funcVectorEquivRE = regexp.MustCompile("^vectorequiv\\s+(\\w+)") 22 | funcGlxVectorEquivRE = regexp.MustCompile("^glxvectorequiv\\s+(\\w+)") 23 | funcCategoryRE = regexp.MustCompile("^category\\s+(\\w+)") 24 | funcSubCategoryRE = regexp.MustCompile("^subcategory\\s+(\\w+)") 25 | funcVersionRE = regexp.MustCompile("^version\\s+([0-9]+)\\.([0-9]+)") 26 | funcDeprecatedRE = regexp.MustCompile("^deprecated\\s+([0-9]+)\\.([0-9]+)") 27 | funcOffsetRE = regexp.MustCompile("^offset\\s+([0-9\\*\\?]+)") 28 | funcGlxRopCodeRE = regexp.MustCompile("^glxropcode\\s+([0-9\\*\\?]+)") 29 | funcGlxSingleRE = regexp.MustCompile("^glxsingle\\s+([0-9\\?\\*]+)") 30 | funcWglFlagsRE = regexp.MustCompile("^wglflags(\\s+([\\w\\*\\- ]+))") 31 | funcGlxFlagsRE = regexp.MustCompile("^glxflags(\\s+([\\w\\*\\- ]+))") 32 | funcDlFlagsRE = regexp.MustCompile("^dlflags\\s+([\\w\\*\\- ]+)") 33 | funcGlfFlagsRE = regexp.MustCompile("^glfflags\\s+([\\w\\*\\- ]+)") 34 | funcGlxVendorPrivRE = regexp.MustCompile("^glxvendorpriv\\s+([0-9\\?]+)") 35 | funcGlextMaskRE = regexp.MustCompile("^glextmask\\s+(\\w+)") 36 | funcExtensionRE = regexp.MustCompile("^extension$|^extension\\s+([\\w\\- ]*)") 37 | funcAliasRE = regexp.MustCompile("^alias\\s+(\\w+)") 38 | funcBeginEndRE = regexp.MustCompile("^beginend\\s+([\\w\\*\\-]+)") 39 | funcAllCategoriesRE = regexp.MustCompile("^category:\\s*([\\w ]+)") 40 | funcAllVersionsRE = regexp.MustCompile("^version:\\s*([0-9\\. ]+)") 41 | funcAllDeprVersionsRE = regexp.MustCompile("^deprecated:\\s*([0-9\\. ]+)") 42 | funcPassthruRE = regexp.MustCompile("^passthru:\\s*(.*)") 43 | funcNewCategoryRE = regexp.MustCompile("^newcategory:\\s*(\\w+)") 44 | //funcIgnoreRE = regexp.MustCompile("^[a-z\\-]+:.*") 45 | ) 46 | 47 | func ReadFunctionsFromFiles(files []string) (FunctionCategories, *FunctionsInfo, error) { 48 | var finfo *FunctionsInfo = nil 49 | allFuncts := make(FunctionCategories) 50 | for _, file := range files { 51 | functs, info, err := ReadFunctionsFromFile(file) 52 | if err != nil { 53 | return nil, nil, err 54 | } 55 | for k, v := range functs { 56 | allFuncts[k] = v 57 | } 58 | if finfo == nil { 59 | finfo = info 60 | } else { 61 | finfo.Versions = append(finfo.Versions, info.Versions...) 62 | finfo.DeprecatedVersions = append(finfo.DeprecatedVersions, info.DeprecatedVersions...) 63 | finfo.Categories = append(finfo.Categories, info.Categories...) 64 | for k, v := range info.Passthru { 65 | finfo.Passthru[k] = append(finfo.Passthru[k], v...) 66 | } 67 | 68 | } 69 | } 70 | return allFuncts, finfo, nil 71 | } 72 | 73 | func ReadFunctionsFromFile(name string) (FunctionCategories, *FunctionsInfo, error) { 74 | file, err := os.Open(name) 75 | if err != nil { 76 | return nil, nil, err 77 | } 78 | defer file.Close() 79 | return ReadFunctions(file) 80 | } 81 | 82 | func ReadFunctions(r io.Reader) (FunctionCategories, *FunctionsInfo, error) { 83 | var currentFunction *Function = nil 84 | currentCategory := "global" 85 | functions := make(FunctionCategories) 86 | finfo := &FunctionsInfo{make([]Version, 0, 8), make([]Version, 0, 8), make([]string, 0, 8), make(map[string][]string)} 87 | 88 | br := bufio.NewReader(r) 89 | 90 | for { 91 | line, err := br.ReadString('\n') 92 | if err == io.EOF { 93 | break 94 | } else if err != nil { 95 | return nil, nil, err 96 | } 97 | line = strings.Trim(line, "\t\n\r ") 98 | 99 | if len(line) == 0 || enumCommentLineRE.MatchString(line) { 100 | //fmt.Printf("Empty or comment line %s\n", line) 101 | continue 102 | } 103 | 104 | if f := funcRE.FindStringSubmatch(line); f != nil { 105 | currentFunction = new(Function) 106 | currentFunction.Name = f[1] 107 | currentFunction.Parameters = make([]Parameter, 0, 4) 108 | } else if ret := funcReturnRE.FindStringSubmatch(line); ret != nil { 109 | currentFunction.Return = ret[1] 110 | } else if param := funcParamRE.FindStringSubmatch(line); param != nil { 111 | out := false 112 | if param[3] == "out" { 113 | out = true 114 | } 115 | modifier := ParamModifierValue 116 | if param[4] == "array" { 117 | modifier = ParamModifierArray 118 | } else if param[4] == "reference" { 119 | modifier = ParamModifierReference 120 | } 121 | currentFunction.Parameters = append(currentFunction.Parameters, Parameter{param[1], param[2], out, modifier}) 122 | } else if category := funcCategoryRE.FindStringSubmatch(line); category != nil { 123 | currentCategory = category[1] 124 | currentFunction.Category = currentCategory 125 | if functions[currentCategory] == nil { 126 | functions[currentCategory] = make([]*Function, 0, 4) 127 | } 128 | functions[currentCategory] = append(functions[currentCategory], currentFunction) 129 | } else if subcategory := funcSubCategoryRE.FindStringSubmatch(line); subcategory != nil { 130 | currentFunction.SubCategory = subcategory[1] 131 | } else if version := funcVersionRE.FindStringSubmatch(line); version != nil { 132 | v, err := MakeVersionFromMajorMinorString(version[1], version[2]) 133 | if err != nil { 134 | return functions, finfo, fmt.Errorf("Unable to parse version: '%s'", line) 135 | } 136 | currentFunction.Version = v 137 | } else if deprecated := funcDeprecatedRE.FindStringSubmatch(line); deprecated != nil { 138 | v, err := MakeVersionFromMajorMinorString(deprecated[1], deprecated[2]) 139 | if err != nil { 140 | return functions, finfo, fmt.Errorf("Unable to parse version: '%s'", line) 141 | } 142 | currentFunction.DeprecatedVersion = v 143 | } else if offset := funcOffsetRE.FindStringSubmatch(line); offset != nil { 144 | currentFunction.Offset = offset[1] 145 | } else if glxropcode := funcGlxRopCodeRE.FindStringSubmatch(line); glxropcode != nil { 146 | currentFunction.GlxRopCode = glxropcode[1] 147 | } else if glxsingle := funcGlxSingleRE.FindStringSubmatch(line); glxsingle != nil { 148 | currentFunction.GlxSingle = glxsingle[1] 149 | } else if wglflags := funcWglFlagsRE.FindStringSubmatch(line); wglflags != nil { 150 | currentFunction.WglFlags = wglflags[1] 151 | } else if glxflags := funcGlxFlagsRE.FindStringSubmatch(line); glxflags != nil { 152 | currentFunction.GlxFlags = glxflags[1] 153 | } else if dlflags := funcDlFlagsRE.FindStringSubmatch(line); dlflags != nil { 154 | currentFunction.DlFlags = dlflags[1] 155 | } else if glfflags := funcGlfFlagsRE.FindStringSubmatch(line); glfflags != nil { 156 | currentFunction.GlfFlags = glfflags[1] 157 | } else if glxvendorpriv := funcGlxVendorPrivRE.FindStringSubmatch(line); glxvendorpriv != nil { 158 | currentFunction.GlxVendorPriv = glxvendorpriv[1] 159 | } else if glextmask := funcGlextMaskRE.FindStringSubmatch(line); glextmask != nil { 160 | currentFunction.GlextMask = glextmask[1] 161 | } else if extension := funcExtensionRE.FindStringSubmatch(line); extension != nil { 162 | if len(extension) >= 2 { 163 | currentFunction.Extension = extension[1] 164 | } 165 | } else if vectorequiv := funcVectorEquivRE.FindStringSubmatch(line); vectorequiv != nil { 166 | currentFunction.VectorEquiv = vectorequiv[1] 167 | } else if glxvectorequiv := funcGlxVectorEquivRE.FindStringSubmatch(line); glxvectorequiv != nil { 168 | currentFunction.GlxVectorEquiv = glxvectorequiv[1] 169 | } else if alias := funcAliasRE.FindStringSubmatch(line); alias != nil { 170 | currentFunction.Alias = alias[1] 171 | } else if beginend := funcBeginEndRE.FindStringSubmatch(line); beginend != nil { 172 | currentFunction.BeginEnd = beginend[1] 173 | } else if allVersions := funcAllVersionsRE.FindStringSubmatch(line); allVersions != nil { 174 | split := strings.Split(allVersions[1], " ") 175 | for _, verString := range split { 176 | v, err := MakeVersionFromString(verString) 177 | if err != nil { 178 | return functions, finfo, fmt.Errorf("Unable to parse version: '%s'", line) 179 | } 180 | finfo.Versions = append(finfo.Versions, v) 181 | } 182 | } else if allDeprVersions := funcAllDeprVersionsRE.FindStringSubmatch(line); allDeprVersions != nil { 183 | split := strings.Split(allDeprVersions[1], " ") 184 | for _, verString := range split { 185 | v, err := MakeVersionFromString(verString) 186 | if err != nil { 187 | return functions, finfo, fmt.Errorf("Unable to parse version: '%s'", line) 188 | } 189 | finfo.DeprecatedVersions = append(finfo.DeprecatedVersions, v) 190 | } 191 | } else if allCategories := funcAllCategoriesRE.FindStringSubmatch(line); allCategories != nil { 192 | finfo.Categories = strings.Split(allCategories[1], " ") 193 | } else if passthru := funcPassthruRE.FindStringSubmatch(line); passthru != nil { 194 | if _, ok := finfo.Passthru[currentCategory]; !ok { 195 | finfo.Passthru[currentCategory] = make([]string, 0, 8) 196 | } 197 | finfo.Passthru[currentCategory] = append(finfo.Passthru[currentCategory], passthru[1]) 198 | } else if newcategory := funcNewCategoryRE.FindStringSubmatch(line); newcategory != nil { 199 | currentCategory = newcategory[1] 200 | functions[currentCategory] = make([]*Function, 0) 201 | //} else if funcIgnoreRE.MatchString(line) { 202 | // // ignore 203 | } else { 204 | fmt.Fprintf(os.Stderr, "WARNING: Unable to parse line '%s' (Ignoring)\n", line) 205 | //return functions, finfo, fmt.Errorf("Unable to parse line: '%s'", line) 206 | } 207 | } 208 | 209 | // HACK: This is really ugly: 210 | // Some ARB extensions are now part of the GL core (starting from version 3.0). 211 | // Parse the passthru C comments for every "VERSION_*" category. 212 | // If we found an extension in the comment -> add them to a version category. 213 | for cat, pts := range finfo.Passthru { 214 | if strings.HasPrefix(cat, "VERSION") { 215 | for _, pt := range pts { 216 | strippedCat := strings.Split(strings.Trim(pt, "\t */"), " ")[0] 217 | if foundFuncts, ok := functions[strippedCat]; ok { 218 | fmt.Printf("Adding extension %s to %s\n", strippedCat, cat) 219 | newFuncts := make([]*Function, 0, len(foundFuncts)) 220 | for _, f := range foundFuncts { 221 | // copy function and set the new category 222 | nf := *f 223 | nf.Category = cat 224 | newFuncts = append(newFuncts, &nf) 225 | } 226 | functions[cat] = append(functions[cat], newFuncts...) 227 | } 228 | } 229 | } 230 | } 231 | 232 | return functions, finfo, nil 233 | } 234 | -------------------------------------------------------------------------------- /funcreader_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The GoGL Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE.mkd file. 4 | 5 | package main 6 | 7 | import ( 8 | "reflect" 9 | "strings" 10 | "testing" 11 | ) 12 | 13 | var testFuntionsStr = "###########\n" + 14 | "\n" + 15 | "# comment 1\n" + 16 | " ### comment 2\n" + 17 | " #comment 3\n" + 18 | "version: 1.0 1.1 4.2\n" + 19 | "# comment\n" + 20 | "Foo1(p1, p2)\n" + 21 | " return void\n" + 22 | " param p1 type1 in value\n" + 23 | " param p2 type2 in array\n" + 24 | " category cat_1 # comment\n" + 25 | " version 1.0\n" + 26 | " glxropcode 85\n" + 27 | " offset 158\n" + 28 | "\n" + 29 | "Foo2(p1)\n" + 30 | " return void\n" + 31 | " param p1 type3 out value\n" + 32 | " param p2 type4 out array\n" + 33 | " category cat_2 # comment\n" + 34 | " version 2.1\n" + 35 | " glxropcode 95\n" + 36 | " offset 168\n" 37 | 38 | func checkFunc(f *Function, fcats FunctionCategories, t *testing.T) { 39 | if functions, ok := fcats[f.Category]; ok { 40 | if foo := functions.Find(f.Name); foo != nil { 41 | if reflect.DeepEqual(foo, f) { 42 | t.Logf("Function equal: %v::%v = %v", f.Category, f.Name, f) 43 | return 44 | } 45 | t.Errorf("Functions not equal: %v: \n%v\n!=\n%v", f.Category, foo, f) 46 | return 47 | } 48 | t.Errorf("Function not found: %v::%v", f.Category, f.Name) 49 | return 50 | } 51 | t.Errorf("Category not found: %v", f.Category) 52 | } 53 | 54 | func TestReadFunctions(t *testing.T) { 55 | r := strings.NewReader(testFuntionsStr) 56 | f, v, err := ReadFunctions(r) 57 | if err != nil { 58 | t.Fatalf("Read functions failed: %v", err) 59 | } 60 | t.Logf("%v", f) 61 | t.Logf("%v", v) 62 | 63 | if len(f) != 2 { 64 | t.Errorf("Wrong number of categories.") 65 | } 66 | 67 | f1 := new(Function) 68 | f1.Name = "Foo1" 69 | f1.Parameters = []Parameter{{"p1", "type1", false, false}, {"p2", "type2", false, true}} 70 | f1.Return = "void" 71 | f1.Version = Version{1, 0} 72 | f1.DeprecatedVersion = Version{0, 0} 73 | f1.Category = "cat_1" 74 | f1.GlxRopCode = "85" 75 | f1.Offset = "158" 76 | checkFunc(f1, f, t) 77 | 78 | f2 := new(Function) 79 | f2.Name = "Foo2" 80 | f2.Parameters = []Parameter{{"p1", "type3", true, false}, {"p2", "type4", true, true}} 81 | f2.Return = "void" 82 | f2.Version = Version{2, 1} 83 | f2.DeprecatedVersion = Version{0, 0} 84 | f2.Category = "cat_2" 85 | f2.GlxRopCode = "95" 86 | f2.Offset = "168" 87 | checkFunc(f2, f, t) 88 | 89 | // TODO: add more tests: flags, categories ... 90 | } 91 | -------------------------------------------------------------------------------- /generator.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The GoGL Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE.mkd file. 4 | 5 | package main 6 | 7 | import ( 8 | "fmt" 9 | "io" 10 | "os" 11 | "path/filepath" 12 | "sort" 13 | "strings" 14 | ) 15 | 16 | func GeneratePackages(packages Packages, functsInfo *FunctionsInfo, typeMap TypeMap, prefix string) error { 17 | for packageName, pak := range packages { 18 | fmt.Printf("Generating package %s ...\n", packageName) 19 | if err := generatePackage(packageName, pak, functsInfo, typeMap, prefix); err != nil { 20 | return err 21 | } 22 | } 23 | return nil 24 | } 25 | 26 | func generatePackage(packageName string, pak *Package, functsInfo *FunctionsInfo, typeMap TypeMap, prefix string) error { 27 | absPath, err := filepath.Abs(packageName) 28 | if err != nil { 29 | return err 30 | } 31 | err = os.MkdirAll(absPath, 0755) 32 | if err != nil { 33 | return err 34 | } 35 | w, err := os.Create(filepath.Join(absPath, fmt.Sprintf("%s.go", packageName))) 36 | if err != nil { 37 | return err 38 | } 39 | defer w.Close() 40 | return writePackage(w, packageName, pak, functsInfo, typeMap, prefix) 41 | } 42 | 43 | func writePackage(w io.Writer, packageName string, pak *Package, functsInfo *FunctionsInfo, typeMap TypeMap, prefix string) error { 44 | highestMajorVersion := -1 45 | isGLPackage := false 46 | 47 | if strings.HasPrefix(packageName, "gl") && !strings.HasPrefix(packageName, "glx") { 48 | isGLPackage = true 49 | } 50 | 51 | fmt.Fprintf(w, "// Automatically generated OpenGL binding.\n// \n") 52 | fmt.Fprintf(w, "// Categories in this package: \n// \n") 53 | 54 | sortedFunctionCategories := make([]string, len(pak.Functions)) 55 | i := 0 56 | for k, _ := range pak.Functions { 57 | sortedFunctionCategories[i] = k 58 | i++ 59 | } 60 | sort.Strings(sortedFunctionCategories) 61 | 62 | sortedEnumCategories := make([]string, len(pak.Enums)) 63 | i = 0 64 | for k, _ := range pak.Enums { 65 | sortedEnumCategories[i] = k 66 | i++ 67 | } 68 | sort.Strings(sortedEnumCategories) 69 | 70 | for _, cat := range sortedFunctionCategories { 71 | pc, _ := ParseCategoryString(cat) 72 | switch pc.Type { 73 | case CategoryExtension: 74 | fmt.Fprintf(w, "// %s: %s\n// \n", cat, MakeExtensionSpecDocUrl(pc.Vendor, pc.Name)) 75 | case CategoryVersion: 76 | fmt.Fprintf(w, "// %s\n// \n", cat) 77 | if pc.Version.Major > highestMajorVersion { 78 | highestMajorVersion = pc.Version.Major 79 | } 80 | case CategoryDepVersion: 81 | fmt.Fprintf(w, "// %s\n// \n", cat) 82 | } 83 | } 84 | if highestMajorVersion > 0 { 85 | fmt.Fprintf(w, "// %s\n// \n", MakeGLDocUrl(highestMajorVersion)) 86 | } 87 | fmt.Fprintf(w, "package %s\n\n", packageName) 88 | 89 | fmt.Fprintf(w, "// #cgo darwin LDFLAGS: -framework OpenGL\n") 90 | fmt.Fprintf(w, "// #cgo linux LDFLAGS: -lGL\n") 91 | fmt.Fprintf(w, "// #cgo windows LDFLAGS: -lopengl32\n// \n") 92 | 93 | fmt.Fprintf(w, "// #include \n") 94 | fmt.Fprintf(w, "// #if defined(__APPLE__)\n") 95 | fmt.Fprintf(w, "// #include \n") 96 | fmt.Fprintf(w, "// #elif defined(_WIN32)\n") 97 | fmt.Fprintf(w, "// #define WIN32_LEAN_AND_MEAN 1\n") 98 | fmt.Fprintf(w, "// #include \n") 99 | fmt.Fprintf(w, "// #else\n") 100 | fmt.Fprintf(w, "// #include \n") 101 | fmt.Fprintf(w, "// #include \n") 102 | fmt.Fprintf(w, "// #endif\n// \n") 103 | 104 | fmt.Fprintf(w, "// #ifndef APIENTRY\n") 105 | fmt.Fprintf(w, "// #define APIENTRY\n") 106 | fmt.Fprintf(w, "// #endif\n") 107 | fmt.Fprintf(w, "// #ifndef APIENTRYP\n") 108 | fmt.Fprintf(w, "// #define APIENTRYP APIENTRY *\n") 109 | fmt.Fprintf(w, "// #endif\n") 110 | fmt.Fprintf(w, "// #ifndef GLAPI\n") 111 | fmt.Fprintf(w, "// #define GLAPI extern\n") 112 | fmt.Fprintf(w, "// #endif\n// \n") 113 | 114 | fmt.Fprintf(w, "// typedef unsigned int GLenum;\n") 115 | fmt.Fprintf(w, "// typedef unsigned char GLboolean;\n") 116 | fmt.Fprintf(w, "// typedef unsigned int GLbitfield;\n") 117 | fmt.Fprintf(w, "// typedef signed char GLbyte;\n") 118 | fmt.Fprintf(w, "// typedef short GLshort;\n") 119 | fmt.Fprintf(w, "// typedef int GLint;\n") 120 | fmt.Fprintf(w, "// typedef int GLsizei;\n") 121 | fmt.Fprintf(w, "// typedef unsigned char GLubyte;\n") 122 | fmt.Fprintf(w, "// typedef unsigned short GLushort;\n") 123 | fmt.Fprintf(w, "// typedef unsigned int GLuint;\n") 124 | fmt.Fprintf(w, "// typedef unsigned short GLhalf;\n") 125 | fmt.Fprintf(w, "// typedef float GLfloat;\n") 126 | fmt.Fprintf(w, "// typedef float GLclampf;\n") 127 | fmt.Fprintf(w, "// typedef double GLdouble;\n") 128 | fmt.Fprintf(w, "// typedef double GLclampd;\n") 129 | fmt.Fprintf(w, "// typedef void GLvoid;\n// \n") 130 | 131 | for _, passthrus := range functsInfo.Passthru["global"] { 132 | fmt.Fprintf(w, "// %s\n", passthrus) 133 | } 134 | 135 | fmt.Fprintf(w, "// #ifdef _WIN32\n") 136 | fmt.Fprintf(w, "// static HMODULE opengl32 = NULL;\n") 137 | fmt.Fprintf(w, "// #endif\n// \n") 138 | 139 | fmt.Fprintf(w, "// static void* go%sGetProcAddress(const char* name) { \n", prefix) 140 | fmt.Fprintf(w, "// #ifdef __APPLE__\n") 141 | fmt.Fprintf(w, "// return dlsym(RTLD_DEFAULT, name);\n") 142 | fmt.Fprintf(w, "// #elif _WIN32\n") 143 | fmt.Fprintf(w, "// void* pf = wglGetProcAddress((LPCSTR)name);\n") 144 | fmt.Fprintf(w, "// if(pf) {\n") 145 | fmt.Fprintf(w, "// return pf;\n") 146 | fmt.Fprintf(w, "// }\n") 147 | fmt.Fprintf(w, "// if(opengl32 == NULL) {\n") 148 | fmt.Fprintf(w, "// opengl32 = LoadLibraryA(\"opengl32.dll\");\n") 149 | fmt.Fprintf(w, "// }\n") 150 | fmt.Fprintf(w, "// return GetProcAddress(opengl32, (LPCSTR)name);\n") 151 | fmt.Fprintf(w, "// #else\n") 152 | fmt.Fprintf(w, "// return glXGetProcAddress((const GLubyte*)name);\n") 153 | fmt.Fprintf(w, "// #endif\n") 154 | fmt.Fprintf(w, "// }\n// \n") 155 | 156 | if err := writeCFuncDeclarations(w, sortedFunctionCategories, pak.Functions, typeMap, prefix); err != nil { 157 | return err 158 | } 159 | 160 | if err := writeCFuncDefinitions(w, sortedFunctionCategories, pak.Functions, typeMap, prefix); err != nil { 161 | return err 162 | } 163 | 164 | if err := writeCFuncGetProcAddrs(w, sortedFunctionCategories, pak.Functions, prefix); err != nil { 165 | return err 166 | } 167 | 168 | fmt.Fprintf(w, "import \"C\"\n") 169 | fmt.Fprintf(w, "import \"unsafe\"\n") 170 | fmt.Fprintf(w, "import \"errors\"\n\n") 171 | 172 | fmt.Fprintf(w, "type (\n") 173 | fmt.Fprintf(w, " Enum C.GLenum\n") 174 | fmt.Fprintf(w, " Boolean C.GLboolean\n") 175 | fmt.Fprintf(w, " Bitfield C.GLbitfield\n") 176 | fmt.Fprintf(w, " Byte C.GLbyte\n") 177 | fmt.Fprintf(w, " Short C.GLshort\n") 178 | fmt.Fprintf(w, " Int C.GLint\n") 179 | fmt.Fprintf(w, " Sizei C.GLsizei\n") 180 | fmt.Fprintf(w, " Ubyte C.GLubyte\n") 181 | fmt.Fprintf(w, " Ushort C.GLushort\n") 182 | fmt.Fprintf(w, " Uint C.GLuint\n") 183 | fmt.Fprintf(w, " Half C.GLhalf\n") 184 | fmt.Fprintf(w, " Float C.GLfloat\n") 185 | fmt.Fprintf(w, " Clampf C.GLclampf\n") 186 | fmt.Fprintf(w, " Double C.GLdouble\n") 187 | fmt.Fprintf(w, " Clampd C.GLclampd\n") 188 | fmt.Fprintf(w, " Char C.GLchar\n") 189 | fmt.Fprintf(w, " Pointer unsafe.Pointer\n") 190 | fmt.Fprintf(w, " Sync C.GLsync\n") 191 | fmt.Fprintf(w, " Int64 C.GLint64\n") 192 | fmt.Fprintf(w, " Uint64 C.GLuint64\n") 193 | fmt.Fprintf(w, " Intptr C.GLintptr\n") 194 | fmt.Fprintf(w, " Sizeiptr C.GLsizeiptr\n") 195 | fmt.Fprintf(w, ")\n\n") 196 | 197 | writeGoEnumDefinitions(w, sortedEnumCategories, pak.Enums) 198 | 199 | if err := writeGoFuncDefinitions(w, sortedFunctionCategories, pak.Functions, typeMap, highestMajorVersion, prefix); err != nil { 200 | return err 201 | } 202 | 203 | writeGoInitDefinitions(w, sortedFunctionCategories, pak.Functions, isGLPackage) 204 | 205 | if isGLPackage { 206 | writeUtilityFunctions(w) 207 | } 208 | 209 | fmt.Fprintf(w, "// EOF") 210 | 211 | return nil 212 | } 213 | 214 | func writeCFuncDeclarations(w io.Writer, sortedFunctionCategories []string, functions FunctionCategories, typeMap TypeMap, prefix string) error { 215 | for _, cat := range sortedFunctionCategories { 216 | fs := functions[cat] 217 | fmt.Fprintf(w, "// // %s\n", cat) 218 | for _, f := range fs { 219 | if err := writeCFuncDeclaration(w, f, typeMap, prefix, false); err != nil { 220 | return err 221 | } 222 | } 223 | } 224 | fmt.Fprintf(w, "// \n") 225 | return nil 226 | } 227 | 228 | func writeCFuncDeclaration(w io.Writer, f *Function, typeMap TypeMap, prefix string, prototype bool) error { 229 | rtype, err := typeMap.Resolve(f.Return) 230 | if err != nil { 231 | return err 232 | } 233 | if prototype { 234 | fmt.Fprintf(w, "// GLAPI %s APIENTRY %s%s(", rtype, prefix, f.Name) 235 | } else { 236 | fmt.Fprintf(w, "// %s (APIENTRYP ptr%s%s)(", rtype, prefix, f.Name) 237 | } 238 | for i, _ := range f.Parameters { 239 | p := &f.Parameters[i] 240 | ptype, err := typeMap.Resolve(p.Type) 241 | if err != nil { 242 | return err 243 | } 244 | fmt.Fprintf(w, "%s", ptype) 245 | if p.Out || (p.Modifier == ParamModifierReference || p.Modifier == ParamModifierArray) { 246 | fmt.Fprint(w, "*") 247 | } 248 | fmt.Fprintf(w, " %s", p.Name) 249 | if i < len(f.Parameters)-1 { 250 | fmt.Fprintf(w, ", ") 251 | } 252 | } 253 | fmt.Fprintf(w, ");\n") 254 | return nil 255 | } 256 | 257 | func writeCFuncDefinitions(w io.Writer, sortedFunctionCategories []string, functions FunctionCategories, typeMap TypeMap, prefix string) error { 258 | for _, cat := range sortedFunctionCategories { 259 | fs := functions[cat] 260 | fmt.Fprintf(w, "// // %s\n", cat) 261 | for _, f := range fs { 262 | if err := writeCFuncDefinition(w, f, typeMap, prefix, false); err != nil { 263 | return err 264 | } 265 | } 266 | } 267 | fmt.Fprintf(w, "// \n") 268 | return nil 269 | } 270 | 271 | func writeCFuncDefinition(w io.Writer, f *Function, typeMap TypeMap, prefix string, prototype bool) error { 272 | rtype, err := typeMap.Resolve(f.Return) 273 | if err != nil { 274 | return err 275 | } 276 | fmt.Fprintf(w, "// %s go%s%s(", rtype, prefix, f.Name) 277 | for i, _ := range f.Parameters { 278 | p := &f.Parameters[i] 279 | ptype, err := typeMap.Resolve(p.Type) 280 | if err != nil { 281 | return err 282 | } 283 | fmt.Fprintf(w, "%s", ptype) 284 | if p.Out || (p.Modifier == ParamModifierReference || p.Modifier == ParamModifierArray) { 285 | fmt.Fprint(w, "*") 286 | } 287 | fmt.Fprintf(w, " %s", RenameIfReservedWord(p.Name)) 288 | if i < len(f.Parameters)-1 { 289 | fmt.Fprintf(w, ", ") 290 | } 291 | } 292 | fmt.Fprintf(w, ") {\n") 293 | if rtype == "void" || rtype == "VOID" { 294 | fmt.Fprintf(w, "// ") 295 | } else { 296 | fmt.Fprintf(w, "// return ") 297 | } 298 | if prototype { 299 | fmt.Fprintf(w, "%s%s(", prefix, f.Name) 300 | } else { 301 | fmt.Fprintf(w, "(*ptr%s%s)(", prefix, f.Name) 302 | } 303 | for i, _ := range f.Parameters { 304 | p := &f.Parameters[i] 305 | fmt.Fprintf(w, "%s", RenameIfReservedWord(p.Name)) 306 | if i < len(f.Parameters)-1 { 307 | fmt.Fprintf(w, ", ") 308 | } 309 | } 310 | fmt.Fprintf(w, ");\n// }\n") 311 | return nil 312 | } 313 | 314 | func writeCFuncGetProcAddrs(w io.Writer, sortedFunctionCategories []string, functions FunctionCategories, prefix string) error { 315 | for _, cat := range sortedFunctionCategories { 316 | fs := functions[cat] 317 | fmt.Fprintf(w, "// int init_%s() {\n", cat) 318 | for _, f := range fs { 319 | fmt.Fprintf(w, "// ptr%s%s = go%sGetProcAddress(\"%s%s\");\n", prefix, f.Name, prefix, prefix, f.Name) 320 | fmt.Fprintf(w, "// if(ptr%s%s == NULL) return 1;\n", prefix, f.Name) 321 | } 322 | fmt.Fprintf(w, "// \treturn 0;\n") 323 | fmt.Fprintf(w, "// }\n") 324 | } 325 | fmt.Fprintf(w, "// \n") 326 | return nil 327 | } 328 | 329 | func writeGoEnumDefinitions(w io.Writer, sortedEnumCategories []string, enumCats EnumCategories) { 330 | for _, cat := range sortedEnumCategories { 331 | enums := enumCats[cat] 332 | fmt.Fprintf(w, "// %s\n", cat) 333 | fmt.Fprintf(w, "const (\n") 334 | 335 | sortedEnums := make([]string, len(enums)) 336 | i := 0 337 | for k, _ := range enums { 338 | sortedEnums[i] = k 339 | i++ 340 | } 341 | sort.Strings(sortedEnums) 342 | 343 | for _, e := range sortedEnums { 344 | v := enums[e] 345 | if !enumCats.IsAlreadyDefined(e, cat) { 346 | fmt.Fprintf(w, "\t%s = %s\n", CleanEnumName(e), v) 347 | } 348 | } 349 | fmt.Fprintf(w, ")\n") 350 | } 351 | } 352 | 353 | func writeGoFuncDefinitions(w io.Writer, sortedFunctionCategories []string, functions FunctionCategories, typeMap TypeMap, majorVersion int, prefix string) error { 354 | for _, cat := range sortedFunctionCategories { 355 | fs := functions[cat] 356 | fmt.Fprintf(w, "// %s\n\n", cat) 357 | for _, f := range fs { 358 | if err := writeGoFuncDefinition(w, f, typeMap, majorVersion, prefix, false); err != nil { 359 | return err 360 | } 361 | } 362 | } 363 | return nil 364 | } 365 | 366 | func writeGoFuncDefinition(w io.Writer, f *Function, typeMap TypeMap, majorVersion int, prefix string, prototype bool) error { 367 | if majorVersion > 0 { 368 | fmt.Fprintf(w, "// %s\n", MakeFuncDocUrl(majorVersion, f.Name)) 369 | } 370 | fmt.Fprintf(w, "func %s(", f.Name) 371 | for i, _ := range f.Parameters { 372 | p := &f.Parameters[i] 373 | fmt.Fprintf(w, "%s ", RenameIfReservedWord(p.Name)) 374 | ptype, err := typeMap.Resolve(p.Type) 375 | if err != nil { 376 | return err 377 | } 378 | goType, _, err := CTypeToGoType(ptype, p.Out, p.Modifier) 379 | if err != nil { 380 | return err 381 | } 382 | fmt.Fprintf(w, "%s", goType) 383 | if i < len(f.Parameters)-1 { 384 | fmt.Fprintf(w, ", ") 385 | } 386 | } 387 | rtype, err := typeMap.Resolve(f.Return) 388 | if err != nil { 389 | return err 390 | } 391 | goType, _, err := CTypeToGoType(rtype, false, ParamModifierValue) 392 | if err != nil { 393 | return err 394 | } 395 | fmt.Fprintf(w, ") %s {\n", goType) 396 | if rtype == "void" || rtype == "VOID" { 397 | if prototype { 398 | fmt.Fprintf(w, " C.%s%s(", prefix, f.Name) 399 | } else { 400 | fmt.Fprintf(w, " C.go%s%s(", prefix, f.Name) 401 | } 402 | } else { 403 | if prototype { 404 | fmt.Fprintf(w, " return (%s)(C.%s%s(", goType, prefix, f.Name) 405 | } else { 406 | fmt.Fprintf(w, " return (%s)(C.go%s%s(", goType, prefix, f.Name) 407 | } 408 | } 409 | for i, _ := range f.Parameters { 410 | p := &f.Parameters[i] 411 | ptype, err := typeMap.Resolve(p.Type) 412 | if err != nil { 413 | return err 414 | } 415 | _, cgoType, err := CTypeToGoType(ptype, p.Out, p.Modifier) 416 | if err != nil { 417 | return err 418 | } 419 | // HACK: handling pointers to pointers is tricky. We use unsafe.Pointer. Any better solution? 420 | if strings.HasPrefix(cgoType, "**") { 421 | fmt.Fprintf(w, "(%s)(unsafe.Pointer(%s))", cgoType, RenameIfReservedWord(p.Name)) 422 | } else { 423 | fmt.Fprintf(w, "(%s)(%s)", cgoType, RenameIfReservedWord(p.Name)) 424 | } 425 | if i < len(f.Parameters)-1 { 426 | fmt.Fprintf(w, ", ") 427 | } 428 | } 429 | if rtype == "void" || rtype == "VOID" { 430 | fmt.Fprintf(w, ")\n}\n") 431 | } else { 432 | fmt.Fprintf(w, "))\n}\n") 433 | } 434 | return nil 435 | } 436 | 437 | func writeGoInitDefinitions(w io.Writer, sortedFunctionCategories []string, functions FunctionCategories, initAll bool) error { 438 | for _, cat := range sortedFunctionCategories { 439 | fmt.Fprintf(w, "func Init%s() error {\n", GoName(cat)) 440 | fmt.Fprintf(w, "\tvar ret C.int\n") 441 | fmt.Fprintf(w, "\tif ret = C.init_%s(); ret != 0 {\n", cat) 442 | fmt.Fprintf(w, "\t\treturn errors.New(\"unable to initialize %s\")\n", cat) 443 | fmt.Fprintf(w, "\t}\n") 444 | fmt.Fprintf(w, "\treturn nil\n") 445 | fmt.Fprintf(w, "}\n") 446 | } 447 | if initAll { 448 | fmt.Fprintf(w, "func Init() error {\n") 449 | fmt.Fprintf(w, "\tvar err error\n") 450 | for _, cat := range sortedFunctionCategories { 451 | fmt.Fprintf(w, "\tif err = Init%s(); err != nil {\n", GoName(cat)) 452 | fmt.Fprintf(w, "\t\treturn err\n") 453 | fmt.Fprintf(w, "\t}\n") 454 | } 455 | fmt.Fprintf(w, "\treturn nil\n") 456 | fmt.Fprintf(w, "}\n") 457 | } 458 | return nil 459 | } 460 | 461 | func writeUtilityFunctions(w io.Writer) { 462 | fmt.Fprintln(w, `//Go bool to GL boolean. 463 | func GLBool(b bool) Boolean { 464 | if b { 465 | return TRUE 466 | } 467 | return FALSE 468 | } 469 | 470 | // GL boolean to Go bool. 471 | func GoBool(b Boolean) bool { 472 | return b == TRUE 473 | } 474 | 475 | // Go string to GL string. 476 | func GLString(str string) *Char { 477 | return (*Char)(C.CString(str)) 478 | } 479 | 480 | // Allocates a GL string. 481 | func GLStringAlloc(length Sizei) *Char { 482 | return (*Char)(C.malloc(C.size_t(length))) 483 | } 484 | 485 | // Frees GL string. 486 | func GLStringFree(str *Char) { 487 | C.free(unsafe.Pointer(str)) 488 | } 489 | 490 | // GL string (GLchar*) to Go string. 491 | func GoString(str *Char) string { 492 | return C.GoString((*C.char)(str)) 493 | } 494 | 495 | // GL string (GLubyte*) to Go string. 496 | func GoStringUb(str *Ubyte) string { 497 | return C.GoString((*C.char)(unsafe.Pointer(str))) 498 | } 499 | 500 | // GL string (GLchar*) with length to Go string. 501 | func GoStringN(str *Char, length Sizei) string { 502 | return C.GoStringN((*C.char)(str), C.int(length)) 503 | } 504 | 505 | // Converts a list of Go strings to a slice of GL strings. 506 | // Usefull for ShaderSource(). 507 | func GLStringArray(strs ...string) []*Char { 508 | strSlice := make([]*Char, len(strs)) 509 | for i, s := range strs { 510 | strSlice[i] = (*Char)(C.CString(s)) 511 | } 512 | return strSlice 513 | } 514 | 515 | // Free GL string slice allocated by GLStringArray(). 516 | func GLStringArrayFree(strs []*Char) { 517 | for _, s := range strs { 518 | C.free(unsafe.Pointer(s)) 519 | } 520 | } 521 | 522 | // Add offset to a pointer. Usefull for VertexAttribPointer, TexCoordPointer, NormalPointer, ... 523 | func Offset(p Pointer, o uintptr) Pointer { 524 | return Pointer(uintptr(p) + o) 525 | } 526 | `) 527 | } 528 | -------------------------------------------------------------------------------- /group.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The GoGL Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE.mkd file. 4 | 5 | package main 6 | 7 | import ( 8 | "fmt" 9 | "os" 10 | "strings" 11 | ) 12 | 13 | type EnumGroupFunc func(category string) (packageNames []string) 14 | type FunctionGroupFunc func(function *Function) (packageNames []string) 15 | 16 | func GroupEnumsAndFunctions(enums EnumCategories, functions FunctionCategories, sortFuncEnums EnumGroupFunc, sortFuncFuncts FunctionGroupFunc) (packages Packages) { 17 | packages = make(Packages) 18 | for category, catEnums := range enums { 19 | if packageNames := sortFuncEnums(category); packageNames != nil { 20 | for _, packageName := range packageNames { 21 | if p, ok := packages[packageName]; ok { 22 | p.Enums[category] = catEnums 23 | } else { 24 | p := &Package{make(EnumCategories), make(FunctionCategories)} 25 | p.Enums[category] = catEnums 26 | packages[packageName] = p 27 | } 28 | } 29 | } 30 | } 31 | for _, catFunctions := range functions { 32 | for _, function := range catFunctions { 33 | if packageNames := sortFuncFuncts(function); packageNames != nil { 34 | for _, packageName := range packageNames { 35 | if p, ok := packages[packageName]; ok { 36 | if _, ok = p.Functions[function.Category]; ok { 37 | p.Functions[function.Category] = append(p.Functions[function.Category], function) 38 | } else { 39 | p.Functions[function.Category] = []*Function{function} 40 | } 41 | } else { 42 | p := &Package{make(EnumCategories), make(FunctionCategories)} 43 | p.Functions[function.Category] = []*Function{function} 44 | packages[packageName] = p 45 | } 46 | } 47 | } 48 | 49 | } 50 | } 51 | return 52 | } 53 | 54 | // Default grouping function. 55 | // Groups packages by GL versions and vendor extensions: 56 | // EXT, ARB, ATI, NV -> ext, arb, ati, nv package 57 | // VERSION_1_0, VERSION_1_1, VERSION_1_2 -> gl12 58 | 59 | func GroupEnumsByVendorAndVersion(category string, supportedVersions []Version) (packageName []string) { 60 | pc, err := ParseCategoryString(category) 61 | if err != nil { 62 | return nil 63 | } 64 | packages := make([]string, 0, 8) 65 | switch pc.Type { 66 | case CategoryExtension: 67 | packages = append(packages, strings.ToLower(pc.Vendor)) 68 | case CategoryVersion: 69 | for _, ver := range supportedVersions { 70 | if ver.Compare(pc.Version) >= 0 { 71 | //fmt.Println("++", ver, pc) 72 | packages = append(packages, fmt.Sprintf("gl%d%d", ver.Major, ver.Minor)) 73 | packages = append(packages, fmt.Sprintf("gl%d%dc", ver.Major, ver.Minor)) 74 | } 75 | } 76 | case CategoryDepVersion: 77 | fmt.Fprintf(os.Stderr, "Deprecated categories are not longer supported. Update your spec file.") 78 | return nil // not supported anymore, spec outdated 79 | } 80 | return packages 81 | } 82 | 83 | func GroupFunctionsByVendorAndVersion(function *Function, supportedVersions []Version) (packageName []string) { 84 | pc, err := ParseCategoryString(function.Category) 85 | if err != nil { 86 | return nil 87 | } 88 | packages := make([]string, 0, 8) 89 | switch pc.Type { 90 | case CategoryExtension: 91 | packages = append(packages, strings.ToLower(pc.Vendor)) 92 | case CategoryVersion: 93 | if function.DeprecatedVersion.Valid() { // is deprecated 94 | for _, ver := range supportedVersions { 95 | if ver.Compare(pc.Version) >= 0 { 96 | if ver.Compare(function.DeprecatedVersion) < 0 { 97 | packages = append(packages, fmt.Sprintf("gl%d%d", ver.Major, ver.Minor)) 98 | } else { 99 | packages = append(packages, fmt.Sprintf("gl%d%dc", ver.Major, ver.Minor)) 100 | } 101 | } 102 | } 103 | } else { 104 | for _, ver := range supportedVersions { 105 | if ver.Compare(pc.Version) >= 0 { 106 | packages = append(packages, fmt.Sprintf("gl%d%d", ver.Major, ver.Minor)) 107 | packages = append(packages, fmt.Sprintf("gl%d%dc", ver.Major, ver.Minor)) 108 | } 109 | } 110 | 111 | } 112 | case CategoryDepVersion: 113 | fmt.Fprintf(os.Stderr, "Deprecated categories are not longer supported. Update your spec file.") 114 | return nil // not supported anymore, spec outdated 115 | } 116 | return packages 117 | } 118 | 119 | // Put everything into one package. 120 | // E.g. for wgl/glx. 121 | 122 | func GroupAllEnumsIntoOnePackage(category, packageName string) (packageNames []string) { 123 | return []string{packageName} 124 | } 125 | 126 | func GroupAllFunctionsIntoOnePackage(functions *Function, packageName string) (packageNames []string) { 127 | return []string{packageName} 128 | } 129 | -------------------------------------------------------------------------------- /group_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The GoGL Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE.mkd file. 4 | 5 | package main 6 | 7 | import ( 8 | "testing" 9 | ) 10 | 11 | func checkEnumCats(paks Packages, t *testing.T, pak string, cats ...string) { 12 | if p, ok := paks[pak]; ok { 13 | if len(cats) != len(p.Enums) { 14 | t.Errorf("len(cats) != len(p.Enums)") 15 | return 16 | } 17 | for _, c := range cats { 18 | if _, ok := p.Enums[c]; !ok { 19 | t.Errorf("Enum not found: %v::%v", pak, c) 20 | return 21 | } 22 | } 23 | return 24 | } 25 | t.Errorf("Package not found: %v", pak) 26 | } 27 | 28 | func checkFuncCats(paks Packages, t *testing.T, pak string, cats ...string) { 29 | if p, ok := paks[pak]; ok { 30 | if len(cats) != len(p.Functions) { 31 | t.Errorf("len(cats) != len(p.Functions)") 32 | return 33 | } 34 | for _, c := range cats { 35 | if _, ok := p.Functions[c]; !ok { 36 | t.Errorf("Function not found: %v::%v", pak, c) 37 | return 38 | } 39 | } 40 | return 41 | } 42 | t.Errorf("Package not found: %v", pak) 43 | } 44 | 45 | func TestPackageGrouping(t *testing.T) { 46 | e := make(EnumCategories) 47 | f := make(FunctionCategories) 48 | 49 | e["VERSION_1_3"] = Enums{} 50 | e["VERSION_1_3_DEPRECATED"] = Enums{} 51 | 52 | e["VERSION_2_1"] = Enums{} 53 | e["VERSION_2_1_DEPRECATED"] = Enums{} 54 | 55 | e["VERSION_2_3"] = Enums{} 56 | e["VERSION_2_3_DEPRECATED"] = Enums{} 57 | 58 | e["VERSION_3_1"] = Enums{} 59 | 60 | e["EXT_1"] = Enums{} 61 | e["NV_1"] = Enums{} 62 | e["ATI_1"] = Enums{} 63 | 64 | f["EXT_1"] = []*Function{} 65 | f["NV_1"] = []*Function{} 66 | f["ATI_1"] = []*Function{} 67 | 68 | suppV := []Version{{1, 3}, {2, 1}, {2, 3}, {3, 1}} 69 | deprV := []Version{{3, 1}} 70 | 71 | p := GroupEnumsAndFunctions(e, f, 72 | func(category string) (packageNames []string) { 73 | return GroupPackagesByVendorFunc(category, suppV, deprV) 74 | }) 75 | 76 | for n, pa := range p { 77 | t.Logf("%s:\n %s\n", n, pa) 78 | } 79 | 80 | if len(p) != 8 { 81 | t.Errorf("Wrong number of categories.") 82 | } 83 | 84 | checkEnumCats(p, t, "nv", "NV_1") 85 | checkEnumCats(p, t, "ati", "ATI_1") 86 | checkEnumCats(p, t, "ext", "EXT_1") 87 | checkEnumCats(p, t, "gl13", "VERSION_1_3", "VERSION_1_3_DEPRECATED") 88 | checkEnumCats(p, t, "gl21", 89 | "VERSION_1_3", "VERSION_1_3_DEPRECATED", 90 | "VERSION_2_1", "VERSION_2_1_DEPRECATED") 91 | checkEnumCats(p, t, "gl23", 92 | "VERSION_1_3", "VERSION_1_3_DEPRECATED", 93 | "VERSION_2_1", "VERSION_2_1_DEPRECATED", 94 | "VERSION_2_3", "VERSION_2_3_DEPRECATED") 95 | checkEnumCats(p, t, "gl31", 96 | "VERSION_1_3", 97 | "VERSION_2_1", 98 | "VERSION_2_3", 99 | "VERSION_3_1") 100 | checkEnumCats(p, t, "gl31c", 101 | "VERSION_1_3", "VERSION_1_3_DEPRECATED", 102 | "VERSION_2_1", "VERSION_2_1_DEPRECATED", 103 | "VERSION_2_3", "VERSION_2_3_DEPRECATED", 104 | "VERSION_3_1") 105 | 106 | checkFuncCats(p, t, "nv", "NV_1") 107 | checkFuncCats(p, t, "ati", "ATI_1") 108 | checkFuncCats(p, t, "ext", "EXT_1") 109 | } 110 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The GoGL Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE.mkd file. 4 | 5 | package main 6 | 7 | import ( 8 | "flag" 9 | "fmt" 10 | "os" 11 | "path/filepath" 12 | ) 13 | 14 | func generatePackages( 15 | specsDir string, 16 | enumextFile string, 17 | specFiles []string, 18 | typeMapFiles []string, 19 | singlePackage, prefix string) error { 20 | 21 | fmt.Printf("Parsing %s file ...\n", enumextFile) 22 | enumCategories, err := ReadEnumsFromFile(filepath.Join(specsDir, enumextFile)) 23 | if err != nil { 24 | return err 25 | } 26 | 27 | fmt.Printf("Parsing %v files ...\n", typeMapFiles) 28 | tmPaths := make([]string, len(typeMapFiles)) 29 | for i, tmFile := range typeMapFiles { 30 | tmPaths[i] = filepath.Join(specsDir, tmFile) 31 | } 32 | typeMap, err := ReadTypeMapFromFiles(tmPaths) 33 | if err != nil { 34 | return err 35 | } 36 | 37 | fmt.Printf("Parsing %v files ...\n", specFiles) 38 | specPaths := make([]string, len(specFiles)) 39 | for i, specFile := range specFiles { 40 | specPaths[i] = filepath.Join(specsDir, specFile) 41 | } 42 | funcCategories, funcInfo, err := ReadFunctionsFromFiles(specPaths) 43 | if err != nil { 44 | return err 45 | } 46 | 47 | fmt.Printf("Grouping extensions ...\n") 48 | var egf EnumGroupFunc 49 | var fgf FunctionGroupFunc 50 | if len(singlePackage) == 0 { // create multiple packages 51 | egf = func(category string) (packageNames []string) { 52 | return GroupEnumsByVendorAndVersion( 53 | category, 54 | funcInfo.Versions) 55 | } 56 | fgf = func(function *Function) (packageNames []string) { 57 | return GroupFunctionsByVendorAndVersion( 58 | function, 59 | funcInfo.Versions) 60 | } 61 | } else { // create single package 62 | egf = func(category string) (packageNames []string) { 63 | return GroupAllEnumsIntoOnePackage( 64 | category, 65 | singlePackage) 66 | } 67 | fgf = func(function *Function) (packageNames []string) { 68 | return GroupAllFunctionsIntoOnePackage( 69 | function, 70 | singlePackage) 71 | } 72 | } 73 | packages := GroupEnumsAndFunctions(enumCategories, funcCategories, egf, fgf) 74 | 75 | // TODO: This output is temporary for debugging 76 | if false { 77 | fmt.Println("Passthrus:") 78 | for cat, pts := range funcInfo.Passthru { 79 | fmt.Printf(" %s:\n", cat) 80 | for _, pt := range pts { 81 | fmt.Printf(" %s\n", pt) 82 | } 83 | } 84 | } 85 | if false { 86 | fmt.Println("Supported versions:") 87 | fmt.Println(funcInfo.Versions) 88 | fmt.Println("Deprecated versions:") 89 | fmt.Println(funcInfo.DeprecatedVersions) 90 | 91 | fmt.Println("Enums:") 92 | for category, enums := range enumCategories { 93 | fmt.Printf(" %v\n", category) 94 | for _, enum := range enums { 95 | fmt.Printf(" %v\n", enum) 96 | } 97 | } 98 | fmt.Println("Types:") 99 | for abstractType, cType := range typeMap { 100 | fmt.Printf(" %v -> %v\n", abstractType, cType) 101 | } 102 | fmt.Println("Functions:") 103 | for category, functions := range funcCategories { 104 | fmt.Printf(" %v\n", category) 105 | for _, function := range functions { 106 | fmt.Printf(" %v\n", function) 107 | } 108 | } 109 | } 110 | 111 | fmt.Printf("Generating packages ...\n") 112 | if err := GeneratePackages(packages, funcInfo, typeMap, prefix); err != nil { 113 | return err 114 | } 115 | 116 | return nil 117 | } 118 | 119 | func generateGoPackages(specsDir string) { 120 | // generate gl and ext packages 121 | if err := generatePackages( 122 | specsDir, 123 | OpenGLEnumExtSpecFile, 124 | []string{OpenGLSpecFile}, 125 | []string{OpenGLTypeMapFile}, 126 | "", "gl"); err != nil { 127 | fmt.Fprintln(os.Stderr, err.Error()) 128 | } 129 | 130 | // generate wgl package 131 | if err := generatePackages( 132 | specsDir, 133 | GLXEnumExtSpecFile, 134 | []string{GLXSpecFile, GLXExtSpecFile}, 135 | []string{OpenGLTypeMapFile, GLXTypeMapFile}, 136 | "glx", "glx"); err != nil { 137 | fmt.Fprintln(os.Stderr, err.Error()) 138 | } 139 | 140 | // generate wgl package 141 | if err := generatePackages( 142 | specsDir, 143 | WGLEnumExtSpecFile, 144 | []string{WGLSpecFile, WGLExtSpecFile}, 145 | []string{OpenGLTypeMapFile, WGLTypeMapFile}, 146 | "wgl", "wgl"); err != nil { 147 | fmt.Fprintln(os.Stderr, err.Error()) 148 | } 149 | } 150 | 151 | func downloadSpec(name string, args []string) { 152 | fs := flag.NewFlagSet(name, flag.ExitOnError) 153 | src := fs.String("src", "alfonse", "Source URL or 'khronos' or 'alfonse'.") 154 | odir := fs.String("odir", "glspecs", "Output directory for spec files.") 155 | fs.Parse(args) 156 | fmt.Println("Downloading specs ...") 157 | switch *src { 158 | case "alfonse": 159 | DownloadOpenGLSpecs(AlfonseSpecsBaseURL, *odir) 160 | case "khronos": 161 | DownloadOpenGLSpecs(KhronosRegistryBaseURL, *odir) 162 | default: 163 | DownloadOpenGLSpecs(*src, *odir) 164 | } 165 | } 166 | 167 | func downloadDoc(name string, args []string) { 168 | fmt.Println("Download docs not implemented.") 169 | fs := flag.NewFlagSet(name, flag.ExitOnError) 170 | fs.String("src", "", "Source URL.") 171 | fs.String("odir", "gldocs", "Output directory for doc files.") 172 | fs.Parse(args) 173 | fmt.Println("Downloading docs ...") 174 | // TODO: download docs 175 | } 176 | 177 | func generate(name string, args []string) { 178 | fs := flag.NewFlagSet(name, flag.ExitOnError) 179 | sdir := fs.String("sdir", "glspecs", "OpenGL spec directory.") 180 | _ = fs.String("ddir", "gldocs", "Documentation directory (currently not used).") 181 | fs.Parse(args) 182 | fmt.Println("Generate Bindings ...") 183 | generateGoPackages(*sdir) 184 | } 185 | 186 | func printUsage(name string) { 187 | fmt.Printf("Usage: %s command [arguments]\n", name) 188 | fmt.Println("Commands:") 189 | fmt.Println(" dlspec Download spec files.") 190 | fmt.Println(" dldoc Download documentation files.") 191 | fmt.Println(" gen Generate bindings.") 192 | fmt.Printf("Type %s -help for a detailed command description.\n", name) 193 | } 194 | 195 | func main() { 196 | fmt.Println("OpenGL binding generator for the Go programming language (http://golang.org).") 197 | fmt.Println("Copyright (c) 2011-2013 by Christoph Schunk. All rights reserved.") 198 | 199 | name := os.Args[0] 200 | args := os.Args[1:] 201 | 202 | if len(args) < 1 { 203 | printUsage(name) 204 | os.Exit(-1) 205 | } 206 | 207 | command := args[0] 208 | 209 | switch command { 210 | case "dlspec": 211 | downloadSpec("dlspec", args[1:]) 212 | case "dldoc": 213 | downloadDoc("dldoc", args[1:]) 214 | case "gen": 215 | generate("gen", args[1:]) 216 | default: 217 | fmt.Fprintf(os.Stderr, "Unknown command '%s'.", command) 218 | printUsage(name) 219 | os.Exit(-1) 220 | } 221 | } 222 | -------------------------------------------------------------------------------- /structs.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The GoGL Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE.mkd file. 4 | 5 | package main 6 | 7 | import ( 8 | "bytes" 9 | "errors" 10 | "fmt" 11 | "strconv" 12 | "strings" 13 | ) 14 | 15 | // Version 16 | 17 | type Version struct { 18 | Major int 19 | Minor int 20 | } 21 | 22 | func MakeVersionFromString(version string) (Version, error) { 23 | split := strings.Split(version, ".") 24 | if len(split) != 2 { 25 | return Version{0, 0}, errors.New("Invalid version string.") 26 | } 27 | return MakeVersionFromMajorMinorString(split[0], split[1]) 28 | } 29 | 30 | func MakeVersionFromMajorMinorString(major, minor string) (Version, error) { 31 | majorNumber, err := strconv.Atoi(major) 32 | if err != nil { 33 | return Version{0, 0}, errors.New("Invalid major version number.") 34 | } 35 | minorNumber, err := strconv.Atoi(minor) 36 | if err != nil { 37 | return Version{0, 0}, errors.New("Invalid minor version number.") 38 | } 39 | return Version{majorNumber, minorNumber}, nil 40 | } 41 | 42 | func (v Version) Compare(v2 Version) int { 43 | if v.Major < v2.Major { 44 | return -1 45 | } else if v.Major > v2.Major { 46 | return 1 47 | } else if v.Minor < v2.Minor { 48 | return -1 49 | } else if v.Minor > v2.Minor { 50 | return 1 51 | } 52 | return 0 53 | } 54 | 55 | func (v Version) Valid() bool { 56 | return v.Major != 0 || v.Minor != 0 57 | } 58 | 59 | func (v Version) String() string { 60 | return fmt.Sprintf("%d.%d", v.Major, v.Minor) 61 | } 62 | 63 | // Functions 64 | 65 | type ParamModifier int 66 | 67 | const ( 68 | ParamModifierValue ParamModifier = iota 69 | ParamModifierArray 70 | ParamModifierReference 71 | ) 72 | 73 | type FunctionsInfo struct { 74 | Versions []Version 75 | DeprecatedVersions []Version 76 | Categories []string 77 | Passthru map[string][]string 78 | } 79 | 80 | type Parameter struct { 81 | Name string 82 | Type string 83 | Out bool 84 | Modifier ParamModifier 85 | } 86 | 87 | type Function struct { 88 | Name string 89 | Parameters []Parameter 90 | Return string 91 | Version Version 92 | DeprecatedVersion Version 93 | Category string 94 | SubCategory string 95 | Offset string 96 | GlxRopCode string 97 | GlxSingle string 98 | WglFlags string 99 | GlxFlags string 100 | DlFlags string 101 | GlfFlags string 102 | GlxVendorPriv string 103 | GlextMask string 104 | Extension string 105 | VectorEquiv string 106 | GlxVectorEquiv string 107 | Alias string 108 | BeginEnd string 109 | } 110 | 111 | type Functions []*Function 112 | type FunctionCategories map[string]Functions 113 | 114 | func (p *Parameter) String() string { 115 | out := "" 116 | modifier := "" 117 | if p.Out { 118 | out = "out " 119 | } 120 | switch p.Modifier { 121 | case ParamModifierArray: 122 | modifier = "[]" 123 | case ParamModifierReference: 124 | modifier = "&" 125 | } 126 | return fmt.Sprintf("%s %s%s%s", p.Type, out, modifier, p.Name) 127 | } 128 | 129 | func (f *Function) String() string { 130 | s := bytes.NewBufferString("") 131 | fmt.Fprintf(s, "%s %s(", f.Return, f.Name) 132 | for i, _ := range f.Parameters { 133 | p := &f.Parameters[i] 134 | fmt.Fprint(s, p) 135 | if i < len(f.Parameters)-1 { 136 | fmt.Fprint(s, ", ") 137 | } 138 | } 139 | fmt.Fprintf(s, ") (v%v, d%v)", f.Version, f.DeprecatedVersion) 140 | return string(s.Bytes()) 141 | } 142 | 143 | func (fs Functions) Find(name string) *Function { 144 | for _, f := range fs { 145 | if f.Name == name { 146 | return f 147 | } 148 | } 149 | return nil 150 | } 151 | 152 | // Enums 153 | 154 | type Enums map[string]string 155 | type EnumCategories map[string]Enums 156 | 157 | func (e Enums) IsDefined(name string) bool { 158 | if _, ok := e[name]; ok { 159 | return true 160 | } 161 | return false 162 | } 163 | 164 | func (e EnumCategories) IsAlreadyDefined(name, excludeCategory string) bool { 165 | for cat, enums := range e { 166 | if excludeCategory != cat { 167 | if enums.IsDefined(name) { 168 | return true 169 | } 170 | } 171 | } 172 | return false 173 | } 174 | 175 | func (e EnumCategories) LookUpDefinition(name string) (bool, string) { 176 | for _, enums := range e { 177 | if val, ok := enums[name]; ok { 178 | return true, val 179 | } 180 | } 181 | return false, "" 182 | } 183 | 184 | // Type maps 185 | 186 | type TypeMap map[string]string 187 | 188 | func (tm TypeMap) Resolve(t string) (string, error) { 189 | // HACK: return t if type is not part of the spec 190 | if t == "void" { 191 | return t, nil 192 | } 193 | if t == "PIXELFORMATDESCRIPTOR" { 194 | return t, nil 195 | } 196 | if t == "LPCSTR" { 197 | return t, nil 198 | } 199 | if t == "LAYERPLANEDESCRIPTOR" { 200 | return t, nil 201 | } 202 | if t == "COLORREF" { 203 | return t, nil 204 | } 205 | if t == "HDC" { 206 | return t, nil 207 | } 208 | if rt, ok := tm[t]; ok { 209 | return rt, nil 210 | } 211 | return t, fmt.Errorf("Unable to resolve type: %s.", t) 212 | } 213 | 214 | // Packages 215 | 216 | type Package struct { 217 | Enums EnumCategories 218 | Functions FunctionCategories 219 | } 220 | 221 | type Packages map[string]*Package 222 | -------------------------------------------------------------------------------- /structs_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The GoGL Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE.mkd file. 4 | 5 | package main 6 | 7 | import ( 8 | "testing" 9 | ) 10 | 11 | type versionTest struct { 12 | In string 13 | Out Version 14 | Err bool 15 | } 16 | 17 | var versionTests = []versionTest{ 18 | {"0.0", Version{0, 0}, false}, 19 | {"0.1", Version{0, 1}, false}, 20 | {"1.0", Version{1, 0}, false}, 21 | {"5.6", Version{5, 6}, false}, 22 | {"0.", Version{0, 0}, true}, 23 | {"", Version{0, 0}, true}, 24 | {".", Version{0, 0}, true}, 25 | {"a", Version{0, 0}, true}, 26 | } 27 | 28 | func TestVersion(t *testing.T) { 29 | for i := range versionTests { 30 | test := &versionTests[i] 31 | v, err := MakeVersionFromString(test.In) 32 | if err != nil != test.Err { 33 | t.Errorf("Converison failed %v, %v", test, err) 34 | } 35 | if v.Valid() != test.Out.Valid() { 36 | t.Errorf("Input and output must be valid or invalid: %v", test) 37 | } 38 | if v.Compare(test.Out) != 0 { 39 | t.Errorf("Input != output %v", test) 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /tmreader.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The GoGL Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE.mkd file. 4 | 5 | package main 6 | 7 | import ( 8 | "bufio" 9 | "fmt" 10 | "io" 11 | "os" 12 | "regexp" 13 | "strings" 14 | ) 15 | 16 | var ( 17 | tmEmptyOrCommentRE = regexp.MustCompile("^[ \\t]*(#.*)?$") 18 | tmTypePairRE = regexp.MustCompile("^([_A-Za-z0-9]+),\\*,\\*,[\\t ]*([A-Za-z0-9\\*_ ]+),\\*,\\*") 19 | ) 20 | 21 | func ReadTypeMapFromFiles(files []string) (TypeMap, error) { 22 | allTypes := make(TypeMap) 23 | for _, file := range files { 24 | types, err := ReadTypeMapFromFile(file) 25 | if err != nil { 26 | return nil, err 27 | } 28 | for k, v := range types { 29 | allTypes[k] = v 30 | } 31 | } 32 | return allTypes, nil 33 | } 34 | 35 | func ReadTypeMapFromFile(name string) (TypeMap, error) { 36 | file, err := os.Open(name) 37 | if err != nil { 38 | return nil, err 39 | } 40 | defer file.Close() 41 | return ReadTypeMap(file) 42 | } 43 | 44 | func ReadTypeMap(r io.Reader) (TypeMap, error) { 45 | tm := make(TypeMap) 46 | br := bufio.NewReader(r) 47 | 48 | for { 49 | line, err := br.ReadString('\n') 50 | if err == io.EOF { 51 | break 52 | } 53 | if err != nil { 54 | return nil, err 55 | } 56 | line = strings.TrimRight(line, "\n") 57 | 58 | if tmEmptyOrCommentRE.MatchString(line) { 59 | continue 60 | } 61 | 62 | if typePair := tmTypePairRE.FindStringSubmatch(line); typePair != nil { 63 | tm[typePair[1]] = typePair[2] 64 | } else { 65 | return tm, fmt.Errorf("Unable to parse line: '%v'", line) 66 | } 67 | } 68 | 69 | return tm, nil 70 | } 71 | -------------------------------------------------------------------------------- /tmreader_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The GoGL Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE.mkd file. 4 | 5 | package main 6 | 7 | import ( 8 | "strings" 9 | "testing" 10 | ) 11 | 12 | var testTypeMapStr = "Test1,*,*, GLType1,*,*\n" + 13 | "Test2,*,*, GLType2,*,*\n" + 14 | "Test3,*,*, GLType3,*,*\n" + 15 | "Test_4,*,*, G L Type_3 *,*,*\n" 16 | 17 | func checkType(tn, gltype string, tm TypeMap, t *testing.T) { 18 | if ty, ok := tm[tn]; ok { 19 | if ty == gltype { 20 | t.Logf("Type found: %v::%v", tn, gltype) 21 | return 22 | } 23 | t.Errorf("Type not found: %v::%v", tn, gltype) 24 | return 25 | } 26 | t.Errorf("Type not found: %v", tn) 27 | } 28 | 29 | func TestTypeMapReader(t *testing.T) { 30 | r := strings.NewReader(testTypeMapStr) 31 | tm, err := ReadTypeMap(r) 32 | if err != nil { 33 | t.Fatalf("Read type map failed: %v", err) 34 | } 35 | t.Logf("%v", tm) 36 | 37 | if len(tm) != 4 { 38 | t.Errorf("Wrong number of types.") 39 | } 40 | 41 | checkType("Test1", "GLType1", tm, t) 42 | checkType("Test2", "GLType2", tm, t) 43 | checkType("Test3", "GLType3", tm, t) 44 | checkType("Test_4", "G L Type_3 *", tm, t) 45 | } 46 | -------------------------------------------------------------------------------- /util.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The GoGL Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE.mkd file. 4 | 5 | package main 6 | 7 | import ( 8 | "errors" 9 | "fmt" 10 | "strconv" 11 | "strings" 12 | "unicode" 13 | ) 14 | 15 | var ( 16 | versionPrefix = "VERSION_" 17 | depVersionSuffix = "_DEPRECATED" 18 | verPrefixLen = len(versionPrefix) 19 | depVerSuffixLen = len(depVersionSuffix) 20 | ) 21 | 22 | type CategoryType int32 23 | 24 | const ( 25 | CategoryInvalid CategoryType = iota 26 | CategoryVersion 27 | CategoryDepVersion 28 | CategoryExtension 29 | ) 30 | 31 | type ParsedCategory struct { 32 | Type CategoryType 33 | Version Version 34 | Vendor string 35 | Name string 36 | } 37 | 38 | func (pc ParsedCategory) String() string { 39 | switch pc.Type { 40 | case CategoryExtension: 41 | return fmt.Sprintf("Extension: vendor: %s, name: %s", pc.Vendor, pc.Name) 42 | case CategoryVersion: 43 | return fmt.Sprintf("Version: %v %s", pc.Version, pc.Vendor) 44 | case CategoryDepVersion: 45 | return fmt.Sprintf("Deprecated version: %v %s", pc.Version, pc.Vendor) 46 | } 47 | return "Invalid category" 48 | } 49 | 50 | func ParseCategoryString(category string) (ParsedCategory, error) { 51 | if strings.HasPrefix(category, versionPrefix) { 52 | ver := category[verPrefixLen:] 53 | ctype := CategoryVersion 54 | if strings.HasSuffix(ver, depVersionSuffix) { 55 | ver = ver[:len(ver)-depVerSuffixLen] 56 | ctype = CategoryDepVersion 57 | } 58 | if splitVer := strings.Split(ver, "_"); len(splitVer) == 2 { 59 | version, err := MakeVersionFromMajorMinorString(splitVer[0], splitVer[1]) 60 | if err != nil { 61 | return ParsedCategory{}, errors.New("Invalid category string.") 62 | } 63 | return ParsedCategory{ctype, version, "", ""}, nil 64 | } 65 | return ParsedCategory{}, errors.New("Invalid category string.") 66 | } else if splitCat := strings.SplitN(category, "_", 2); len(splitCat) == 2 { 67 | return ParsedCategory{CategoryExtension, Version{}, splitCat[0], splitCat[1]}, nil 68 | } else if len(category) > 0 { 69 | return ParsedCategory{CategoryExtension, Version{}, category, ""}, nil 70 | } 71 | return ParsedCategory{}, errors.New("Invalid category string.") 72 | } 73 | 74 | // Converts strings with underscores to Go-like names. e.g.: bla_blub_foo -> BlaBlubFoo 75 | func GoName(n string) string { 76 | prev := '_' 77 | return strings.Map(func(r rune) rune { 78 | if r == '_' { 79 | prev = r 80 | return -1 81 | } 82 | if prev == '_' { 83 | prev = r 84 | return unicode.ToTitle(r) 85 | } 86 | prev = r 87 | return unicode.ToLower(r) 88 | }, 89 | n) 90 | } 91 | 92 | func RenameIfReservedWord(word string) string { 93 | switch word { 94 | case "func", "type", "struct", "range", "map", "string", "near", "far": 95 | return fmt.Sprintf("%s_", word) 96 | } 97 | return word 98 | } 99 | 100 | // append X suffix if enum name starts with a digit 101 | func CleanEnumName(enum string) string { 102 | if strings.IndexAny(enum, "0123456789") == 0 { 103 | return fmt.Sprintf("X%s", enum) 104 | } 105 | return enum 106 | } 107 | 108 | // Converts C types to Go types. 109 | func CTypeToGoType(cType string, out bool, mod ParamModifier) (goType, cgoType string, err error) { 110 | // special cases: 111 | switch cType { 112 | case "void": 113 | goType = "" 114 | cgoType = "" 115 | if mod == ParamModifierArray || mod == ParamModifierReference { 116 | goType = "Pointer" 117 | cgoType = "unsafe.Pointer" 118 | } 119 | //if out { 120 | // err = errors.New("Unsupported void type.") 121 | //} 122 | return 123 | case "GLvoid": 124 | if mod == ParamModifierArray || mod == ParamModifierReference || out { 125 | goType = "Pointer" 126 | cgoType = "unsafe.Pointer" 127 | } else { 128 | err = errors.New("Unsupported GLvoid type.") 129 | } 130 | return 131 | case "GLvoid*", "GLvoid* const": 132 | goType = "Pointer" 133 | cgoType = "unsafe.Pointer" 134 | if mod == ParamModifierArray || mod == ParamModifierReference { 135 | goType = "*" + goType 136 | cgoType = "*" + cgoType 137 | } 138 | // out can be ignored 139 | return 140 | case "const GLubyte *": 141 | goType = "*Ubyte" 142 | cgoType = "*C.GLubyte" 143 | if mod == ParamModifierArray || mod == ParamModifierReference { 144 | goType = "*" + goType 145 | cgoType = "*" + cgoType 146 | } 147 | if out { 148 | err = errors.New("Unsupported out parameter.") 149 | } 150 | return 151 | case "GLchar*", "GLchar* const": 152 | goType = "*Char" 153 | cgoType = "*C.GLchar" 154 | if mod == ParamModifierArray || mod == ParamModifierReference { 155 | goType = "*" + goType 156 | cgoType = "*" + cgoType 157 | } 158 | return 159 | case "GLcharARB*": 160 | goType = "*Char" 161 | cgoType = "*C.GLcharARB" 162 | if mod == ParamModifierArray || mod == ParamModifierReference { 163 | goType = "*" + goType 164 | cgoType = "*" + cgoType 165 | } 166 | return 167 | case "GLboolean*": 168 | goType = "*Boolean" 169 | cgoType = "*C.GLboolean" 170 | if mod == ParamModifierArray || mod == ParamModifierReference { 171 | goType = "*" + goType 172 | cgoType = "*" + cgoType 173 | } 174 | return 175 | case "GLhandleARB": 176 | goType = "Uint" // handle is uint 177 | cgoType = "C.GLhandleARB" 178 | if mod == ParamModifierArray || mod == ParamModifierReference { 179 | goType = "*" + goType 180 | cgoType = "*" + cgoType 181 | } 182 | return 183 | case "GLDEBUGPROCARB", "GLDEBUGPROCAMD": 184 | goType = "Pointer" // TODO: Debug callback support? 185 | cgoType = "*[0]byte" 186 | if mod == ParamModifierArray || mod == ParamModifierReference || out { 187 | err = errors.New("Unsupported type.") 188 | } 189 | return 190 | case "GLDEBUGPROC": 191 | goType = "Pointer" // TODO: Debug callback support? 192 | cgoType = "*[0]byte" 193 | if mod == ParamModifierArray || mod == ParamModifierReference || out { 194 | err = errors.New("Unsupported type.") 195 | } 196 | return 197 | case "GLvdpauSurfaceNV": 198 | goType = "Intptr" // TODO: vdpau support? 199 | cgoType = "C.GLvdpauSurfaceNV" 200 | if mod == ParamModifierArray || mod == ParamModifierReference { 201 | goType = "*" + goType 202 | cgoType = "*" + cgoType 203 | } 204 | return 205 | case "GLsync": 206 | goType = "Sync" 207 | cgoType = "C.GLsync" 208 | if mod == ParamModifierArray || mod == ParamModifierReference || out { 209 | err = errors.New("Unsupported type.") 210 | } 211 | return 212 | case "struct _cl_context *", "struct _cl_event *": 213 | goType = "Pointer" // TODO: OpenCL context, event support? 214 | cgoType = "*[0]byte" 215 | if mod == ParamModifierArray || mod == ParamModifierReference || out { 216 | err = errors.New("Unsupported type.") 217 | } 218 | return 219 | // glx 220 | case "Display": 221 | goType = "Pointer" 222 | cgoType = "C.Display" 223 | if mod == ParamModifierArray || mod == ParamModifierReference { 224 | //goType = "*" + goType 225 | cgoType = "*" + cgoType 226 | } 227 | return 228 | case "Display *": 229 | goType = "Pointer" 230 | cgoType = "*C.Display" 231 | if mod == ParamModifierArray || mod == ParamModifierReference { 232 | //goType = "*" + goType 233 | cgoType = "*" + cgoType 234 | } 235 | return 236 | case "GLXFBConfig": 237 | goType = "Pointer" 238 | cgoType = "C.GLXFBConfig" 239 | return 240 | case "GLXFBConfig *": 241 | goType = "Pointer" 242 | cgoType = "C.GLXFBConfig *" 243 | return 244 | case "GLXContext", "const GLXContext": 245 | goType = "Pointer" 246 | cgoType = "C.GLXContext" 247 | return 248 | case "GLXContextID": 249 | goType = "uint32" 250 | cgoType = "C.GLXContextID" 251 | return 252 | case "GLXDrawable": 253 | goType = "Pointer" 254 | cgoType = "C.GLXDrawable" 255 | return 256 | case "XVisualInfo": 257 | goType = "Pointer" 258 | cgoType = "C.XVisualInfo" 259 | return 260 | case "XVisualInfo *": 261 | goType = "Pointer" 262 | cgoType = "*C.XVisualInfo" 263 | return 264 | case "Pixmap": 265 | goType = "Pointer" 266 | cgoType = "C.Pixmap" 267 | return 268 | case "GLXPixmap": 269 | goType = "Pointer" 270 | cgoType = "C.GLXPixmap" 271 | return 272 | case "Colormap": 273 | goType = "Pointer" 274 | cgoType = "C.Colormap" 275 | return 276 | case "GLXPbuffer": 277 | goType = "Pointer" 278 | cgoType = "C.GLXPbuffer" 279 | return 280 | case "GLXPbufferSGIX": 281 | goType = "Pointer" 282 | cgoType = "C.GLXPbufferSGIX" 283 | return 284 | case "GLXFBConfigSGIX": 285 | goType = "Pointer" 286 | cgoType = "C.GLXFBConfigSGIX" 287 | return 288 | case "GLXFBConfigSGIX *": 289 | goType = "Pointer" 290 | cgoType = "*C.GLXFBConfigSGIX" 291 | return 292 | case "DMparams": 293 | goType = "Pointer" 294 | cgoType = "C.DMparams" 295 | return 296 | case "DMbuffer": 297 | goType = "Pointer" 298 | cgoType = "C.DMbuffer" 299 | return 300 | case "__GLXextFuncPtr": 301 | goType = "Pointer" 302 | cgoType = "C.__GLXextFuncPtr" 303 | return 304 | case "GLXVideoDeviceNV": 305 | goType = "Pointer" 306 | cgoType = "C.GLXVideoDeviceNV" 307 | return 308 | case "GLXVideoCaptureDeviceNV": 309 | goType = "Pointer" 310 | cgoType = "C.GLXVideoCaptureDeviceNV" 311 | return 312 | case "GLXVideoCaptureDeviceNV *": 313 | goType = "Pointer" 314 | cgoType = "*C.GLXVideoCaptureDeviceNV" 315 | return 316 | case "GLXHyperpipeNetworkSGIX *": 317 | goType = "Pointer" 318 | cgoType = "*C.GLXHyperpipeNetworkSGIX" 319 | return 320 | case "GLXHyperpipeConfigSGIX *": 321 | goType = "Pointer" 322 | cgoType = "*C.GLXHyperpipeConfigSGIX" 323 | return 324 | case "GLXHyperpipeConfigSGIX": 325 | if mod == ParamModifierArray || mod == ParamModifierReference || out { 326 | goType = "Pointer" 327 | cgoType = "*C.GLXHyperpipeConfigSGIX" 328 | } else { 329 | err = errors.New("Unsupported GLXHyperpipeConfigSGIX type.") 330 | } 331 | return 332 | case "GLXVideoSourceSGIX": 333 | goType = "Pointer" 334 | cgoType = "*C.GGLXVideoSourceSGIX" 335 | return 336 | case "Window": 337 | goType = "Pointer" 338 | cgoType = "C.Window" 339 | return 340 | case "GLXWindow": 341 | goType = "Pointer" 342 | cgoType = "C.GLXWindow" 343 | return 344 | case "VLServer": 345 | goType = "Pointer" 346 | cgoType = "C.VLServer" 347 | return 348 | case "VLPath": 349 | goType = "Pointer" 350 | cgoType = "C.VLPath" 351 | return 352 | case "VLNode": 353 | goType = "Pointer" 354 | cgoType = "C.VLNode" 355 | return 356 | case "unsigned int *": 357 | goType = "*uint32" 358 | cgoType = "*C.uint32" 359 | return 360 | 361 | // wgl 362 | case "VOID": 363 | goType = "" 364 | cgoType = "" 365 | return 366 | case "LPVOID": 367 | goType = "Pointer" 368 | cgoType = "C.LPVOID" 369 | return 370 | case "void*": 371 | goType = "Pointer" 372 | cgoType = "C.LPVOID" 373 | return 374 | case "HANDLE": 375 | goType = "Pointer" 376 | cgoType = "C.HANDLE" 377 | return 378 | case "HDC": 379 | goType = "Pointer" 380 | cgoType = "C.HDC" 381 | return 382 | case "HGLRC": 383 | goType = "Pointer" 384 | cgoType = "C.HGLRC" 385 | return 386 | case "HPBUFFERARB": 387 | goType = "Pointer" 388 | cgoType = "C.HPBUFFERARB" 389 | return 390 | case "HPBUFFEREXT": 391 | goType = "Pointer" 392 | cgoType = "C.HPBUFFEREXT" 393 | return 394 | case "HGPUNV": 395 | goType = "Pointer" 396 | cgoType = "C.HGPUNV" 397 | return 398 | case "PGPU_DEVICE": 399 | goType = "Pointer" 400 | cgoType = "C.PGPU_DEVICE" 401 | return 402 | case "HVIDEOOUTPUTDEVICENV": 403 | goType = "Pointer" 404 | cgoType = "C.HVIDEOOUTPUTDEVICENV" 405 | return 406 | case "HVIDEOINPUTDEVICENV": 407 | goType = "Pointer" 408 | cgoType = "C.HVIDEOINPUTDEVICENV" 409 | return 410 | case "HPVIDEODEV": 411 | goType = "Pointer" 412 | cgoType = "C.HPVIDEODEV" 413 | return 414 | case "COLORREF": 415 | goType = "Pointer" 416 | cgoType = "C.COLORREF" 417 | return 418 | case "LAYERPLANEDESCRIPTOR": 419 | goType = "[]byte" 420 | cgoType = "C.LAYERPLANEDESCRIPTOR" 421 | return 422 | case "LPCSTR": 423 | goType = "*byte" 424 | cgoType = "C.LPCSTR" 425 | return 426 | case "PIXELFORMATDESCRIPTOR": 427 | goType = "[]byte" 428 | cgoType = "C.PIXELFORMATDESCRIPTOR" 429 | return 430 | case "const char *": 431 | goType = "*byte" 432 | cgoType = "*C.char" 433 | return 434 | } 435 | // standard cases for primitive data types: 436 | switch cType { 437 | // base types 438 | case "GLenum": 439 | goType = "Enum" 440 | cgoType = "C.GLenum" 441 | case "GLboolean": 442 | goType = "Boolean" 443 | cgoType = "C.GLboolean" 444 | case "GLbitfield": 445 | goType = "Bitfield" 446 | cgoType = "C.GLbitfield" 447 | case "GLbyte": 448 | goType = "Byte" 449 | cgoType = "C.GLbyte" 450 | case "GLshort": 451 | goType = "Short" 452 | cgoType = "C.GLshort" 453 | case "GLint": 454 | goType = "Int" 455 | cgoType = "C.GLint" 456 | case "GLsizei": 457 | goType = "Sizei" 458 | cgoType = "C.GLsizei" 459 | case "GLubyte": 460 | goType = "Ubyte" 461 | cgoType = "C.GLubyte" 462 | case "GLushort": 463 | goType = "Ushort" 464 | cgoType = "C.GLushort" 465 | case "GLuint": 466 | goType = "Uint" 467 | cgoType = "C.GLuint" 468 | case "GLhalf": 469 | goType = "Half" 470 | cgoType = "C.GLhalf" 471 | case "GLhalfNV": 472 | goType = "Half" 473 | cgoType = "C.GLhalfNV" 474 | case "GLfloat": 475 | goType = "Float" 476 | cgoType = "C.GLfloat" 477 | case "GLclampf": 478 | goType = "Clampf" 479 | cgoType = "C.GLclampf" 480 | case "GLdouble": 481 | goType = "Double" 482 | cgoType = "C.GLdouble" 483 | case "GLclampd": 484 | goType = "Clampd" 485 | cgoType = "C.GLclampd" 486 | // 487 | case "GLchar": 488 | goType = "Char" 489 | cgoType = "C.GLchar" 490 | case "GLcharARB": 491 | goType = "Char" 492 | cgoType = "C.GLcharARB" 493 | // 494 | case "GLintptr": 495 | goType = "Intptr" 496 | cgoType = "C.GLintptr" 497 | case "GLintptrARB": 498 | goType = "Intptr" 499 | cgoType = "C.GLintptrARB" 500 | case "GLsizeiptr": 501 | goType = "Sizeiptr" 502 | cgoType = "C.GLsizeiptr" 503 | case "GLsizeiptrARB": 504 | goType = "Sizeiptr" 505 | cgoType = "C.GLsizeiptrARB" 506 | // 507 | case "GLint64": 508 | goType = "Int64" 509 | cgoType = "C.GLint64" 510 | case "GLint64EXT": 511 | goType = "Int64" 512 | cgoType = "C.GLint64EXT" 513 | case "GLuint64": 514 | goType = "Uint64" 515 | cgoType = "C.GLuint64" 516 | case "GLuint64EXT": 517 | goType = "Uint64" 518 | cgoType = "C.GLuint64EXT" 519 | // glx 520 | case "int": 521 | goType = "Int" 522 | cgoType = "C.int" 523 | case "int32_t": 524 | goType = "int32" 525 | cgoType = "C.int32_t" 526 | case "int64_t": 527 | goType = "int64" 528 | cgoType = "C.int64_t" 529 | case "Bool": 530 | goType = "int" 531 | cgoType = "C.int" 532 | case "Status": 533 | goType = "int" 534 | cgoType = "C.int" 535 | case "long": 536 | goType = "int32" 537 | cgoType = "C.long" 538 | 539 | //wgl 540 | case "UINT": 541 | goType = "uint32" 542 | cgoType = "C.UINT" 543 | case "INT": 544 | goType = "int32" 545 | cgoType = "C.INT" 546 | case "INT32": 547 | goType = "int32" 548 | cgoType = "C.INT32" 549 | case "INT64": 550 | goType = "int64" 551 | cgoType = "C.INT64" 552 | case "USHORT": 553 | goType = "uint16" 554 | cgoType = "C.USHORT" 555 | case "DWORD": 556 | goType = "uint32" 557 | cgoType = "C.DWORD" 558 | case "FLOAT": 559 | goType = "float32" 560 | cgoType = "C.FLOAT" 561 | case "BOOL": 562 | goType = "int32" 563 | cgoType = "C.BOOL" 564 | case "PROC": 565 | goType = "Pointer" 566 | cgoType = "C.PROC" 567 | case "float": 568 | goType = "float32" 569 | cgoType = "C.float32" 570 | case "unsigned int": 571 | goType = "uint32" 572 | cgoType = "C.uint32" 573 | case "unsigned long": 574 | goType = "uint32" 575 | cgoType = "C.unsigned_long" 576 | default: 577 | err = errors.New("Unknown GL type: " + cType) 578 | return 579 | } 580 | if mod == ParamModifierArray || mod == ParamModifierReference || out { 581 | goType = "*" + goType 582 | cgoType = "*" + cgoType 583 | } 584 | return 585 | } 586 | 587 | func MakeExtensionSpecDocUrl(vendor, extension string) string { 588 | return fmt.Sprintf("https://www.opengl.org/registry/specs/%s/%s.txt", vendor, extension) 589 | } 590 | 591 | func MakeGLDocUrl(majorVersion int) string { 592 | manVer := "" 593 | if majorVersion >= 3 { 594 | manVer = strconv.Itoa(majorVersion) 595 | } 596 | return fmt.Sprintf("https://www.opengl.org/sdk/docs/man%s", manVer) 597 | } 598 | 599 | func MakeFuncDocUrl(majorVersion int, fName string) string { 600 | manVer := "" 601 | if majorVersion >= 3 { 602 | manVer = strconv.Itoa(majorVersion) 603 | } 604 | return fmt.Sprintf("https://www.opengl.org/sdk/docs/man%s/xhtml/gl%s.xml", manVer, fName) 605 | } 606 | -------------------------------------------------------------------------------- /util_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The GoGL Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE.mkd file. 4 | 5 | package main 6 | 7 | import ( 8 | "reflect" 9 | "testing" 10 | ) 11 | 12 | type testCategories struct { 13 | in string 14 | out ParsedCategory 15 | } 16 | 17 | type testGoName struct { 18 | in string 19 | out string 20 | } 21 | 22 | var allTestCategories = []testCategories{ 23 | {"VERSION_1_4", ParsedCategory{CategoryVersion, Version{1, 4}, "", ""}}, 24 | {"VERSION_2_0_DEPRECATED", ParsedCategory{CategoryDepVersion, Version{2, 0}, "", ""}}, 25 | {"ARB_multisample", ParsedCategory{CategoryExtension, Version{0, 0}, "ARB", "multisample"}}, 26 | {"EXT_12345678", ParsedCategory{CategoryExtension, Version{0, 0}, "EXT", "12345678"}}, 27 | {"ABC123_a_b_", ParsedCategory{CategoryExtension, Version{0, 0}, "ABC123", "a_b_"}}, 28 | {"A_", ParsedCategory{CategoryExtension, Version{0, 0}, "A", ""}}, 29 | } 30 | 31 | var allTestGoName = []testGoName{ 32 | {"", ""}, 33 | {"_", ""}, 34 | {"ARB_multisample", "ARBMultisample"}, 35 | {"vertex_array_object", "VertexArrayObject"}, 36 | {"a_b_c_", "ABC"}, 37 | } 38 | 39 | func TestParsedCategory(t *testing.T) { 40 | for i := range allTestCategories { 41 | te := &allTestCategories[i] 42 | pc, err := ParseCategoryString(te.in) 43 | if err != nil { 44 | t.Fatalf(err.Error()) 45 | } 46 | t.Logf("%s -> %v", te.in, te.out) 47 | if !reflect.DeepEqual(pc, te.out) { 48 | t.Errorf("not equal: out = %v", pc) 49 | } 50 | } 51 | } 52 | 53 | func TestGoName(t *testing.T) { 54 | for i := range allTestGoName { 55 | te := &allTestGoName[i] 56 | if GoName(te.in) != te.out { 57 | t.Errorf("String conversion failed: %v -> %v", te.in, te.out) 58 | } 59 | } 60 | } 61 | --------------------------------------------------------------------------------