├── LICENSE ├── Makefile ├── README.md ├── config.json ├── generate.py ├── gl.cpp ├── gl.hpp ├── gl.xml └── test.cpp /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2020 Nikita Lisitsa 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | test: test.cpp gl.hpp gl.cpp 2 | g++ test.cpp gl.cpp -o test -lGLX -lSDL2 3 | 4 | gl.hpp gl.cpp: config.json generate.py 5 | ./generate.py config.json 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # OpenGL Loader Generator 2 | 3 | OpenGL Loader Generator is a generator of [OpenGL loading library](https://www.khronos.org/opengl/wiki/OpenGL_Loading_Library) targetting C++ that supports different OpenGL versions, profiles, extensions, and even has adjustable code formatting. The generated library loads OpenGL function pointers & can be used in place of system-provided OpenGL header files (which [are known](https://www.khronos.org/opengl/wiki/Load_OpenGL_Functions#Function_Prototypes) to contain definitions for only a few extremely old OpenGL verions). The library has no dependencies other than an OpenGL implementation and a C++11 compiler. 4 | 5 | The project has been tested under Linux with GCC 9.2 & under Windows with MinGW 9.3. If for some reason it doesn't work for your platform, be welcome to post an issue or (better) make a PR. 6 | 7 | The project is heavily influenced by [glLoadGen](https://bitbucket.org/alfonse/glloadgen) (no longer supported). 8 | 9 | # Generation 10 | 11 | The generator itself is a single python script `generator.py`. It needs a configuration file to work, though. 12 | 13 | To generate the loading library (header & source files), run 14 | `./generator.py config.json` 15 | 16 | The config file is a single JSON object containing the generator configuration (see the [example file](https://github.com/lisyarus/opengl-loader-generator/blob/master/config.json)). A config file was chosen instead of e.g. command-line arguments to make updating the config & loader easier. 17 | 18 | The following generator options are supported: 19 | 20 | | Option | Type | Default value | Description | 21 | | --- | --- | --- | --- | 22 | | `spec_file` | `string` | `"gl.xml"` | Path to [OpenGL specification XML file](https://github.com/KhronosGroup/OpenGL-Registry/tree/master/xml) (a version of this file is included in this repository) | 23 | | `api` | `string` | `"gl"` | The API to load: `gl`, `gles1`, `gles2` or `glsc` | 24 | | `version` | `string` | `"4.6"` | The API version to load | 25 | | `profile` | `string` | `"core"` | The API profile to load (may be empty) | 26 | | `extensions` | `[string]` | `[]` | The list of extensions to load | 27 | | `indent` | `string` | `"\t"` | The string to use as indentation in the generated code | 28 | | `namespace` | `string` | `"gl"` | The namespace that will be used for generated API functions and constants (empty namespace means using global namespace) | 29 | | `loader_namespace` | `string` | `"sys"` | The namespace that will be used for the loader library public interface, relative to the `gl` namespace (empty namespace means using parent namespace) | 30 | | `internal_namespace` | `string` | `"internal"` | The namespace that will be used for the loader library internals, relative to the `gl` namespace (empty namespace means using parent namespace) | 31 | | `internal_prefix` | `string` | `""` | The prefix that will be appended to all OpenGL function names in the loader library internals (**not** the loaded OpenGL functions) | 32 | | `undef` | `int` | `4` | All OpenGL constants of this length or shorter will be `#undef`ined in the beginning of the library header (some systems may define `TRUE`, `ZERO`, etc) | 33 | | `strip` | `bool` | `true` | Whether to strip the `gl` and `GL_` prefixes from OpenGL functions and constants (makes sense when using a namespace) | 34 | | `out_header` | `string` | `"gl.hpp"` | The path to the generated loader library header | 35 | | `out_source` | `string` | `"gl.cpp"` | The path to the generated loader library source | 36 | | `include` | `string` | `"\"${config.out_header}\""` | The string to be used by the library source to include the library header (including the `""` or `<>`); that is, the library source will contain a line `#include ${config.include}` | 37 | 38 | All non-absolute paths are resolved relative to current working directory. 39 | 40 | The generated functions are in C++, thus adhere to C++ linkage & name mangling rules. 41 | 42 | Note that options `config.namespace = ""` and `config.strip = false` make the generated functions appear in the global namespace with names identical to how they are defined in OpenGL (e.g. `glClear` in the global namespace, etc). This may interfere with already existing OpenGL functions, use at your own risk (however the library prevents including OpenGL headers alongside itself, and OpenGL functions have `C` linkage, so it should be hard to actually face any problems). 43 | 44 | See the examples of generated [header](https://github.com/lisyarus/opengl-loader-generator/blob/master/gl.hpp) and [source](https://github.com/lisyarus/opengl-loader-generator/blob/master/gl.cpp) for further details on the structure of the generated files. 45 | 46 | # Usage 47 | 48 | With the default settings, the `gl` namespace contains all OpenGL functions and constants for a particular version & profile, while the loader library API is in the `gl::sys` namespace. The `gl::internal` namespace will contain the actual OpenGL functions' pointers that will be loaded at runtime. All of these namespaces can be changed through the configuration file. 49 | 50 | To initialize the library, call `gl::sys::initialize()`. This function returns `true` if all the required OpenGL functions were successfully loaded (excluding extensions), and `false` otherwise. To check if a particular requested extension is supported, call `gl::sys::ext_EXTENSION_NAME()`, e.g. `gl::sys::ext_ARB_texture_filter_anisotropic()` for the `GL_ARB_texture_filter_anisotropic` extension (note that the `GL_` part is stripped). 51 | 52 | The loaded functions and constants can be used like `gl::DrawArrays(gl::TRIANGLES, 0, 6)` (again, assuming default settings). See the [test application](https://github.com/lisyarus/opengl-loader-generator/blob/master/test.cpp) for a working example of library usage. 53 | 54 | # License 55 | 56 | The OpenGL Loader Generator is distributed under the [MIT license](https://github.com/lisyarus/opengl-loader-generator/blob/master/LICENSE). 57 | 58 | # Contributing 59 | 60 | Any fixes and/or enhancements are **warmly welcome**. 61 | Before creating a pull request, make sure that the [test application](https://github.com/lisyarus/opengl-loader-generator/blob/master/Makefile) compiles and runs successfully (you'll need the [SDL2 library](https://www.libsdl.org/download-2.0.php) for that). -------------------------------------------------------------------------------- /config.json: -------------------------------------------------------------------------------- 1 | { 2 | "spec_file": "gl.xml", 3 | "api": "gl", 4 | "version": "3.3", 5 | "profile": "core", 6 | "extensions": [ 7 | "ARB_texture_filter_anisotropic", 8 | "ARB_compute_shader" 9 | ], 10 | "indent": "\t", 11 | "namespace": "gl", 12 | "loader_namespace": "sys", 13 | "internal_namespace": "internal", 14 | "internal_prefix": "", 15 | "undef": 4, 16 | "strip": true, 17 | "out_header": "gl.hpp", 18 | "out_source": "gl.cpp", 19 | "include": "\"gl.hpp\"" 20 | } 21 | -------------------------------------------------------------------------------- /generate.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import sys 4 | import json 5 | 6 | # Default config 7 | 8 | class Object(object): 9 | pass 10 | 11 | default_config = Object() 12 | 13 | default_config.spec_file = 'gl.xml' 14 | default_config.api = 'gl' 15 | default_config.version = '4.6' 16 | default_config.profile = 'core' 17 | default_config.extensions = [] 18 | 19 | default_config.indent = "\t" 20 | default_config.namespace = 'gl' 21 | default_config.loader_namespace = 'sys' 22 | default_config.internal_namespace = 'internal' 23 | default_config.internal_prefix = '' 24 | 25 | default_config.undef = 4 26 | default_config.strip = True 27 | 28 | default_config.out_header = 'gl.hpp' 29 | default_config.out_source = 'gl.cpp' 30 | default_config.include = '"gl.hpp"' 31 | 32 | # Parse config 33 | 34 | if len(sys.argv) != 2: 35 | print("Usage: {} ".format(sys.argv[0])) 36 | sys.exit(1) 37 | 38 | cfg = json.load(open(sys.argv[1], 'rt')) 39 | 40 | config = Object() 41 | 42 | config.spec_file = cfg.get('spec_file', default_config.spec_file) 43 | config.api = cfg.get('api', default_config.api ) 44 | config.version = cfg.get('version', default_config.version ) 45 | config.profile = cfg.get('profile', default_config.profile ) 46 | config.extensions = cfg.get('extensions', default_config.extensions) 47 | 48 | config.indent = cfg.get('indent', default_config.indent ) 49 | config.namespace = cfg.get('namespace', default_config.namespace ) 50 | config.loader_namespace = cfg.get('loader_namespace', default_config.loader_namespace ) 51 | config.internal_namespace = cfg.get('internal_namespace', default_config.internal_namespace) 52 | config.internal_prefix = cfg.get('internal_prefix', default_config.internal_prefix ) 53 | 54 | config.undef = cfg.get('undef', default_config.undef) 55 | config.strip = cfg.get('strip', default_config.strip) 56 | 57 | config.out_header = cfg.get('out_header', default_config.out_header) 58 | config.out_source = cfg.get('out_source', default_config.out_source) 59 | config.include = cfg.get('include', "\"{}\"".format(config.out_header)) 60 | 61 | # Helper variables & functions 62 | 63 | api_name = { 64 | 'gl': "OpenGL", 65 | 'gles1': "OpenGL ES", 66 | 'gles2': "OpenGL ES", 67 | 'glsc2': "OpenGL SC", 68 | } 69 | 70 | if config.api not in api_name: 71 | print('Unknown api:', config.api) 72 | sys.exit(1) 73 | 74 | indent = config.indent 75 | gl_indent = indent 76 | int_indent = indent 77 | sys_indent = indent 78 | 79 | if not config.namespace: 80 | gl_indent = "" 81 | 82 | if not config.internal_namespace: 83 | int_indent = "" 84 | 85 | if not config.loader_namespace: 86 | sys_indent = "" 87 | 88 | def strip(name): 89 | if config.strip: 90 | if name[:3] == 'GL_': return name[3:] 91 | if name[:2] == 'gl': return name[2:] 92 | return name 93 | 94 | def parse_name_and_type(node, need_strip): 95 | nptype = node.find('ptype') 96 | nname = node.find('name') 97 | 98 | name = nname.text 99 | 100 | proto = "" 101 | if node.text: 102 | proto += node.text 103 | if nptype is not None: 104 | proto += nptype.text 105 | if nptype.tail: 106 | proto += nptype.tail 107 | proto += strip(nname.text) if need_strip else nname.text 108 | if nname.tail: 109 | proto += nname.tail 110 | 111 | t = "" 112 | if node.text: 113 | t += node.text 114 | if nptype is not None: 115 | t += nptype.text 116 | if nptype.tail: 117 | t += nptype.tail 118 | 119 | return (name, proto, t) 120 | 121 | def internal_name(name, ns): 122 | return ((config.internal_namespace + "::") if (config.internal_namespace and ns) else "") + config.internal_prefix + name 123 | 124 | def valid_id(name): 125 | return not name[0].isnumeric() 126 | 127 | # Parse the spec 128 | 129 | import xml.etree.ElementTree as ET 130 | root = ET.parse(config.spec_file).getroot() 131 | 132 | types = [] 133 | for ntypes in root.findall('types'): 134 | for ntype in ntypes.findall('type'): 135 | nname = ntype.find('name') 136 | 137 | t = "" 138 | if ntype.text: 139 | t += ntype.text 140 | if nname is not None: 141 | if nname.text: 142 | t += nname.text 143 | if nname.tail: 144 | t += nname.tail 145 | 146 | types.append(t) 147 | 148 | enums = {} 149 | for nenums in root.findall('enums'): 150 | if nenums.get('namespace') != 'GL': continue 151 | 152 | for nenum in nenums.findall('enum'): 153 | name = nenum.get('name') 154 | value = nenum.get('value') 155 | t = nenum.get('type') 156 | 157 | enums[name] = {} 158 | enums[name]['value'] = value 159 | enums[name]['type'] = 'GLenum' 160 | if t is not None: 161 | if t == 'u': 162 | enums[name]['type'] = 'unsigned' 163 | if t == 'ull': 164 | enums[name]['type'] = 'unsigned long long' 165 | 166 | commands = {} 167 | for ncommands in root.findall('commands'): 168 | if ncommands.get('namespace') != 'GL': continue 169 | 170 | for ncommand in ncommands.findall('command'): 171 | name, proto, t = parse_name_and_type(ncommand.find('proto'), config.strip) 172 | 173 | params = [] 174 | for nparam in ncommand.findall('param'): 175 | params.append(parse_name_and_type(nparam, False)) 176 | 177 | commands[name] = {} 178 | commands[name]['proto'] = proto 179 | commands[name]['type'] = t 180 | commands[name]['params'] = params 181 | 182 | def process_features(node): 183 | result = { 184 | 'enums': [], 185 | 'commands': [] 186 | } 187 | for nrequire in node.findall('require'): 188 | profile = nrequire.get('profile') 189 | if profile is not None and config.profile is not None and profile != config.profile: continue 190 | for nenum in nrequire.findall('enum'): 191 | result['enums'].append(nenum.get('name')) 192 | for ncommand in nrequire.findall('command'): 193 | result['commands'].append(ncommand.get('name')) 194 | 195 | removed = set() 196 | for nremove in node.findall('remove'): 197 | profile = nremove.get('profile') 198 | if profile is not None and config.profile is not None and profile != config.profile: continue 199 | for nenum in nremove.findall('enum'): 200 | removed.add(nenum.get('name')) 201 | for ncommand in nremove.findall('command'): 202 | removed.add(ncommand.get('name')) 203 | 204 | return (result, removed) 205 | 206 | api_by_version = {} 207 | api_by_extension = {} 208 | removed = set() 209 | 210 | for nfeature in root.findall('feature'): 211 | api = nfeature.get('api') 212 | version = nfeature.get('number') 213 | if api != config.api or version is None or version > config.version: continue 214 | f, r = process_features(nfeature) 215 | api_by_version[version] = f 216 | removed = removed.union(r) 217 | 218 | for nextension in root.find('extensions').findall('extension'): 219 | name = nextension.get('name') 220 | if name[3:] not in config.extensions: continue 221 | f, r = process_features(nextension) 222 | api_by_extension[name] = f 223 | 224 | # Write the header file 225 | 226 | header_definitions = """ 227 | // Prevent inclusion of other OpenGL-related headers 228 | 229 | #if defined(__glew_h__) || defined(__GLEW_H__) 230 | #error Attempt to include auto-generated header after including glew.h 231 | #endif 232 | #if defined(__gl_h_) || defined(__GL_H__) 233 | #error Attempt to include auto-generated header after including gl.h 234 | #endif 235 | #if defined(__glext_h_) || defined(__GLEXT_H_) 236 | #error Attempt to include auto-generated header after including glext.h 237 | #endif 238 | #if defined(__gltypes_h_) 239 | #error Attempt to include auto-generated header after gltypes.h 240 | #endif 241 | #if defined(__gl_ATI_h_) 242 | #error Attempt to include auto-generated header after including glATI.h 243 | #endif 244 | 245 | #define __glew_h__ 246 | #define __GLEW_H__ 247 | #define __gl_h_ 248 | #define __GL_H__ 249 | #define __glext_h_ 250 | #define __GLEXT_H_ 251 | #define __gltypes_h_ 252 | #define __gl_ATI_h_ 253 | 254 | """ 255 | 256 | with open(config.out_header, 'wt') as header: 257 | 258 | pointers_defined = set() 259 | enums_defined = set() 260 | functions_defined = set() 261 | 262 | header.write("#pragma once\n") 263 | header.write(header_definitions) 264 | 265 | # Write undefs 266 | if config.undef > 0: 267 | header.write("// Undefine some macros that may interfere with {} constants\n\n".format(api_name[config.api])) 268 | for e in enums: 269 | name = strip(e) 270 | if valid_id(name) and len(name) <= config.undef: 271 | header.write("#undef {}\n".format(name)) 272 | header.write("\n") 273 | 274 | # Write type definitions 275 | header.write("// {} type definitions\n\n".format(api_name[config.api])) 276 | for t in types: 277 | header.write(t + "\n") 278 | header.write("\n") 279 | 280 | if config.namespace: 281 | header.write("namespace {}\n{{\n\n".format(config.namespace)) 282 | 283 | # Write internal pointers 284 | if config.internal_namespace: 285 | header.write("{}namespace {}\n{}{{\n\n".format(gl_indent, config.internal_namespace, gl_indent)) 286 | 287 | def internal_write_features(f): 288 | for c in f['commands']: 289 | if c in pointers_defined: continue 290 | if c in removed: continue 291 | pointers_defined.add(c) 292 | command = commands[c] 293 | 294 | proto = command['proto'].replace(strip(c), "(*" + internal_name(c, False) + ")") 295 | params_proto = ", ".join(p[1] for p in command['params']) 296 | 297 | header.write("{}{}extern {}({});\n".format(gl_indent, int_indent, proto, params_proto)) 298 | header.write("\n") 299 | 300 | for version in sorted(api_by_version.keys()): 301 | header.write("{}{}// {} {}\n\n".format(gl_indent, int_indent, api_name[config.api], version)) 302 | internal_write_features(api_by_version[version]) 303 | 304 | for name in api_by_extension.keys(): 305 | header.write("{}{}// {}\n\n".format(gl_indent, int_indent, name)) 306 | internal_write_features(api_by_extension[name]) 307 | 308 | if config.internal_namespace: 309 | header.write("{}}} // namespace {}\n\n".format(gl_indent, config.internal_namespace)) 310 | 311 | # Write enums & inline functions 312 | def write_features(f): 313 | for e in f['enums']: 314 | if e in enums_defined: continue 315 | if e in removed: continue 316 | enums_defined.add(e) 317 | 318 | name = strip(e) 319 | if not valid_id(name): 320 | name = "_" + name 321 | header.write("{}constexpr {} {} = {};\n".format(gl_indent, enums[e]['type'], name, enums[e]['value'])) 322 | header.write("\n") 323 | for c in f['commands']: 324 | if c in functions_defined: continue 325 | if c in removed: continue 326 | functions_defined.add(c) 327 | command = commands[c] 328 | 329 | proto = command['proto'] 330 | pointer_name = internal_name(c, True) 331 | params = ", ".join(p[0] for p in command['params']) 332 | params_proto = ", ".join(p[1] for p in command['params']) 333 | 334 | header.write("{}inline {}({}){{ return {}({}); }}\n".format(gl_indent, proto, params_proto, pointer_name, params)) 335 | header.write("\n") 336 | 337 | for version in sorted(api_by_version.keys()): 338 | header.write("{}// {} {}\n\n".format(gl_indent, api_name[config.api], version)) 339 | write_features(api_by_version[version]) 340 | 341 | for name in api_by_extension.keys(): 342 | header.write("{}// {}\n\n".format(gl_indent, name)) 343 | write_features(api_by_extension[name]) 344 | 345 | if config.loader_namespace: 346 | header.write("{}namespace {}\n{}{{\n\n".format(gl_indent, config.loader_namespace, indent)) 347 | 348 | header.write("{}{}bool initialize();\n".format(gl_indent, sys_indent)) 349 | header.write("{}{}const char * api();\n".format(gl_indent, sys_indent)) 350 | header.write("{}{}int major_version();\n".format(gl_indent, sys_indent)) 351 | header.write("{}{}int minor_version();\n".format(gl_indent, sys_indent)) 352 | header.write("\n") 353 | 354 | header.write("{}{}bool has_extension(const char * name);\n".format(gl_indent, sys_indent)) 355 | 356 | for name in api_by_extension.keys(): 357 | header.write("{}{}bool ext_{}();\n".format(gl_indent, sys_indent, name[3:])) 358 | header.write("\n") 359 | 360 | if config.loader_namespace: 361 | header.write("{}}} // namespace {}\n\n".format(gl_indent, config.loader_namespace)) 362 | 363 | if config.namespace: 364 | header.write("}} // namespace {}\n\n".format(config.namespace)) 365 | 366 | # Write the source file 367 | 368 | source_definitions = """ 369 | #include 370 | #include 371 | 372 | #if defined(__APPLE__) 373 | #include 374 | #elif defined(__sgi) || defined (__sun) 375 | #include 376 | #include 377 | #elif defined(_WIN32) 378 | #include 379 | #elif defined(__ANDROID__) 380 | #include 381 | #else 382 | #include 383 | #endif 384 | 385 | """ 386 | 387 | get_proc_address_code = """ 388 | #if defined(__APPLE__) 389 | 390 | static void * get_proc_address(const char *func) 391 | { 392 | \tstatic void * image = dlopen("/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL", RTLD_LAZY); 393 | 394 | \tif (!image) return nullptr; 395 | 396 | \treturn dlsym(image, func); 397 | } 398 | 399 | #elif defined(__sgi) || defined (__sun) 400 | 401 | static void * get_proc_address(const char *func) 402 | { 403 | \tstatic void * image = dlopen(nullptr, RTLD_LAZY | RTLD_LOCAL); 404 | \tstatic void * gpa = image ? dlsym(image, "glXGetProcAddress") : nullptr; 405 | 406 | \tif (gpa) 407 | \t\treturn reinterpret_cast(gpa)(reinterpret_cast(name)); 408 | \telse 409 | \t\treturn dlsym(image, name); 410 | } 411 | 412 | #elif defined(_WIN32) 413 | 414 | #ifdef _MSC_VER 415 | #pragma warning(disable: 4055) 416 | #pragma warning(disable: 4054) 417 | #pragma warning(disable: 4996) 418 | #endif 419 | 420 | static int test_pointer(const PROC p) 421 | { 422 | \tptrdiff_t i; 423 | \tif (!p) return 0; 424 | \ti = (ptrdiff_t)p; 425 | 426 | \tif(i == 1 || i == 2 || i == 3 || i == -1) return 0; 427 | 428 | \treturn 1; 429 | } 430 | 431 | static void * get_proc_address(const char *name) 432 | { 433 | \tstatic HMODULE image = GetModuleHandleA("opengl32.dll"); 434 | 435 | \tPROC func = wglGetProcAddress(reinterpret_cast(name)); 436 | \tif (test_pointer(func)) 437 | \t{ 438 | \t\treturn reinterpret_cast(func); 439 | \t} 440 | 441 | \treturn reinterpret_cast(GetProcAddress(image, reinterpret_cast(name))); 442 | } 443 | 444 | #elif defined(__ANDROID__) 445 | 446 | static void * get_proc_address(const char *func) 447 | { 448 | \treturn reinterpret_cast(eglGetProcAddress(func)); 449 | } 450 | 451 | #else // GLX 452 | 453 | static void * get_proc_address(const char *func) 454 | { 455 | \treturn reinterpret_cast(glXGetProcAddress(reinterpret_cast(func))); 456 | } 457 | 458 | #endif 459 | """ 460 | 461 | with open(config.out_source, 'wt') as source: 462 | 463 | source.write("#include {}\n\n".format(config.include)) 464 | 465 | source.write(source_definitions) 466 | 467 | if config.namespace: 468 | source.write("namespace {}\n{{\n\n".format(config.namespace)) 469 | 470 | # Write internal pointers 471 | pointers_defined = set() 472 | 473 | if config.internal_namespace: 474 | source.write("{}namespace {}\n{}{{\n\n".format(gl_indent, config.internal_namespace, indent)) 475 | 476 | for line in get_proc_address_code.splitlines(): 477 | source.write(gl_indent + int_indent + line.replace("\t", indent) + "\n") 478 | source.write("\n") 479 | 480 | def internal_write_features(f): 481 | for c in f['commands']: 482 | if c in pointers_defined: continue 483 | if c in removed: continue 484 | pointers_defined.add(c) 485 | command = commands[c] 486 | 487 | proto = command['proto'].replace(strip(c), "(*" + internal_name(c, False) + ")") 488 | params_proto = ", ".join(p[1] for p in command['params']) 489 | 490 | source.write("{}{}{}({}) = nullptr;\n".format(gl_indent, int_indent, proto, params_proto)) 491 | source.write("\n") 492 | 493 | for version in sorted(api_by_version.keys()): 494 | source.write("{}{}// {} {}\n\n".format(gl_indent, int_indent, api_name[config.api], version)) 495 | internal_write_features(api_by_version[version]) 496 | 497 | for name in api_by_extension.keys(): 498 | source.write("{}{}// {}\n\n".format(gl_indent, int_indent, name)) 499 | internal_write_features(api_by_extension[name]) 500 | 501 | if config.internal_namespace: 502 | source.write("{}}} // namespace {}\n\n".format(gl_indent, config.internal_namespace)) 503 | 504 | pointers_defined = set() 505 | 506 | if config.loader_namespace: 507 | source.write("{}namespace {}\n{}{{\n\n".format(gl_indent, config.loader_namespace, indent)) 508 | 509 | for name in api_by_extension.keys(): 510 | source.write("{}{}static bool ext_{}_loaded = false;\n".format(gl_indent, int_indent, name)) 511 | source.write("\n") 512 | 513 | def write_loaders(f): 514 | for c in f['commands']: 515 | if c in pointers_defined: continue 516 | if c in removed: continue 517 | pointers_defined.add(c) 518 | 519 | command = commands[c] 520 | 521 | params_proto = ", ".join(p[2] for p in command['params']) 522 | 523 | source.write("{}{}{}{} = reinterpret_cast<{}(*)({})>({}(\"{}\"));\n".format(gl_indent, sys_indent, indent, internal_name(c, True), 524 | command['type'], params_proto, internal_name('get_proc_address', True), c)) 525 | source.write("{}{}{}if (!{}) return false;\n".format(gl_indent, sys_indent, indent, internal_name(c, True))) 526 | 527 | 528 | source.write("{}{}static bool load_core()\n".format(gl_indent, sys_indent)) 529 | source.write("{}{}{{\n".format(gl_indent, sys_indent)) 530 | for version in sorted(api_by_version.keys()): 531 | source.write("{}{}{}// {} {}\n\n".format(gl_indent, sys_indent, indent, api_name[config.api], version)) 532 | write_loaders(api_by_version[version]) 533 | source.write("\n") 534 | source.write("{}{}{}return true;\n".format(gl_indent, sys_indent, indent)) 535 | source.write("{}{}}}\n\n".format(gl_indent, sys_indent)) 536 | 537 | for name in api_by_extension.keys(): 538 | source.write("{}{}static bool load_ext_{}()\n".format(gl_indent, sys_indent, name)) 539 | source.write("{}{}{{\n".format(gl_indent, sys_indent)) 540 | write_loaders(api_by_extension[name]) 541 | source.write("\n") 542 | source.write("{}{}{}return true;\n".format(gl_indent, sys_indent, indent)) 543 | source.write("{}{}}}\n\n".format(gl_indent, sys_indent)) 544 | 545 | source.write("{}{}static std::unordered_set extensions;\n".format(gl_indent, sys_indent)) 546 | 547 | source.write("{}{}bool initialize()\n".format(gl_indent, sys_indent)) 548 | source.write("{}{}{{\n".format(gl_indent, sys_indent)) 549 | source.write("{}{}{}if (!load_core()) return false;\n".format(gl_indent, sys_indent, indent)) 550 | source.write("\n") 551 | source.write("{}{}{}GLint num_extensions;\n".format(gl_indent, sys_indent, indent)) 552 | source.write("{}{}{}{}({}, &num_extensions);\n".format(gl_indent, sys_indent, indent, internal_name('glGetIntegerv', True), enums['GL_NUM_EXTENSIONS']['value'])) 553 | source.write("{}{}{}for (GLint i = 0; i < num_extensions; ++i)\n".format(gl_indent, sys_indent, indent)) 554 | source.write("{}{}{}{}extensions.insert(reinterpret_cast({}({}, i)));\n".format(gl_indent, sys_indent, indent, indent, internal_name('glGetStringi', True), enums['GL_EXTENSIONS']['value'])) 555 | source.write("\n") 556 | for name in api_by_extension.keys(): 557 | source.write("{}{}{}if (extensions.count(\"{}\") > 0)\n".format(gl_indent, int_indent, indent, name)) 558 | source.write("{}{}{}{}ext_{}_loaded = load_ext_{}();\n".format(gl_indent, int_indent, indent, indent, name, name)) 559 | source.write("\n") 560 | source.write("{}{}{}return true;\n".format(gl_indent, sys_indent, indent)) 561 | source.write("{}{}}}\n".format(gl_indent, sys_indent)) 562 | source.write("\n") 563 | 564 | source.write("{}{}const char * api(){{ return \"{}\"; }}\n\n".format(gl_indent, sys_indent, api_name[config.api])) 565 | source.write("{}{}int major_version(){{ return {}; }}\n\n".format(gl_indent, sys_indent, config.version[0])) 566 | source.write("{}{}int minor_version(){{ return {}; }}\n\n".format(gl_indent, sys_indent, config.version[2])) 567 | 568 | source.write("{}{}bool has_extension(const char * name){{ return extensions.contains(name); }}\n\n".format(gl_indent, sys_indent)) 569 | 570 | for name in api_by_extension.keys(): 571 | source.write("{}{}bool ext_{}(){{ return ext_{}_loaded; }}\n".format(gl_indent, int_indent, name[3:], name)) 572 | source.write("\n") 573 | 574 | if config.loader_namespace: 575 | source.write("{}}} // namespace {}\n\n".format(gl_indent, config.loader_namespace)) 576 | 577 | if config.namespace: 578 | source.write("}} // namespace {}\n\n".format(config.namespace)) 579 | -------------------------------------------------------------------------------- /gl.cpp: -------------------------------------------------------------------------------- 1 | #include "gl.hpp" 2 | 3 | 4 | #include 5 | #include 6 | 7 | #if defined(__APPLE__) 8 | #include 9 | #elif defined(__sgi) || defined (__sun) 10 | #include 11 | #include 12 | #elif defined(_WIN32) 13 | #include 14 | #elif defined(__ANDROID__) 15 | #include 16 | #else 17 | #include 18 | #endif 19 | 20 | namespace gl 21 | { 22 | 23 | namespace internal 24 | { 25 | 26 | 27 | #if defined(__APPLE__) 28 | 29 | static void * get_proc_address(const char *func) 30 | { 31 | static void * image = dlopen("/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL", RTLD_LAZY); 32 | 33 | if (!image) return nullptr; 34 | 35 | return dlsym(image, func); 36 | } 37 | 38 | #elif defined(__sgi) || defined (__sun) 39 | 40 | static void * get_proc_address(const char *func) 41 | { 42 | static void * image = dlopen(nullptr, RTLD_LAZY | RTLD_LOCAL); 43 | static void * gpa = image ? dlsym(image, "glXGetProcAddress") : nullptr; 44 | 45 | if (gpa) 46 | return reinterpret_cast(gpa)(reinterpret_cast(name)); 47 | else 48 | return dlsym(image, name); 49 | } 50 | 51 | #elif defined(_WIN32) 52 | 53 | #ifdef _MSC_VER 54 | #pragma warning(disable: 4055) 55 | #pragma warning(disable: 4054) 56 | #pragma warning(disable: 4996) 57 | #endif 58 | 59 | static int test_pointer(const PROC p) 60 | { 61 | ptrdiff_t i; 62 | if (!p) return 0; 63 | i = (ptrdiff_t)p; 64 | 65 | if(i == 1 || i == 2 || i == 3 || i == -1) return 0; 66 | 67 | return 1; 68 | } 69 | 70 | static void * get_proc_address(const char *name) 71 | { 72 | static HMODULE image = GetModuleHandleA("opengl32.dll"); 73 | 74 | PROC func = wglGetProcAddress(reinterpret_cast(name)); 75 | if (test_pointer(func)) 76 | { 77 | return reinterpret_cast(func); 78 | } 79 | 80 | return reinterpret_cast(GetProcAddress(image, reinterpret_cast(name))); 81 | } 82 | 83 | #elif defined(__ANDROID__) 84 | 85 | static void * get_proc_address(const char *func) 86 | { 87 | return reinterpret_cast(eglGetProcAddress(func)); 88 | } 89 | 90 | #else // GLX 91 | 92 | static void * get_proc_address(const char *func) 93 | { 94 | return reinterpret_cast(glXGetProcAddress(reinterpret_cast(func))); 95 | } 96 | 97 | #endif 98 | 99 | // OpenGL 1.0 100 | 101 | void (*glCullFace)(GLenum mode) = nullptr; 102 | void (*glFrontFace)(GLenum mode) = nullptr; 103 | void (*glHint)(GLenum target, GLenum mode) = nullptr; 104 | void (*glLineWidth)(GLfloat width) = nullptr; 105 | void (*glPointSize)(GLfloat size) = nullptr; 106 | void (*glPolygonMode)(GLenum face, GLenum mode) = nullptr; 107 | void (*glScissor)(GLint x, GLint y, GLsizei width, GLsizei height) = nullptr; 108 | void (*glTexParameterf)(GLenum target, GLenum pname, GLfloat param) = nullptr; 109 | void (*glTexParameterfv)(GLenum target, GLenum pname, const GLfloat *params) = nullptr; 110 | void (*glTexParameteri)(GLenum target, GLenum pname, GLint param) = nullptr; 111 | void (*glTexParameteriv)(GLenum target, GLenum pname, const GLint *params) = nullptr; 112 | void (*glTexImage1D)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels) = nullptr; 113 | void (*glTexImage2D)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels) = nullptr; 114 | void (*glDrawBuffer)(GLenum buf) = nullptr; 115 | void (*glClear)(GLbitfield mask) = nullptr; 116 | void (*glClearColor)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) = nullptr; 117 | void (*glClearStencil)(GLint s) = nullptr; 118 | void (*glClearDepth)(GLdouble depth) = nullptr; 119 | void (*glStencilMask)(GLuint mask) = nullptr; 120 | void (*glColorMask)(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) = nullptr; 121 | void (*glDepthMask)(GLboolean flag) = nullptr; 122 | void (*glDisable)(GLenum cap) = nullptr; 123 | void (*glEnable)(GLenum cap) = nullptr; 124 | void (*glFinish)() = nullptr; 125 | void (*glFlush)() = nullptr; 126 | void (*glBlendFunc)(GLenum sfactor, GLenum dfactor) = nullptr; 127 | void (*glLogicOp)(GLenum opcode) = nullptr; 128 | void (*glStencilFunc)(GLenum func, GLint ref, GLuint mask) = nullptr; 129 | void (*glStencilOp)(GLenum fail, GLenum zfail, GLenum zpass) = nullptr; 130 | void (*glDepthFunc)(GLenum func) = nullptr; 131 | void (*glPixelStoref)(GLenum pname, GLfloat param) = nullptr; 132 | void (*glPixelStorei)(GLenum pname, GLint param) = nullptr; 133 | void (*glReadBuffer)(GLenum src) = nullptr; 134 | void (*glReadPixels)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels) = nullptr; 135 | void (*glGetBooleanv)(GLenum pname, GLboolean *data) = nullptr; 136 | void (*glGetDoublev)(GLenum pname, GLdouble *data) = nullptr; 137 | GLenum (*glGetError)() = nullptr; 138 | void (*glGetFloatv)(GLenum pname, GLfloat *data) = nullptr; 139 | void (*glGetIntegerv)(GLenum pname, GLint *data) = nullptr; 140 | const GLubyte *(*glGetString)(GLenum name) = nullptr; 141 | void (*glGetTexImage)(GLenum target, GLint level, GLenum format, GLenum type, void *pixels) = nullptr; 142 | void (*glGetTexParameterfv)(GLenum target, GLenum pname, GLfloat *params) = nullptr; 143 | void (*glGetTexParameteriv)(GLenum target, GLenum pname, GLint *params) = nullptr; 144 | void (*glGetTexLevelParameterfv)(GLenum target, GLint level, GLenum pname, GLfloat *params) = nullptr; 145 | void (*glGetTexLevelParameteriv)(GLenum target, GLint level, GLenum pname, GLint *params) = nullptr; 146 | GLboolean (*glIsEnabled)(GLenum cap) = nullptr; 147 | void (*glDepthRange)(GLdouble n, GLdouble f) = nullptr; 148 | void (*glViewport)(GLint x, GLint y, GLsizei width, GLsizei height) = nullptr; 149 | 150 | // OpenGL 1.1 151 | 152 | void (*glDrawArrays)(GLenum mode, GLint first, GLsizei count) = nullptr; 153 | void (*glDrawElements)(GLenum mode, GLsizei count, GLenum type, const void *indices) = nullptr; 154 | void (*glPolygonOffset)(GLfloat factor, GLfloat units) = nullptr; 155 | void (*glCopyTexImage1D)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border) = nullptr; 156 | void (*glCopyTexImage2D)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) = nullptr; 157 | void (*glCopyTexSubImage1D)(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width) = nullptr; 158 | void (*glCopyTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) = nullptr; 159 | void (*glTexSubImage1D)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels) = nullptr; 160 | void (*glTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels) = nullptr; 161 | void (*glBindTexture)(GLenum target, GLuint texture) = nullptr; 162 | void (*glDeleteTextures)(GLsizei n, const GLuint *textures) = nullptr; 163 | void (*glGenTextures)(GLsizei n, GLuint *textures) = nullptr; 164 | GLboolean (*glIsTexture)(GLuint texture) = nullptr; 165 | 166 | // OpenGL 1.2 167 | 168 | void (*glDrawRangeElements)(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices) = nullptr; 169 | void (*glTexImage3D)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels) = nullptr; 170 | void (*glTexSubImage3D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels) = nullptr; 171 | void (*glCopyTexSubImage3D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height) = nullptr; 172 | 173 | // OpenGL 1.3 174 | 175 | void (*glActiveTexture)(GLenum texture) = nullptr; 176 | void (*glSampleCoverage)(GLfloat value, GLboolean invert) = nullptr; 177 | void (*glCompressedTexImage3D)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data) = nullptr; 178 | void (*glCompressedTexImage2D)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data) = nullptr; 179 | void (*glCompressedTexImage1D)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data) = nullptr; 180 | void (*glCompressedTexSubImage3D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data) = nullptr; 181 | void (*glCompressedTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data) = nullptr; 182 | void (*glCompressedTexSubImage1D)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data) = nullptr; 183 | void (*glGetCompressedTexImage)(GLenum target, GLint level, void *img) = nullptr; 184 | 185 | // OpenGL 1.4 186 | 187 | void (*glBlendFuncSeparate)(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha) = nullptr; 188 | void (*glMultiDrawArrays)(GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount) = nullptr; 189 | void (*glMultiDrawElements)(GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount) = nullptr; 190 | void (*glPointParameterf)(GLenum pname, GLfloat param) = nullptr; 191 | void (*glPointParameterfv)(GLenum pname, const GLfloat *params) = nullptr; 192 | void (*glPointParameteri)(GLenum pname, GLint param) = nullptr; 193 | void (*glPointParameteriv)(GLenum pname, const GLint *params) = nullptr; 194 | void (*glBlendColor)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) = nullptr; 195 | void (*glBlendEquation)(GLenum mode) = nullptr; 196 | 197 | // OpenGL 1.5 198 | 199 | void (*glGenQueries)(GLsizei n, GLuint *ids) = nullptr; 200 | void (*glDeleteQueries)(GLsizei n, const GLuint *ids) = nullptr; 201 | GLboolean (*glIsQuery)(GLuint id) = nullptr; 202 | void (*glBeginQuery)(GLenum target, GLuint id) = nullptr; 203 | void (*glEndQuery)(GLenum target) = nullptr; 204 | void (*glGetQueryiv)(GLenum target, GLenum pname, GLint *params) = nullptr; 205 | void (*glGetQueryObjectiv)(GLuint id, GLenum pname, GLint *params) = nullptr; 206 | void (*glGetQueryObjectuiv)(GLuint id, GLenum pname, GLuint *params) = nullptr; 207 | void (*glBindBuffer)(GLenum target, GLuint buffer) = nullptr; 208 | void (*glDeleteBuffers)(GLsizei n, const GLuint *buffers) = nullptr; 209 | void (*glGenBuffers)(GLsizei n, GLuint *buffers) = nullptr; 210 | GLboolean (*glIsBuffer)(GLuint buffer) = nullptr; 211 | void (*glBufferData)(GLenum target, GLsizeiptr size, const void *data, GLenum usage) = nullptr; 212 | void (*glBufferSubData)(GLenum target, GLintptr offset, GLsizeiptr size, const void *data) = nullptr; 213 | void (*glGetBufferSubData)(GLenum target, GLintptr offset, GLsizeiptr size, void *data) = nullptr; 214 | void *(*glMapBuffer)(GLenum target, GLenum access) = nullptr; 215 | GLboolean (*glUnmapBuffer)(GLenum target) = nullptr; 216 | void (*glGetBufferParameteriv)(GLenum target, GLenum pname, GLint *params) = nullptr; 217 | void (*glGetBufferPointerv)(GLenum target, GLenum pname, void **params) = nullptr; 218 | 219 | // OpenGL 2.0 220 | 221 | void (*glBlendEquationSeparate)(GLenum modeRGB, GLenum modeAlpha) = nullptr; 222 | void (*glDrawBuffers)(GLsizei n, const GLenum *bufs) = nullptr; 223 | void (*glStencilOpSeparate)(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass) = nullptr; 224 | void (*glStencilFuncSeparate)(GLenum face, GLenum func, GLint ref, GLuint mask) = nullptr; 225 | void (*glStencilMaskSeparate)(GLenum face, GLuint mask) = nullptr; 226 | void (*glAttachShader)(GLuint program, GLuint shader) = nullptr; 227 | void (*glBindAttribLocation)(GLuint program, GLuint index, const GLchar *name) = nullptr; 228 | void (*glCompileShader)(GLuint shader) = nullptr; 229 | GLuint (*glCreateProgram)() = nullptr; 230 | GLuint (*glCreateShader)(GLenum type) = nullptr; 231 | void (*glDeleteProgram)(GLuint program) = nullptr; 232 | void (*glDeleteShader)(GLuint shader) = nullptr; 233 | void (*glDetachShader)(GLuint program, GLuint shader) = nullptr; 234 | void (*glDisableVertexAttribArray)(GLuint index) = nullptr; 235 | void (*glEnableVertexAttribArray)(GLuint index) = nullptr; 236 | void (*glGetActiveAttrib)(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name) = nullptr; 237 | void (*glGetActiveUniform)(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name) = nullptr; 238 | void (*glGetAttachedShaders)(GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders) = nullptr; 239 | GLint (*glGetAttribLocation)(GLuint program, const GLchar *name) = nullptr; 240 | void (*glGetProgramiv)(GLuint program, GLenum pname, GLint *params) = nullptr; 241 | void (*glGetProgramInfoLog)(GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog) = nullptr; 242 | void (*glGetShaderiv)(GLuint shader, GLenum pname, GLint *params) = nullptr; 243 | void (*glGetShaderInfoLog)(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog) = nullptr; 244 | void (*glGetShaderSource)(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source) = nullptr; 245 | GLint (*glGetUniformLocation)(GLuint program, const GLchar *name) = nullptr; 246 | void (*glGetUniformfv)(GLuint program, GLint location, GLfloat *params) = nullptr; 247 | void (*glGetUniformiv)(GLuint program, GLint location, GLint *params) = nullptr; 248 | void (*glGetVertexAttribdv)(GLuint index, GLenum pname, GLdouble *params) = nullptr; 249 | void (*glGetVertexAttribfv)(GLuint index, GLenum pname, GLfloat *params) = nullptr; 250 | void (*glGetVertexAttribiv)(GLuint index, GLenum pname, GLint *params) = nullptr; 251 | void (*glGetVertexAttribPointerv)(GLuint index, GLenum pname, void **pointer) = nullptr; 252 | GLboolean (*glIsProgram)(GLuint program) = nullptr; 253 | GLboolean (*glIsShader)(GLuint shader) = nullptr; 254 | void (*glLinkProgram)(GLuint program) = nullptr; 255 | void (*glShaderSource)(GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length) = nullptr; 256 | void (*glUseProgram)(GLuint program) = nullptr; 257 | void (*glUniform1f)(GLint location, GLfloat v0) = nullptr; 258 | void (*glUniform2f)(GLint location, GLfloat v0, GLfloat v1) = nullptr; 259 | void (*glUniform3f)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2) = nullptr; 260 | void (*glUniform4f)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) = nullptr; 261 | void (*glUniform1i)(GLint location, GLint v0) = nullptr; 262 | void (*glUniform2i)(GLint location, GLint v0, GLint v1) = nullptr; 263 | void (*glUniform3i)(GLint location, GLint v0, GLint v1, GLint v2) = nullptr; 264 | void (*glUniform4i)(GLint location, GLint v0, GLint v1, GLint v2, GLint v3) = nullptr; 265 | void (*glUniform1fv)(GLint location, GLsizei count, const GLfloat *value) = nullptr; 266 | void (*glUniform2fv)(GLint location, GLsizei count, const GLfloat *value) = nullptr; 267 | void (*glUniform3fv)(GLint location, GLsizei count, const GLfloat *value) = nullptr; 268 | void (*glUniform4fv)(GLint location, GLsizei count, const GLfloat *value) = nullptr; 269 | void (*glUniform1iv)(GLint location, GLsizei count, const GLint *value) = nullptr; 270 | void (*glUniform2iv)(GLint location, GLsizei count, const GLint *value) = nullptr; 271 | void (*glUniform3iv)(GLint location, GLsizei count, const GLint *value) = nullptr; 272 | void (*glUniform4iv)(GLint location, GLsizei count, const GLint *value) = nullptr; 273 | void (*glUniformMatrix2fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) = nullptr; 274 | void (*glUniformMatrix3fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) = nullptr; 275 | void (*glUniformMatrix4fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) = nullptr; 276 | void (*glValidateProgram)(GLuint program) = nullptr; 277 | void (*glVertexAttrib1d)(GLuint index, GLdouble x) = nullptr; 278 | void (*glVertexAttrib1dv)(GLuint index, const GLdouble *v) = nullptr; 279 | void (*glVertexAttrib1f)(GLuint index, GLfloat x) = nullptr; 280 | void (*glVertexAttrib1fv)(GLuint index, const GLfloat *v) = nullptr; 281 | void (*glVertexAttrib1s)(GLuint index, GLshort x) = nullptr; 282 | void (*glVertexAttrib1sv)(GLuint index, const GLshort *v) = nullptr; 283 | void (*glVertexAttrib2d)(GLuint index, GLdouble x, GLdouble y) = nullptr; 284 | void (*glVertexAttrib2dv)(GLuint index, const GLdouble *v) = nullptr; 285 | void (*glVertexAttrib2f)(GLuint index, GLfloat x, GLfloat y) = nullptr; 286 | void (*glVertexAttrib2fv)(GLuint index, const GLfloat *v) = nullptr; 287 | void (*glVertexAttrib2s)(GLuint index, GLshort x, GLshort y) = nullptr; 288 | void (*glVertexAttrib2sv)(GLuint index, const GLshort *v) = nullptr; 289 | void (*glVertexAttrib3d)(GLuint index, GLdouble x, GLdouble y, GLdouble z) = nullptr; 290 | void (*glVertexAttrib3dv)(GLuint index, const GLdouble *v) = nullptr; 291 | void (*glVertexAttrib3f)(GLuint index, GLfloat x, GLfloat y, GLfloat z) = nullptr; 292 | void (*glVertexAttrib3fv)(GLuint index, const GLfloat *v) = nullptr; 293 | void (*glVertexAttrib3s)(GLuint index, GLshort x, GLshort y, GLshort z) = nullptr; 294 | void (*glVertexAttrib3sv)(GLuint index, const GLshort *v) = nullptr; 295 | void (*glVertexAttrib4Nbv)(GLuint index, const GLbyte *v) = nullptr; 296 | void (*glVertexAttrib4Niv)(GLuint index, const GLint *v) = nullptr; 297 | void (*glVertexAttrib4Nsv)(GLuint index, const GLshort *v) = nullptr; 298 | void (*glVertexAttrib4Nub)(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w) = nullptr; 299 | void (*glVertexAttrib4Nubv)(GLuint index, const GLubyte *v) = nullptr; 300 | void (*glVertexAttrib4Nuiv)(GLuint index, const GLuint *v) = nullptr; 301 | void (*glVertexAttrib4Nusv)(GLuint index, const GLushort *v) = nullptr; 302 | void (*glVertexAttrib4bv)(GLuint index, const GLbyte *v) = nullptr; 303 | void (*glVertexAttrib4d)(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w) = nullptr; 304 | void (*glVertexAttrib4dv)(GLuint index, const GLdouble *v) = nullptr; 305 | void (*glVertexAttrib4f)(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) = nullptr; 306 | void (*glVertexAttrib4fv)(GLuint index, const GLfloat *v) = nullptr; 307 | void (*glVertexAttrib4iv)(GLuint index, const GLint *v) = nullptr; 308 | void (*glVertexAttrib4s)(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w) = nullptr; 309 | void (*glVertexAttrib4sv)(GLuint index, const GLshort *v) = nullptr; 310 | void (*glVertexAttrib4ubv)(GLuint index, const GLubyte *v) = nullptr; 311 | void (*glVertexAttrib4uiv)(GLuint index, const GLuint *v) = nullptr; 312 | void (*glVertexAttrib4usv)(GLuint index, const GLushort *v) = nullptr; 313 | void (*glVertexAttribPointer)(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer) = nullptr; 314 | 315 | // OpenGL 2.1 316 | 317 | void (*glUniformMatrix2x3fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) = nullptr; 318 | void (*glUniformMatrix3x2fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) = nullptr; 319 | void (*glUniformMatrix2x4fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) = nullptr; 320 | void (*glUniformMatrix4x2fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) = nullptr; 321 | void (*glUniformMatrix3x4fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) = nullptr; 322 | void (*glUniformMatrix4x3fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) = nullptr; 323 | 324 | // OpenGL 3.0 325 | 326 | void (*glColorMaski)(GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a) = nullptr; 327 | void (*glGetBooleani_v)(GLenum target, GLuint index, GLboolean *data) = nullptr; 328 | void (*glGetIntegeri_v)(GLenum target, GLuint index, GLint *data) = nullptr; 329 | void (*glEnablei)(GLenum target, GLuint index) = nullptr; 330 | void (*glDisablei)(GLenum target, GLuint index) = nullptr; 331 | GLboolean (*glIsEnabledi)(GLenum target, GLuint index) = nullptr; 332 | void (*glBeginTransformFeedback)(GLenum primitiveMode) = nullptr; 333 | void (*glEndTransformFeedback)() = nullptr; 334 | void (*glBindBufferRange)(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size) = nullptr; 335 | void (*glBindBufferBase)(GLenum target, GLuint index, GLuint buffer) = nullptr; 336 | void (*glTransformFeedbackVaryings)(GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode) = nullptr; 337 | void (*glGetTransformFeedbackVarying)(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name) = nullptr; 338 | void (*glClampColor)(GLenum target, GLenum clamp) = nullptr; 339 | void (*glBeginConditionalRender)(GLuint id, GLenum mode) = nullptr; 340 | void (*glEndConditionalRender)() = nullptr; 341 | void (*glVertexAttribIPointer)(GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer) = nullptr; 342 | void (*glGetVertexAttribIiv)(GLuint index, GLenum pname, GLint *params) = nullptr; 343 | void (*glGetVertexAttribIuiv)(GLuint index, GLenum pname, GLuint *params) = nullptr; 344 | void (*glVertexAttribI1i)(GLuint index, GLint x) = nullptr; 345 | void (*glVertexAttribI2i)(GLuint index, GLint x, GLint y) = nullptr; 346 | void (*glVertexAttribI3i)(GLuint index, GLint x, GLint y, GLint z) = nullptr; 347 | void (*glVertexAttribI4i)(GLuint index, GLint x, GLint y, GLint z, GLint w) = nullptr; 348 | void (*glVertexAttribI1ui)(GLuint index, GLuint x) = nullptr; 349 | void (*glVertexAttribI2ui)(GLuint index, GLuint x, GLuint y) = nullptr; 350 | void (*glVertexAttribI3ui)(GLuint index, GLuint x, GLuint y, GLuint z) = nullptr; 351 | void (*glVertexAttribI4ui)(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w) = nullptr; 352 | void (*glVertexAttribI1iv)(GLuint index, const GLint *v) = nullptr; 353 | void (*glVertexAttribI2iv)(GLuint index, const GLint *v) = nullptr; 354 | void (*glVertexAttribI3iv)(GLuint index, const GLint *v) = nullptr; 355 | void (*glVertexAttribI4iv)(GLuint index, const GLint *v) = nullptr; 356 | void (*glVertexAttribI1uiv)(GLuint index, const GLuint *v) = nullptr; 357 | void (*glVertexAttribI2uiv)(GLuint index, const GLuint *v) = nullptr; 358 | void (*glVertexAttribI3uiv)(GLuint index, const GLuint *v) = nullptr; 359 | void (*glVertexAttribI4uiv)(GLuint index, const GLuint *v) = nullptr; 360 | void (*glVertexAttribI4bv)(GLuint index, const GLbyte *v) = nullptr; 361 | void (*glVertexAttribI4sv)(GLuint index, const GLshort *v) = nullptr; 362 | void (*glVertexAttribI4ubv)(GLuint index, const GLubyte *v) = nullptr; 363 | void (*glVertexAttribI4usv)(GLuint index, const GLushort *v) = nullptr; 364 | void (*glGetUniformuiv)(GLuint program, GLint location, GLuint *params) = nullptr; 365 | void (*glBindFragDataLocation)(GLuint program, GLuint color, const GLchar *name) = nullptr; 366 | GLint (*glGetFragDataLocation)(GLuint program, const GLchar *name) = nullptr; 367 | void (*glUniform1ui)(GLint location, GLuint v0) = nullptr; 368 | void (*glUniform2ui)(GLint location, GLuint v0, GLuint v1) = nullptr; 369 | void (*glUniform3ui)(GLint location, GLuint v0, GLuint v1, GLuint v2) = nullptr; 370 | void (*glUniform4ui)(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) = nullptr; 371 | void (*glUniform1uiv)(GLint location, GLsizei count, const GLuint *value) = nullptr; 372 | void (*glUniform2uiv)(GLint location, GLsizei count, const GLuint *value) = nullptr; 373 | void (*glUniform3uiv)(GLint location, GLsizei count, const GLuint *value) = nullptr; 374 | void (*glUniform4uiv)(GLint location, GLsizei count, const GLuint *value) = nullptr; 375 | void (*glTexParameterIiv)(GLenum target, GLenum pname, const GLint *params) = nullptr; 376 | void (*glTexParameterIuiv)(GLenum target, GLenum pname, const GLuint *params) = nullptr; 377 | void (*glGetTexParameterIiv)(GLenum target, GLenum pname, GLint *params) = nullptr; 378 | void (*glGetTexParameterIuiv)(GLenum target, GLenum pname, GLuint *params) = nullptr; 379 | void (*glClearBufferiv)(GLenum buffer, GLint drawbuffer, const GLint *value) = nullptr; 380 | void (*glClearBufferuiv)(GLenum buffer, GLint drawbuffer, const GLuint *value) = nullptr; 381 | void (*glClearBufferfv)(GLenum buffer, GLint drawbuffer, const GLfloat *value) = nullptr; 382 | void (*glClearBufferfi)(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) = nullptr; 383 | const GLubyte *(*glGetStringi)(GLenum name, GLuint index) = nullptr; 384 | GLboolean (*glIsRenderbuffer)(GLuint renderbuffer) = nullptr; 385 | void (*glBindRenderbuffer)(GLenum target, GLuint renderbuffer) = nullptr; 386 | void (*glDeleteRenderbuffers)(GLsizei n, const GLuint *renderbuffers) = nullptr; 387 | void (*glGenRenderbuffers)(GLsizei n, GLuint *renderbuffers) = nullptr; 388 | void (*glRenderbufferStorage)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) = nullptr; 389 | void (*glGetRenderbufferParameteriv)(GLenum target, GLenum pname, GLint *params) = nullptr; 390 | GLboolean (*glIsFramebuffer)(GLuint framebuffer) = nullptr; 391 | void (*glBindFramebuffer)(GLenum target, GLuint framebuffer) = nullptr; 392 | void (*glDeleteFramebuffers)(GLsizei n, const GLuint *framebuffers) = nullptr; 393 | void (*glGenFramebuffers)(GLsizei n, GLuint *framebuffers) = nullptr; 394 | GLenum (*glCheckFramebufferStatus)(GLenum target) = nullptr; 395 | void (*glFramebufferTexture1D)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) = nullptr; 396 | void (*glFramebufferTexture2D)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) = nullptr; 397 | void (*glFramebufferTexture3D)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset) = nullptr; 398 | void (*glFramebufferRenderbuffer)(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) = nullptr; 399 | void (*glGetFramebufferAttachmentParameteriv)(GLenum target, GLenum attachment, GLenum pname, GLint *params) = nullptr; 400 | void (*glGenerateMipmap)(GLenum target) = nullptr; 401 | void (*glBlitFramebuffer)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) = nullptr; 402 | void (*glRenderbufferStorageMultisample)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) = nullptr; 403 | void (*glFramebufferTextureLayer)(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer) = nullptr; 404 | void *(*glMapBufferRange)(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) = nullptr; 405 | void (*glFlushMappedBufferRange)(GLenum target, GLintptr offset, GLsizeiptr length) = nullptr; 406 | void (*glBindVertexArray)(GLuint array) = nullptr; 407 | void (*glDeleteVertexArrays)(GLsizei n, const GLuint *arrays) = nullptr; 408 | void (*glGenVertexArrays)(GLsizei n, GLuint *arrays) = nullptr; 409 | GLboolean (*glIsVertexArray)(GLuint array) = nullptr; 410 | 411 | // OpenGL 3.1 412 | 413 | void (*glDrawArraysInstanced)(GLenum mode, GLint first, GLsizei count, GLsizei instancecount) = nullptr; 414 | void (*glDrawElementsInstanced)(GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount) = nullptr; 415 | void (*glTexBuffer)(GLenum target, GLenum internalformat, GLuint buffer) = nullptr; 416 | void (*glPrimitiveRestartIndex)(GLuint index) = nullptr; 417 | void (*glCopyBufferSubData)(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) = nullptr; 418 | void (*glGetUniformIndices)(GLuint program, GLsizei uniformCount, const GLchar *const*uniformNames, GLuint *uniformIndices) = nullptr; 419 | void (*glGetActiveUniformsiv)(GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params) = nullptr; 420 | void (*glGetActiveUniformName)(GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName) = nullptr; 421 | GLuint (*glGetUniformBlockIndex)(GLuint program, const GLchar *uniformBlockName) = nullptr; 422 | void (*glGetActiveUniformBlockiv)(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params) = nullptr; 423 | void (*glGetActiveUniformBlockName)(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName) = nullptr; 424 | void (*glUniformBlockBinding)(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding) = nullptr; 425 | 426 | // OpenGL 3.2 427 | 428 | void (*glDrawElementsBaseVertex)(GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex) = nullptr; 429 | void (*glDrawRangeElementsBaseVertex)(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex) = nullptr; 430 | void (*glDrawElementsInstancedBaseVertex)(GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex) = nullptr; 431 | void (*glMultiDrawElementsBaseVertex)(GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount, const GLint *basevertex) = nullptr; 432 | void (*glProvokingVertex)(GLenum mode) = nullptr; 433 | GLsync (*glFenceSync)(GLenum condition, GLbitfield flags) = nullptr; 434 | GLboolean (*glIsSync)(GLsync sync) = nullptr; 435 | void (*glDeleteSync)(GLsync sync) = nullptr; 436 | GLenum (*glClientWaitSync)(GLsync sync, GLbitfield flags, GLuint64 timeout) = nullptr; 437 | void (*glWaitSync)(GLsync sync, GLbitfield flags, GLuint64 timeout) = nullptr; 438 | void (*glGetInteger64v)(GLenum pname, GLint64 *data) = nullptr; 439 | void (*glGetSynciv)(GLsync sync, GLenum pname, GLsizei count, GLsizei *length, GLint *values) = nullptr; 440 | void (*glGetInteger64i_v)(GLenum target, GLuint index, GLint64 *data) = nullptr; 441 | void (*glGetBufferParameteri64v)(GLenum target, GLenum pname, GLint64 *params) = nullptr; 442 | void (*glFramebufferTexture)(GLenum target, GLenum attachment, GLuint texture, GLint level) = nullptr; 443 | void (*glTexImage2DMultisample)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations) = nullptr; 444 | void (*glTexImage3DMultisample)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations) = nullptr; 445 | void (*glGetMultisamplefv)(GLenum pname, GLuint index, GLfloat *val) = nullptr; 446 | void (*glSampleMaski)(GLuint maskNumber, GLbitfield mask) = nullptr; 447 | 448 | // OpenGL 3.3 449 | 450 | void (*glBindFragDataLocationIndexed)(GLuint program, GLuint colorNumber, GLuint index, const GLchar *name) = nullptr; 451 | GLint (*glGetFragDataIndex)(GLuint program, const GLchar *name) = nullptr; 452 | void (*glGenSamplers)(GLsizei count, GLuint *samplers) = nullptr; 453 | void (*glDeleteSamplers)(GLsizei count, const GLuint *samplers) = nullptr; 454 | GLboolean (*glIsSampler)(GLuint sampler) = nullptr; 455 | void (*glBindSampler)(GLuint unit, GLuint sampler) = nullptr; 456 | void (*glSamplerParameteri)(GLuint sampler, GLenum pname, GLint param) = nullptr; 457 | void (*glSamplerParameteriv)(GLuint sampler, GLenum pname, const GLint *param) = nullptr; 458 | void (*glSamplerParameterf)(GLuint sampler, GLenum pname, GLfloat param) = nullptr; 459 | void (*glSamplerParameterfv)(GLuint sampler, GLenum pname, const GLfloat *param) = nullptr; 460 | void (*glSamplerParameterIiv)(GLuint sampler, GLenum pname, const GLint *param) = nullptr; 461 | void (*glSamplerParameterIuiv)(GLuint sampler, GLenum pname, const GLuint *param) = nullptr; 462 | void (*glGetSamplerParameteriv)(GLuint sampler, GLenum pname, GLint *params) = nullptr; 463 | void (*glGetSamplerParameterIiv)(GLuint sampler, GLenum pname, GLint *params) = nullptr; 464 | void (*glGetSamplerParameterfv)(GLuint sampler, GLenum pname, GLfloat *params) = nullptr; 465 | void (*glGetSamplerParameterIuiv)(GLuint sampler, GLenum pname, GLuint *params) = nullptr; 466 | void (*glQueryCounter)(GLuint id, GLenum target) = nullptr; 467 | void (*glGetQueryObjecti64v)(GLuint id, GLenum pname, GLint64 *params) = nullptr; 468 | void (*glGetQueryObjectui64v)(GLuint id, GLenum pname, GLuint64 *params) = nullptr; 469 | void (*glVertexAttribDivisor)(GLuint index, GLuint divisor) = nullptr; 470 | void (*glVertexAttribP1ui)(GLuint index, GLenum type, GLboolean normalized, GLuint value) = nullptr; 471 | void (*glVertexAttribP1uiv)(GLuint index, GLenum type, GLboolean normalized, const GLuint *value) = nullptr; 472 | void (*glVertexAttribP2ui)(GLuint index, GLenum type, GLboolean normalized, GLuint value) = nullptr; 473 | void (*glVertexAttribP2uiv)(GLuint index, GLenum type, GLboolean normalized, const GLuint *value) = nullptr; 474 | void (*glVertexAttribP3ui)(GLuint index, GLenum type, GLboolean normalized, GLuint value) = nullptr; 475 | void (*glVertexAttribP3uiv)(GLuint index, GLenum type, GLboolean normalized, const GLuint *value) = nullptr; 476 | void (*glVertexAttribP4ui)(GLuint index, GLenum type, GLboolean normalized, GLuint value) = nullptr; 477 | void (*glVertexAttribP4uiv)(GLuint index, GLenum type, GLboolean normalized, const GLuint *value) = nullptr; 478 | 479 | // GL_ARB_compute_shader 480 | 481 | void (*glDispatchCompute)(GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z) = nullptr; 482 | void (*glDispatchComputeIndirect)(GLintptr indirect) = nullptr; 483 | 484 | // GL_ARB_texture_filter_anisotropic 485 | 486 | 487 | } // namespace internal 488 | 489 | namespace sys 490 | { 491 | 492 | static bool ext_GL_ARB_compute_shader_loaded = false; 493 | static bool ext_GL_ARB_texture_filter_anisotropic_loaded = false; 494 | 495 | static bool load_core() 496 | { 497 | // OpenGL 1.0 498 | 499 | internal::glCullFace = reinterpret_cast(internal::get_proc_address("glCullFace")); 500 | if (!internal::glCullFace) return false; 501 | internal::glFrontFace = reinterpret_cast(internal::get_proc_address("glFrontFace")); 502 | if (!internal::glFrontFace) return false; 503 | internal::glHint = reinterpret_cast(internal::get_proc_address("glHint")); 504 | if (!internal::glHint) return false; 505 | internal::glLineWidth = reinterpret_cast(internal::get_proc_address("glLineWidth")); 506 | if (!internal::glLineWidth) return false; 507 | internal::glPointSize = reinterpret_cast(internal::get_proc_address("glPointSize")); 508 | if (!internal::glPointSize) return false; 509 | internal::glPolygonMode = reinterpret_cast(internal::get_proc_address("glPolygonMode")); 510 | if (!internal::glPolygonMode) return false; 511 | internal::glScissor = reinterpret_cast(internal::get_proc_address("glScissor")); 512 | if (!internal::glScissor) return false; 513 | internal::glTexParameterf = reinterpret_cast(internal::get_proc_address("glTexParameterf")); 514 | if (!internal::glTexParameterf) return false; 515 | internal::glTexParameterfv = reinterpret_cast(internal::get_proc_address("glTexParameterfv")); 516 | if (!internal::glTexParameterfv) return false; 517 | internal::glTexParameteri = reinterpret_cast(internal::get_proc_address("glTexParameteri")); 518 | if (!internal::glTexParameteri) return false; 519 | internal::glTexParameteriv = reinterpret_cast(internal::get_proc_address("glTexParameteriv")); 520 | if (!internal::glTexParameteriv) return false; 521 | internal::glTexImage1D = reinterpret_cast(internal::get_proc_address("glTexImage1D")); 522 | if (!internal::glTexImage1D) return false; 523 | internal::glTexImage2D = reinterpret_cast(internal::get_proc_address("glTexImage2D")); 524 | if (!internal::glTexImage2D) return false; 525 | internal::glDrawBuffer = reinterpret_cast(internal::get_proc_address("glDrawBuffer")); 526 | if (!internal::glDrawBuffer) return false; 527 | internal::glClear = reinterpret_cast(internal::get_proc_address("glClear")); 528 | if (!internal::glClear) return false; 529 | internal::glClearColor = reinterpret_cast(internal::get_proc_address("glClearColor")); 530 | if (!internal::glClearColor) return false; 531 | internal::glClearStencil = reinterpret_cast(internal::get_proc_address("glClearStencil")); 532 | if (!internal::glClearStencil) return false; 533 | internal::glClearDepth = reinterpret_cast(internal::get_proc_address("glClearDepth")); 534 | if (!internal::glClearDepth) return false; 535 | internal::glStencilMask = reinterpret_cast(internal::get_proc_address("glStencilMask")); 536 | if (!internal::glStencilMask) return false; 537 | internal::glColorMask = reinterpret_cast(internal::get_proc_address("glColorMask")); 538 | if (!internal::glColorMask) return false; 539 | internal::glDepthMask = reinterpret_cast(internal::get_proc_address("glDepthMask")); 540 | if (!internal::glDepthMask) return false; 541 | internal::glDisable = reinterpret_cast(internal::get_proc_address("glDisable")); 542 | if (!internal::glDisable) return false; 543 | internal::glEnable = reinterpret_cast(internal::get_proc_address("glEnable")); 544 | if (!internal::glEnable) return false; 545 | internal::glFinish = reinterpret_cast(internal::get_proc_address("glFinish")); 546 | if (!internal::glFinish) return false; 547 | internal::glFlush = reinterpret_cast(internal::get_proc_address("glFlush")); 548 | if (!internal::glFlush) return false; 549 | internal::glBlendFunc = reinterpret_cast(internal::get_proc_address("glBlendFunc")); 550 | if (!internal::glBlendFunc) return false; 551 | internal::glLogicOp = reinterpret_cast(internal::get_proc_address("glLogicOp")); 552 | if (!internal::glLogicOp) return false; 553 | internal::glStencilFunc = reinterpret_cast(internal::get_proc_address("glStencilFunc")); 554 | if (!internal::glStencilFunc) return false; 555 | internal::glStencilOp = reinterpret_cast(internal::get_proc_address("glStencilOp")); 556 | if (!internal::glStencilOp) return false; 557 | internal::glDepthFunc = reinterpret_cast(internal::get_proc_address("glDepthFunc")); 558 | if (!internal::glDepthFunc) return false; 559 | internal::glPixelStoref = reinterpret_cast(internal::get_proc_address("glPixelStoref")); 560 | if (!internal::glPixelStoref) return false; 561 | internal::glPixelStorei = reinterpret_cast(internal::get_proc_address("glPixelStorei")); 562 | if (!internal::glPixelStorei) return false; 563 | internal::glReadBuffer = reinterpret_cast(internal::get_proc_address("glReadBuffer")); 564 | if (!internal::glReadBuffer) return false; 565 | internal::glReadPixels = reinterpret_cast(internal::get_proc_address("glReadPixels")); 566 | if (!internal::glReadPixels) return false; 567 | internal::glGetBooleanv = reinterpret_cast(internal::get_proc_address("glGetBooleanv")); 568 | if (!internal::glGetBooleanv) return false; 569 | internal::glGetDoublev = reinterpret_cast(internal::get_proc_address("glGetDoublev")); 570 | if (!internal::glGetDoublev) return false; 571 | internal::glGetError = reinterpret_cast(internal::get_proc_address("glGetError")); 572 | if (!internal::glGetError) return false; 573 | internal::glGetFloatv = reinterpret_cast(internal::get_proc_address("glGetFloatv")); 574 | if (!internal::glGetFloatv) return false; 575 | internal::glGetIntegerv = reinterpret_cast(internal::get_proc_address("glGetIntegerv")); 576 | if (!internal::glGetIntegerv) return false; 577 | internal::glGetString = reinterpret_cast(internal::get_proc_address("glGetString")); 578 | if (!internal::glGetString) return false; 579 | internal::glGetTexImage = reinterpret_cast(internal::get_proc_address("glGetTexImage")); 580 | if (!internal::glGetTexImage) return false; 581 | internal::glGetTexParameterfv = reinterpret_cast(internal::get_proc_address("glGetTexParameterfv")); 582 | if (!internal::glGetTexParameterfv) return false; 583 | internal::glGetTexParameteriv = reinterpret_cast(internal::get_proc_address("glGetTexParameteriv")); 584 | if (!internal::glGetTexParameteriv) return false; 585 | internal::glGetTexLevelParameterfv = reinterpret_cast(internal::get_proc_address("glGetTexLevelParameterfv")); 586 | if (!internal::glGetTexLevelParameterfv) return false; 587 | internal::glGetTexLevelParameteriv = reinterpret_cast(internal::get_proc_address("glGetTexLevelParameteriv")); 588 | if (!internal::glGetTexLevelParameteriv) return false; 589 | internal::glIsEnabled = reinterpret_cast(internal::get_proc_address("glIsEnabled")); 590 | if (!internal::glIsEnabled) return false; 591 | internal::glDepthRange = reinterpret_cast(internal::get_proc_address("glDepthRange")); 592 | if (!internal::glDepthRange) return false; 593 | internal::glViewport = reinterpret_cast(internal::get_proc_address("glViewport")); 594 | if (!internal::glViewport) return false; 595 | 596 | // OpenGL 1.1 597 | 598 | internal::glDrawArrays = reinterpret_cast(internal::get_proc_address("glDrawArrays")); 599 | if (!internal::glDrawArrays) return false; 600 | internal::glDrawElements = reinterpret_cast(internal::get_proc_address("glDrawElements")); 601 | if (!internal::glDrawElements) return false; 602 | internal::glPolygonOffset = reinterpret_cast(internal::get_proc_address("glPolygonOffset")); 603 | if (!internal::glPolygonOffset) return false; 604 | internal::glCopyTexImage1D = reinterpret_cast(internal::get_proc_address("glCopyTexImage1D")); 605 | if (!internal::glCopyTexImage1D) return false; 606 | internal::glCopyTexImage2D = reinterpret_cast(internal::get_proc_address("glCopyTexImage2D")); 607 | if (!internal::glCopyTexImage2D) return false; 608 | internal::glCopyTexSubImage1D = reinterpret_cast(internal::get_proc_address("glCopyTexSubImage1D")); 609 | if (!internal::glCopyTexSubImage1D) return false; 610 | internal::glCopyTexSubImage2D = reinterpret_cast(internal::get_proc_address("glCopyTexSubImage2D")); 611 | if (!internal::glCopyTexSubImage2D) return false; 612 | internal::glTexSubImage1D = reinterpret_cast(internal::get_proc_address("glTexSubImage1D")); 613 | if (!internal::glTexSubImage1D) return false; 614 | internal::glTexSubImage2D = reinterpret_cast(internal::get_proc_address("glTexSubImage2D")); 615 | if (!internal::glTexSubImage2D) return false; 616 | internal::glBindTexture = reinterpret_cast(internal::get_proc_address("glBindTexture")); 617 | if (!internal::glBindTexture) return false; 618 | internal::glDeleteTextures = reinterpret_cast(internal::get_proc_address("glDeleteTextures")); 619 | if (!internal::glDeleteTextures) return false; 620 | internal::glGenTextures = reinterpret_cast(internal::get_proc_address("glGenTextures")); 621 | if (!internal::glGenTextures) return false; 622 | internal::glIsTexture = reinterpret_cast(internal::get_proc_address("glIsTexture")); 623 | if (!internal::glIsTexture) return false; 624 | 625 | // OpenGL 1.2 626 | 627 | internal::glDrawRangeElements = reinterpret_cast(internal::get_proc_address("glDrawRangeElements")); 628 | if (!internal::glDrawRangeElements) return false; 629 | internal::glTexImage3D = reinterpret_cast(internal::get_proc_address("glTexImage3D")); 630 | if (!internal::glTexImage3D) return false; 631 | internal::glTexSubImage3D = reinterpret_cast(internal::get_proc_address("glTexSubImage3D")); 632 | if (!internal::glTexSubImage3D) return false; 633 | internal::glCopyTexSubImage3D = reinterpret_cast(internal::get_proc_address("glCopyTexSubImage3D")); 634 | if (!internal::glCopyTexSubImage3D) return false; 635 | 636 | // OpenGL 1.3 637 | 638 | internal::glActiveTexture = reinterpret_cast(internal::get_proc_address("glActiveTexture")); 639 | if (!internal::glActiveTexture) return false; 640 | internal::glSampleCoverage = reinterpret_cast(internal::get_proc_address("glSampleCoverage")); 641 | if (!internal::glSampleCoverage) return false; 642 | internal::glCompressedTexImage3D = reinterpret_cast(internal::get_proc_address("glCompressedTexImage3D")); 643 | if (!internal::glCompressedTexImage3D) return false; 644 | internal::glCompressedTexImage2D = reinterpret_cast(internal::get_proc_address("glCompressedTexImage2D")); 645 | if (!internal::glCompressedTexImage2D) return false; 646 | internal::glCompressedTexImage1D = reinterpret_cast(internal::get_proc_address("glCompressedTexImage1D")); 647 | if (!internal::glCompressedTexImage1D) return false; 648 | internal::glCompressedTexSubImage3D = reinterpret_cast(internal::get_proc_address("glCompressedTexSubImage3D")); 649 | if (!internal::glCompressedTexSubImage3D) return false; 650 | internal::glCompressedTexSubImage2D = reinterpret_cast(internal::get_proc_address("glCompressedTexSubImage2D")); 651 | if (!internal::glCompressedTexSubImage2D) return false; 652 | internal::glCompressedTexSubImage1D = reinterpret_cast(internal::get_proc_address("glCompressedTexSubImage1D")); 653 | if (!internal::glCompressedTexSubImage1D) return false; 654 | internal::glGetCompressedTexImage = reinterpret_cast(internal::get_proc_address("glGetCompressedTexImage")); 655 | if (!internal::glGetCompressedTexImage) return false; 656 | 657 | // OpenGL 1.4 658 | 659 | internal::glBlendFuncSeparate = reinterpret_cast(internal::get_proc_address("glBlendFuncSeparate")); 660 | if (!internal::glBlendFuncSeparate) return false; 661 | internal::glMultiDrawArrays = reinterpret_cast(internal::get_proc_address("glMultiDrawArrays")); 662 | if (!internal::glMultiDrawArrays) return false; 663 | internal::glMultiDrawElements = reinterpret_cast(internal::get_proc_address("glMultiDrawElements")); 664 | if (!internal::glMultiDrawElements) return false; 665 | internal::glPointParameterf = reinterpret_cast(internal::get_proc_address("glPointParameterf")); 666 | if (!internal::glPointParameterf) return false; 667 | internal::glPointParameterfv = reinterpret_cast(internal::get_proc_address("glPointParameterfv")); 668 | if (!internal::glPointParameterfv) return false; 669 | internal::glPointParameteri = reinterpret_cast(internal::get_proc_address("glPointParameteri")); 670 | if (!internal::glPointParameteri) return false; 671 | internal::glPointParameteriv = reinterpret_cast(internal::get_proc_address("glPointParameteriv")); 672 | if (!internal::glPointParameteriv) return false; 673 | internal::glBlendColor = reinterpret_cast(internal::get_proc_address("glBlendColor")); 674 | if (!internal::glBlendColor) return false; 675 | internal::glBlendEquation = reinterpret_cast(internal::get_proc_address("glBlendEquation")); 676 | if (!internal::glBlendEquation) return false; 677 | 678 | // OpenGL 1.5 679 | 680 | internal::glGenQueries = reinterpret_cast(internal::get_proc_address("glGenQueries")); 681 | if (!internal::glGenQueries) return false; 682 | internal::glDeleteQueries = reinterpret_cast(internal::get_proc_address("glDeleteQueries")); 683 | if (!internal::glDeleteQueries) return false; 684 | internal::glIsQuery = reinterpret_cast(internal::get_proc_address("glIsQuery")); 685 | if (!internal::glIsQuery) return false; 686 | internal::glBeginQuery = reinterpret_cast(internal::get_proc_address("glBeginQuery")); 687 | if (!internal::glBeginQuery) return false; 688 | internal::glEndQuery = reinterpret_cast(internal::get_proc_address("glEndQuery")); 689 | if (!internal::glEndQuery) return false; 690 | internal::glGetQueryiv = reinterpret_cast(internal::get_proc_address("glGetQueryiv")); 691 | if (!internal::glGetQueryiv) return false; 692 | internal::glGetQueryObjectiv = reinterpret_cast(internal::get_proc_address("glGetQueryObjectiv")); 693 | if (!internal::glGetQueryObjectiv) return false; 694 | internal::glGetQueryObjectuiv = reinterpret_cast(internal::get_proc_address("glGetQueryObjectuiv")); 695 | if (!internal::glGetQueryObjectuiv) return false; 696 | internal::glBindBuffer = reinterpret_cast(internal::get_proc_address("glBindBuffer")); 697 | if (!internal::glBindBuffer) return false; 698 | internal::glDeleteBuffers = reinterpret_cast(internal::get_proc_address("glDeleteBuffers")); 699 | if (!internal::glDeleteBuffers) return false; 700 | internal::glGenBuffers = reinterpret_cast(internal::get_proc_address("glGenBuffers")); 701 | if (!internal::glGenBuffers) return false; 702 | internal::glIsBuffer = reinterpret_cast(internal::get_proc_address("glIsBuffer")); 703 | if (!internal::glIsBuffer) return false; 704 | internal::glBufferData = reinterpret_cast(internal::get_proc_address("glBufferData")); 705 | if (!internal::glBufferData) return false; 706 | internal::glBufferSubData = reinterpret_cast(internal::get_proc_address("glBufferSubData")); 707 | if (!internal::glBufferSubData) return false; 708 | internal::glGetBufferSubData = reinterpret_cast(internal::get_proc_address("glGetBufferSubData")); 709 | if (!internal::glGetBufferSubData) return false; 710 | internal::glMapBuffer = reinterpret_cast(internal::get_proc_address("glMapBuffer")); 711 | if (!internal::glMapBuffer) return false; 712 | internal::glUnmapBuffer = reinterpret_cast(internal::get_proc_address("glUnmapBuffer")); 713 | if (!internal::glUnmapBuffer) return false; 714 | internal::glGetBufferParameteriv = reinterpret_cast(internal::get_proc_address("glGetBufferParameteriv")); 715 | if (!internal::glGetBufferParameteriv) return false; 716 | internal::glGetBufferPointerv = reinterpret_cast(internal::get_proc_address("glGetBufferPointerv")); 717 | if (!internal::glGetBufferPointerv) return false; 718 | 719 | // OpenGL 2.0 720 | 721 | internal::glBlendEquationSeparate = reinterpret_cast(internal::get_proc_address("glBlendEquationSeparate")); 722 | if (!internal::glBlendEquationSeparate) return false; 723 | internal::glDrawBuffers = reinterpret_cast(internal::get_proc_address("glDrawBuffers")); 724 | if (!internal::glDrawBuffers) return false; 725 | internal::glStencilOpSeparate = reinterpret_cast(internal::get_proc_address("glStencilOpSeparate")); 726 | if (!internal::glStencilOpSeparate) return false; 727 | internal::glStencilFuncSeparate = reinterpret_cast(internal::get_proc_address("glStencilFuncSeparate")); 728 | if (!internal::glStencilFuncSeparate) return false; 729 | internal::glStencilMaskSeparate = reinterpret_cast(internal::get_proc_address("glStencilMaskSeparate")); 730 | if (!internal::glStencilMaskSeparate) return false; 731 | internal::glAttachShader = reinterpret_cast(internal::get_proc_address("glAttachShader")); 732 | if (!internal::glAttachShader) return false; 733 | internal::glBindAttribLocation = reinterpret_cast(internal::get_proc_address("glBindAttribLocation")); 734 | if (!internal::glBindAttribLocation) return false; 735 | internal::glCompileShader = reinterpret_cast(internal::get_proc_address("glCompileShader")); 736 | if (!internal::glCompileShader) return false; 737 | internal::glCreateProgram = reinterpret_cast(internal::get_proc_address("glCreateProgram")); 738 | if (!internal::glCreateProgram) return false; 739 | internal::glCreateShader = reinterpret_cast(internal::get_proc_address("glCreateShader")); 740 | if (!internal::glCreateShader) return false; 741 | internal::glDeleteProgram = reinterpret_cast(internal::get_proc_address("glDeleteProgram")); 742 | if (!internal::glDeleteProgram) return false; 743 | internal::glDeleteShader = reinterpret_cast(internal::get_proc_address("glDeleteShader")); 744 | if (!internal::glDeleteShader) return false; 745 | internal::glDetachShader = reinterpret_cast(internal::get_proc_address("glDetachShader")); 746 | if (!internal::glDetachShader) return false; 747 | internal::glDisableVertexAttribArray = reinterpret_cast(internal::get_proc_address("glDisableVertexAttribArray")); 748 | if (!internal::glDisableVertexAttribArray) return false; 749 | internal::glEnableVertexAttribArray = reinterpret_cast(internal::get_proc_address("glEnableVertexAttribArray")); 750 | if (!internal::glEnableVertexAttribArray) return false; 751 | internal::glGetActiveAttrib = reinterpret_cast(internal::get_proc_address("glGetActiveAttrib")); 752 | if (!internal::glGetActiveAttrib) return false; 753 | internal::glGetActiveUniform = reinterpret_cast(internal::get_proc_address("glGetActiveUniform")); 754 | if (!internal::glGetActiveUniform) return false; 755 | internal::glGetAttachedShaders = reinterpret_cast(internal::get_proc_address("glGetAttachedShaders")); 756 | if (!internal::glGetAttachedShaders) return false; 757 | internal::glGetAttribLocation = reinterpret_cast(internal::get_proc_address("glGetAttribLocation")); 758 | if (!internal::glGetAttribLocation) return false; 759 | internal::glGetProgramiv = reinterpret_cast(internal::get_proc_address("glGetProgramiv")); 760 | if (!internal::glGetProgramiv) return false; 761 | internal::glGetProgramInfoLog = reinterpret_cast(internal::get_proc_address("glGetProgramInfoLog")); 762 | if (!internal::glGetProgramInfoLog) return false; 763 | internal::glGetShaderiv = reinterpret_cast(internal::get_proc_address("glGetShaderiv")); 764 | if (!internal::glGetShaderiv) return false; 765 | internal::glGetShaderInfoLog = reinterpret_cast(internal::get_proc_address("glGetShaderInfoLog")); 766 | if (!internal::glGetShaderInfoLog) return false; 767 | internal::glGetShaderSource = reinterpret_cast(internal::get_proc_address("glGetShaderSource")); 768 | if (!internal::glGetShaderSource) return false; 769 | internal::glGetUniformLocation = reinterpret_cast(internal::get_proc_address("glGetUniformLocation")); 770 | if (!internal::glGetUniformLocation) return false; 771 | internal::glGetUniformfv = reinterpret_cast(internal::get_proc_address("glGetUniformfv")); 772 | if (!internal::glGetUniformfv) return false; 773 | internal::glGetUniformiv = reinterpret_cast(internal::get_proc_address("glGetUniformiv")); 774 | if (!internal::glGetUniformiv) return false; 775 | internal::glGetVertexAttribdv = reinterpret_cast(internal::get_proc_address("glGetVertexAttribdv")); 776 | if (!internal::glGetVertexAttribdv) return false; 777 | internal::glGetVertexAttribfv = reinterpret_cast(internal::get_proc_address("glGetVertexAttribfv")); 778 | if (!internal::glGetVertexAttribfv) return false; 779 | internal::glGetVertexAttribiv = reinterpret_cast(internal::get_proc_address("glGetVertexAttribiv")); 780 | if (!internal::glGetVertexAttribiv) return false; 781 | internal::glGetVertexAttribPointerv = reinterpret_cast(internal::get_proc_address("glGetVertexAttribPointerv")); 782 | if (!internal::glGetVertexAttribPointerv) return false; 783 | internal::glIsProgram = reinterpret_cast(internal::get_proc_address("glIsProgram")); 784 | if (!internal::glIsProgram) return false; 785 | internal::glIsShader = reinterpret_cast(internal::get_proc_address("glIsShader")); 786 | if (!internal::glIsShader) return false; 787 | internal::glLinkProgram = reinterpret_cast(internal::get_proc_address("glLinkProgram")); 788 | if (!internal::glLinkProgram) return false; 789 | internal::glShaderSource = reinterpret_cast(internal::get_proc_address("glShaderSource")); 790 | if (!internal::glShaderSource) return false; 791 | internal::glUseProgram = reinterpret_cast(internal::get_proc_address("glUseProgram")); 792 | if (!internal::glUseProgram) return false; 793 | internal::glUniform1f = reinterpret_cast(internal::get_proc_address("glUniform1f")); 794 | if (!internal::glUniform1f) return false; 795 | internal::glUniform2f = reinterpret_cast(internal::get_proc_address("glUniform2f")); 796 | if (!internal::glUniform2f) return false; 797 | internal::glUniform3f = reinterpret_cast(internal::get_proc_address("glUniform3f")); 798 | if (!internal::glUniform3f) return false; 799 | internal::glUniform4f = reinterpret_cast(internal::get_proc_address("glUniform4f")); 800 | if (!internal::glUniform4f) return false; 801 | internal::glUniform1i = reinterpret_cast(internal::get_proc_address("glUniform1i")); 802 | if (!internal::glUniform1i) return false; 803 | internal::glUniform2i = reinterpret_cast(internal::get_proc_address("glUniform2i")); 804 | if (!internal::glUniform2i) return false; 805 | internal::glUniform3i = reinterpret_cast(internal::get_proc_address("glUniform3i")); 806 | if (!internal::glUniform3i) return false; 807 | internal::glUniform4i = reinterpret_cast(internal::get_proc_address("glUniform4i")); 808 | if (!internal::glUniform4i) return false; 809 | internal::glUniform1fv = reinterpret_cast(internal::get_proc_address("glUniform1fv")); 810 | if (!internal::glUniform1fv) return false; 811 | internal::glUniform2fv = reinterpret_cast(internal::get_proc_address("glUniform2fv")); 812 | if (!internal::glUniform2fv) return false; 813 | internal::glUniform3fv = reinterpret_cast(internal::get_proc_address("glUniform3fv")); 814 | if (!internal::glUniform3fv) return false; 815 | internal::glUniform4fv = reinterpret_cast(internal::get_proc_address("glUniform4fv")); 816 | if (!internal::glUniform4fv) return false; 817 | internal::glUniform1iv = reinterpret_cast(internal::get_proc_address("glUniform1iv")); 818 | if (!internal::glUniform1iv) return false; 819 | internal::glUniform2iv = reinterpret_cast(internal::get_proc_address("glUniform2iv")); 820 | if (!internal::glUniform2iv) return false; 821 | internal::glUniform3iv = reinterpret_cast(internal::get_proc_address("glUniform3iv")); 822 | if (!internal::glUniform3iv) return false; 823 | internal::glUniform4iv = reinterpret_cast(internal::get_proc_address("glUniform4iv")); 824 | if (!internal::glUniform4iv) return false; 825 | internal::glUniformMatrix2fv = reinterpret_cast(internal::get_proc_address("glUniformMatrix2fv")); 826 | if (!internal::glUniformMatrix2fv) return false; 827 | internal::glUniformMatrix3fv = reinterpret_cast(internal::get_proc_address("glUniformMatrix3fv")); 828 | if (!internal::glUniformMatrix3fv) return false; 829 | internal::glUniformMatrix4fv = reinterpret_cast(internal::get_proc_address("glUniformMatrix4fv")); 830 | if (!internal::glUniformMatrix4fv) return false; 831 | internal::glValidateProgram = reinterpret_cast(internal::get_proc_address("glValidateProgram")); 832 | if (!internal::glValidateProgram) return false; 833 | internal::glVertexAttrib1d = reinterpret_cast(internal::get_proc_address("glVertexAttrib1d")); 834 | if (!internal::glVertexAttrib1d) return false; 835 | internal::glVertexAttrib1dv = reinterpret_cast(internal::get_proc_address("glVertexAttrib1dv")); 836 | if (!internal::glVertexAttrib1dv) return false; 837 | internal::glVertexAttrib1f = reinterpret_cast(internal::get_proc_address("glVertexAttrib1f")); 838 | if (!internal::glVertexAttrib1f) return false; 839 | internal::glVertexAttrib1fv = reinterpret_cast(internal::get_proc_address("glVertexAttrib1fv")); 840 | if (!internal::glVertexAttrib1fv) return false; 841 | internal::glVertexAttrib1s = reinterpret_cast(internal::get_proc_address("glVertexAttrib1s")); 842 | if (!internal::glVertexAttrib1s) return false; 843 | internal::glVertexAttrib1sv = reinterpret_cast(internal::get_proc_address("glVertexAttrib1sv")); 844 | if (!internal::glVertexAttrib1sv) return false; 845 | internal::glVertexAttrib2d = reinterpret_cast(internal::get_proc_address("glVertexAttrib2d")); 846 | if (!internal::glVertexAttrib2d) return false; 847 | internal::glVertexAttrib2dv = reinterpret_cast(internal::get_proc_address("glVertexAttrib2dv")); 848 | if (!internal::glVertexAttrib2dv) return false; 849 | internal::glVertexAttrib2f = reinterpret_cast(internal::get_proc_address("glVertexAttrib2f")); 850 | if (!internal::glVertexAttrib2f) return false; 851 | internal::glVertexAttrib2fv = reinterpret_cast(internal::get_proc_address("glVertexAttrib2fv")); 852 | if (!internal::glVertexAttrib2fv) return false; 853 | internal::glVertexAttrib2s = reinterpret_cast(internal::get_proc_address("glVertexAttrib2s")); 854 | if (!internal::glVertexAttrib2s) return false; 855 | internal::glVertexAttrib2sv = reinterpret_cast(internal::get_proc_address("glVertexAttrib2sv")); 856 | if (!internal::glVertexAttrib2sv) return false; 857 | internal::glVertexAttrib3d = reinterpret_cast(internal::get_proc_address("glVertexAttrib3d")); 858 | if (!internal::glVertexAttrib3d) return false; 859 | internal::glVertexAttrib3dv = reinterpret_cast(internal::get_proc_address("glVertexAttrib3dv")); 860 | if (!internal::glVertexAttrib3dv) return false; 861 | internal::glVertexAttrib3f = reinterpret_cast(internal::get_proc_address("glVertexAttrib3f")); 862 | if (!internal::glVertexAttrib3f) return false; 863 | internal::glVertexAttrib3fv = reinterpret_cast(internal::get_proc_address("glVertexAttrib3fv")); 864 | if (!internal::glVertexAttrib3fv) return false; 865 | internal::glVertexAttrib3s = reinterpret_cast(internal::get_proc_address("glVertexAttrib3s")); 866 | if (!internal::glVertexAttrib3s) return false; 867 | internal::glVertexAttrib3sv = reinterpret_cast(internal::get_proc_address("glVertexAttrib3sv")); 868 | if (!internal::glVertexAttrib3sv) return false; 869 | internal::glVertexAttrib4Nbv = reinterpret_cast(internal::get_proc_address("glVertexAttrib4Nbv")); 870 | if (!internal::glVertexAttrib4Nbv) return false; 871 | internal::glVertexAttrib4Niv = reinterpret_cast(internal::get_proc_address("glVertexAttrib4Niv")); 872 | if (!internal::glVertexAttrib4Niv) return false; 873 | internal::glVertexAttrib4Nsv = reinterpret_cast(internal::get_proc_address("glVertexAttrib4Nsv")); 874 | if (!internal::glVertexAttrib4Nsv) return false; 875 | internal::glVertexAttrib4Nub = reinterpret_cast(internal::get_proc_address("glVertexAttrib4Nub")); 876 | if (!internal::glVertexAttrib4Nub) return false; 877 | internal::glVertexAttrib4Nubv = reinterpret_cast(internal::get_proc_address("glVertexAttrib4Nubv")); 878 | if (!internal::glVertexAttrib4Nubv) return false; 879 | internal::glVertexAttrib4Nuiv = reinterpret_cast(internal::get_proc_address("glVertexAttrib4Nuiv")); 880 | if (!internal::glVertexAttrib4Nuiv) return false; 881 | internal::glVertexAttrib4Nusv = reinterpret_cast(internal::get_proc_address("glVertexAttrib4Nusv")); 882 | if (!internal::glVertexAttrib4Nusv) return false; 883 | internal::glVertexAttrib4bv = reinterpret_cast(internal::get_proc_address("glVertexAttrib4bv")); 884 | if (!internal::glVertexAttrib4bv) return false; 885 | internal::glVertexAttrib4d = reinterpret_cast(internal::get_proc_address("glVertexAttrib4d")); 886 | if (!internal::glVertexAttrib4d) return false; 887 | internal::glVertexAttrib4dv = reinterpret_cast(internal::get_proc_address("glVertexAttrib4dv")); 888 | if (!internal::glVertexAttrib4dv) return false; 889 | internal::glVertexAttrib4f = reinterpret_cast(internal::get_proc_address("glVertexAttrib4f")); 890 | if (!internal::glVertexAttrib4f) return false; 891 | internal::glVertexAttrib4fv = reinterpret_cast(internal::get_proc_address("glVertexAttrib4fv")); 892 | if (!internal::glVertexAttrib4fv) return false; 893 | internal::glVertexAttrib4iv = reinterpret_cast(internal::get_proc_address("glVertexAttrib4iv")); 894 | if (!internal::glVertexAttrib4iv) return false; 895 | internal::glVertexAttrib4s = reinterpret_cast(internal::get_proc_address("glVertexAttrib4s")); 896 | if (!internal::glVertexAttrib4s) return false; 897 | internal::glVertexAttrib4sv = reinterpret_cast(internal::get_proc_address("glVertexAttrib4sv")); 898 | if (!internal::glVertexAttrib4sv) return false; 899 | internal::glVertexAttrib4ubv = reinterpret_cast(internal::get_proc_address("glVertexAttrib4ubv")); 900 | if (!internal::glVertexAttrib4ubv) return false; 901 | internal::glVertexAttrib4uiv = reinterpret_cast(internal::get_proc_address("glVertexAttrib4uiv")); 902 | if (!internal::glVertexAttrib4uiv) return false; 903 | internal::glVertexAttrib4usv = reinterpret_cast(internal::get_proc_address("glVertexAttrib4usv")); 904 | if (!internal::glVertexAttrib4usv) return false; 905 | internal::glVertexAttribPointer = reinterpret_cast(internal::get_proc_address("glVertexAttribPointer")); 906 | if (!internal::glVertexAttribPointer) return false; 907 | 908 | // OpenGL 2.1 909 | 910 | internal::glUniformMatrix2x3fv = reinterpret_cast(internal::get_proc_address("glUniformMatrix2x3fv")); 911 | if (!internal::glUniformMatrix2x3fv) return false; 912 | internal::glUniformMatrix3x2fv = reinterpret_cast(internal::get_proc_address("glUniformMatrix3x2fv")); 913 | if (!internal::glUniformMatrix3x2fv) return false; 914 | internal::glUniformMatrix2x4fv = reinterpret_cast(internal::get_proc_address("glUniformMatrix2x4fv")); 915 | if (!internal::glUniformMatrix2x4fv) return false; 916 | internal::glUniformMatrix4x2fv = reinterpret_cast(internal::get_proc_address("glUniformMatrix4x2fv")); 917 | if (!internal::glUniformMatrix4x2fv) return false; 918 | internal::glUniformMatrix3x4fv = reinterpret_cast(internal::get_proc_address("glUniformMatrix3x4fv")); 919 | if (!internal::glUniformMatrix3x4fv) return false; 920 | internal::glUniformMatrix4x3fv = reinterpret_cast(internal::get_proc_address("glUniformMatrix4x3fv")); 921 | if (!internal::glUniformMatrix4x3fv) return false; 922 | 923 | // OpenGL 3.0 924 | 925 | internal::glColorMaski = reinterpret_cast(internal::get_proc_address("glColorMaski")); 926 | if (!internal::glColorMaski) return false; 927 | internal::glGetBooleani_v = reinterpret_cast(internal::get_proc_address("glGetBooleani_v")); 928 | if (!internal::glGetBooleani_v) return false; 929 | internal::glGetIntegeri_v = reinterpret_cast(internal::get_proc_address("glGetIntegeri_v")); 930 | if (!internal::glGetIntegeri_v) return false; 931 | internal::glEnablei = reinterpret_cast(internal::get_proc_address("glEnablei")); 932 | if (!internal::glEnablei) return false; 933 | internal::glDisablei = reinterpret_cast(internal::get_proc_address("glDisablei")); 934 | if (!internal::glDisablei) return false; 935 | internal::glIsEnabledi = reinterpret_cast(internal::get_proc_address("glIsEnabledi")); 936 | if (!internal::glIsEnabledi) return false; 937 | internal::glBeginTransformFeedback = reinterpret_cast(internal::get_proc_address("glBeginTransformFeedback")); 938 | if (!internal::glBeginTransformFeedback) return false; 939 | internal::glEndTransformFeedback = reinterpret_cast(internal::get_proc_address("glEndTransformFeedback")); 940 | if (!internal::glEndTransformFeedback) return false; 941 | internal::glBindBufferRange = reinterpret_cast(internal::get_proc_address("glBindBufferRange")); 942 | if (!internal::glBindBufferRange) return false; 943 | internal::glBindBufferBase = reinterpret_cast(internal::get_proc_address("glBindBufferBase")); 944 | if (!internal::glBindBufferBase) return false; 945 | internal::glTransformFeedbackVaryings = reinterpret_cast(internal::get_proc_address("glTransformFeedbackVaryings")); 946 | if (!internal::glTransformFeedbackVaryings) return false; 947 | internal::glGetTransformFeedbackVarying = reinterpret_cast(internal::get_proc_address("glGetTransformFeedbackVarying")); 948 | if (!internal::glGetTransformFeedbackVarying) return false; 949 | internal::glClampColor = reinterpret_cast(internal::get_proc_address("glClampColor")); 950 | if (!internal::glClampColor) return false; 951 | internal::glBeginConditionalRender = reinterpret_cast(internal::get_proc_address("glBeginConditionalRender")); 952 | if (!internal::glBeginConditionalRender) return false; 953 | internal::glEndConditionalRender = reinterpret_cast(internal::get_proc_address("glEndConditionalRender")); 954 | if (!internal::glEndConditionalRender) return false; 955 | internal::glVertexAttribIPointer = reinterpret_cast(internal::get_proc_address("glVertexAttribIPointer")); 956 | if (!internal::glVertexAttribIPointer) return false; 957 | internal::glGetVertexAttribIiv = reinterpret_cast(internal::get_proc_address("glGetVertexAttribIiv")); 958 | if (!internal::glGetVertexAttribIiv) return false; 959 | internal::glGetVertexAttribIuiv = reinterpret_cast(internal::get_proc_address("glGetVertexAttribIuiv")); 960 | if (!internal::glGetVertexAttribIuiv) return false; 961 | internal::glVertexAttribI1i = reinterpret_cast(internal::get_proc_address("glVertexAttribI1i")); 962 | if (!internal::glVertexAttribI1i) return false; 963 | internal::glVertexAttribI2i = reinterpret_cast(internal::get_proc_address("glVertexAttribI2i")); 964 | if (!internal::glVertexAttribI2i) return false; 965 | internal::glVertexAttribI3i = reinterpret_cast(internal::get_proc_address("glVertexAttribI3i")); 966 | if (!internal::glVertexAttribI3i) return false; 967 | internal::glVertexAttribI4i = reinterpret_cast(internal::get_proc_address("glVertexAttribI4i")); 968 | if (!internal::glVertexAttribI4i) return false; 969 | internal::glVertexAttribI1ui = reinterpret_cast(internal::get_proc_address("glVertexAttribI1ui")); 970 | if (!internal::glVertexAttribI1ui) return false; 971 | internal::glVertexAttribI2ui = reinterpret_cast(internal::get_proc_address("glVertexAttribI2ui")); 972 | if (!internal::glVertexAttribI2ui) return false; 973 | internal::glVertexAttribI3ui = reinterpret_cast(internal::get_proc_address("glVertexAttribI3ui")); 974 | if (!internal::glVertexAttribI3ui) return false; 975 | internal::glVertexAttribI4ui = reinterpret_cast(internal::get_proc_address("glVertexAttribI4ui")); 976 | if (!internal::glVertexAttribI4ui) return false; 977 | internal::glVertexAttribI1iv = reinterpret_cast(internal::get_proc_address("glVertexAttribI1iv")); 978 | if (!internal::glVertexAttribI1iv) return false; 979 | internal::glVertexAttribI2iv = reinterpret_cast(internal::get_proc_address("glVertexAttribI2iv")); 980 | if (!internal::glVertexAttribI2iv) return false; 981 | internal::glVertexAttribI3iv = reinterpret_cast(internal::get_proc_address("glVertexAttribI3iv")); 982 | if (!internal::glVertexAttribI3iv) return false; 983 | internal::glVertexAttribI4iv = reinterpret_cast(internal::get_proc_address("glVertexAttribI4iv")); 984 | if (!internal::glVertexAttribI4iv) return false; 985 | internal::glVertexAttribI1uiv = reinterpret_cast(internal::get_proc_address("glVertexAttribI1uiv")); 986 | if (!internal::glVertexAttribI1uiv) return false; 987 | internal::glVertexAttribI2uiv = reinterpret_cast(internal::get_proc_address("glVertexAttribI2uiv")); 988 | if (!internal::glVertexAttribI2uiv) return false; 989 | internal::glVertexAttribI3uiv = reinterpret_cast(internal::get_proc_address("glVertexAttribI3uiv")); 990 | if (!internal::glVertexAttribI3uiv) return false; 991 | internal::glVertexAttribI4uiv = reinterpret_cast(internal::get_proc_address("glVertexAttribI4uiv")); 992 | if (!internal::glVertexAttribI4uiv) return false; 993 | internal::glVertexAttribI4bv = reinterpret_cast(internal::get_proc_address("glVertexAttribI4bv")); 994 | if (!internal::glVertexAttribI4bv) return false; 995 | internal::glVertexAttribI4sv = reinterpret_cast(internal::get_proc_address("glVertexAttribI4sv")); 996 | if (!internal::glVertexAttribI4sv) return false; 997 | internal::glVertexAttribI4ubv = reinterpret_cast(internal::get_proc_address("glVertexAttribI4ubv")); 998 | if (!internal::glVertexAttribI4ubv) return false; 999 | internal::glVertexAttribI4usv = reinterpret_cast(internal::get_proc_address("glVertexAttribI4usv")); 1000 | if (!internal::glVertexAttribI4usv) return false; 1001 | internal::glGetUniformuiv = reinterpret_cast(internal::get_proc_address("glGetUniformuiv")); 1002 | if (!internal::glGetUniformuiv) return false; 1003 | internal::glBindFragDataLocation = reinterpret_cast(internal::get_proc_address("glBindFragDataLocation")); 1004 | if (!internal::glBindFragDataLocation) return false; 1005 | internal::glGetFragDataLocation = reinterpret_cast(internal::get_proc_address("glGetFragDataLocation")); 1006 | if (!internal::glGetFragDataLocation) return false; 1007 | internal::glUniform1ui = reinterpret_cast(internal::get_proc_address("glUniform1ui")); 1008 | if (!internal::glUniform1ui) return false; 1009 | internal::glUniform2ui = reinterpret_cast(internal::get_proc_address("glUniform2ui")); 1010 | if (!internal::glUniform2ui) return false; 1011 | internal::glUniform3ui = reinterpret_cast(internal::get_proc_address("glUniform3ui")); 1012 | if (!internal::glUniform3ui) return false; 1013 | internal::glUniform4ui = reinterpret_cast(internal::get_proc_address("glUniform4ui")); 1014 | if (!internal::glUniform4ui) return false; 1015 | internal::glUniform1uiv = reinterpret_cast(internal::get_proc_address("glUniform1uiv")); 1016 | if (!internal::glUniform1uiv) return false; 1017 | internal::glUniform2uiv = reinterpret_cast(internal::get_proc_address("glUniform2uiv")); 1018 | if (!internal::glUniform2uiv) return false; 1019 | internal::glUniform3uiv = reinterpret_cast(internal::get_proc_address("glUniform3uiv")); 1020 | if (!internal::glUniform3uiv) return false; 1021 | internal::glUniform4uiv = reinterpret_cast(internal::get_proc_address("glUniform4uiv")); 1022 | if (!internal::glUniform4uiv) return false; 1023 | internal::glTexParameterIiv = reinterpret_cast(internal::get_proc_address("glTexParameterIiv")); 1024 | if (!internal::glTexParameterIiv) return false; 1025 | internal::glTexParameterIuiv = reinterpret_cast(internal::get_proc_address("glTexParameterIuiv")); 1026 | if (!internal::glTexParameterIuiv) return false; 1027 | internal::glGetTexParameterIiv = reinterpret_cast(internal::get_proc_address("glGetTexParameterIiv")); 1028 | if (!internal::glGetTexParameterIiv) return false; 1029 | internal::glGetTexParameterIuiv = reinterpret_cast(internal::get_proc_address("glGetTexParameterIuiv")); 1030 | if (!internal::glGetTexParameterIuiv) return false; 1031 | internal::glClearBufferiv = reinterpret_cast(internal::get_proc_address("glClearBufferiv")); 1032 | if (!internal::glClearBufferiv) return false; 1033 | internal::glClearBufferuiv = reinterpret_cast(internal::get_proc_address("glClearBufferuiv")); 1034 | if (!internal::glClearBufferuiv) return false; 1035 | internal::glClearBufferfv = reinterpret_cast(internal::get_proc_address("glClearBufferfv")); 1036 | if (!internal::glClearBufferfv) return false; 1037 | internal::glClearBufferfi = reinterpret_cast(internal::get_proc_address("glClearBufferfi")); 1038 | if (!internal::glClearBufferfi) return false; 1039 | internal::glGetStringi = reinterpret_cast(internal::get_proc_address("glGetStringi")); 1040 | if (!internal::glGetStringi) return false; 1041 | internal::glIsRenderbuffer = reinterpret_cast(internal::get_proc_address("glIsRenderbuffer")); 1042 | if (!internal::glIsRenderbuffer) return false; 1043 | internal::glBindRenderbuffer = reinterpret_cast(internal::get_proc_address("glBindRenderbuffer")); 1044 | if (!internal::glBindRenderbuffer) return false; 1045 | internal::glDeleteRenderbuffers = reinterpret_cast(internal::get_proc_address("glDeleteRenderbuffers")); 1046 | if (!internal::glDeleteRenderbuffers) return false; 1047 | internal::glGenRenderbuffers = reinterpret_cast(internal::get_proc_address("glGenRenderbuffers")); 1048 | if (!internal::glGenRenderbuffers) return false; 1049 | internal::glRenderbufferStorage = reinterpret_cast(internal::get_proc_address("glRenderbufferStorage")); 1050 | if (!internal::glRenderbufferStorage) return false; 1051 | internal::glGetRenderbufferParameteriv = reinterpret_cast(internal::get_proc_address("glGetRenderbufferParameteriv")); 1052 | if (!internal::glGetRenderbufferParameteriv) return false; 1053 | internal::glIsFramebuffer = reinterpret_cast(internal::get_proc_address("glIsFramebuffer")); 1054 | if (!internal::glIsFramebuffer) return false; 1055 | internal::glBindFramebuffer = reinterpret_cast(internal::get_proc_address("glBindFramebuffer")); 1056 | if (!internal::glBindFramebuffer) return false; 1057 | internal::glDeleteFramebuffers = reinterpret_cast(internal::get_proc_address("glDeleteFramebuffers")); 1058 | if (!internal::glDeleteFramebuffers) return false; 1059 | internal::glGenFramebuffers = reinterpret_cast(internal::get_proc_address("glGenFramebuffers")); 1060 | if (!internal::glGenFramebuffers) return false; 1061 | internal::glCheckFramebufferStatus = reinterpret_cast(internal::get_proc_address("glCheckFramebufferStatus")); 1062 | if (!internal::glCheckFramebufferStatus) return false; 1063 | internal::glFramebufferTexture1D = reinterpret_cast(internal::get_proc_address("glFramebufferTexture1D")); 1064 | if (!internal::glFramebufferTexture1D) return false; 1065 | internal::glFramebufferTexture2D = reinterpret_cast(internal::get_proc_address("glFramebufferTexture2D")); 1066 | if (!internal::glFramebufferTexture2D) return false; 1067 | internal::glFramebufferTexture3D = reinterpret_cast(internal::get_proc_address("glFramebufferTexture3D")); 1068 | if (!internal::glFramebufferTexture3D) return false; 1069 | internal::glFramebufferRenderbuffer = reinterpret_cast(internal::get_proc_address("glFramebufferRenderbuffer")); 1070 | if (!internal::glFramebufferRenderbuffer) return false; 1071 | internal::glGetFramebufferAttachmentParameteriv = reinterpret_cast(internal::get_proc_address("glGetFramebufferAttachmentParameteriv")); 1072 | if (!internal::glGetFramebufferAttachmentParameteriv) return false; 1073 | internal::glGenerateMipmap = reinterpret_cast(internal::get_proc_address("glGenerateMipmap")); 1074 | if (!internal::glGenerateMipmap) return false; 1075 | internal::glBlitFramebuffer = reinterpret_cast(internal::get_proc_address("glBlitFramebuffer")); 1076 | if (!internal::glBlitFramebuffer) return false; 1077 | internal::glRenderbufferStorageMultisample = reinterpret_cast(internal::get_proc_address("glRenderbufferStorageMultisample")); 1078 | if (!internal::glRenderbufferStorageMultisample) return false; 1079 | internal::glFramebufferTextureLayer = reinterpret_cast(internal::get_proc_address("glFramebufferTextureLayer")); 1080 | if (!internal::glFramebufferTextureLayer) return false; 1081 | internal::glMapBufferRange = reinterpret_cast(internal::get_proc_address("glMapBufferRange")); 1082 | if (!internal::glMapBufferRange) return false; 1083 | internal::glFlushMappedBufferRange = reinterpret_cast(internal::get_proc_address("glFlushMappedBufferRange")); 1084 | if (!internal::glFlushMappedBufferRange) return false; 1085 | internal::glBindVertexArray = reinterpret_cast(internal::get_proc_address("glBindVertexArray")); 1086 | if (!internal::glBindVertexArray) return false; 1087 | internal::glDeleteVertexArrays = reinterpret_cast(internal::get_proc_address("glDeleteVertexArrays")); 1088 | if (!internal::glDeleteVertexArrays) return false; 1089 | internal::glGenVertexArrays = reinterpret_cast(internal::get_proc_address("glGenVertexArrays")); 1090 | if (!internal::glGenVertexArrays) return false; 1091 | internal::glIsVertexArray = reinterpret_cast(internal::get_proc_address("glIsVertexArray")); 1092 | if (!internal::glIsVertexArray) return false; 1093 | 1094 | // OpenGL 3.1 1095 | 1096 | internal::glDrawArraysInstanced = reinterpret_cast(internal::get_proc_address("glDrawArraysInstanced")); 1097 | if (!internal::glDrawArraysInstanced) return false; 1098 | internal::glDrawElementsInstanced = reinterpret_cast(internal::get_proc_address("glDrawElementsInstanced")); 1099 | if (!internal::glDrawElementsInstanced) return false; 1100 | internal::glTexBuffer = reinterpret_cast(internal::get_proc_address("glTexBuffer")); 1101 | if (!internal::glTexBuffer) return false; 1102 | internal::glPrimitiveRestartIndex = reinterpret_cast(internal::get_proc_address("glPrimitiveRestartIndex")); 1103 | if (!internal::glPrimitiveRestartIndex) return false; 1104 | internal::glCopyBufferSubData = reinterpret_cast(internal::get_proc_address("glCopyBufferSubData")); 1105 | if (!internal::glCopyBufferSubData) return false; 1106 | internal::glGetUniformIndices = reinterpret_cast(internal::get_proc_address("glGetUniformIndices")); 1107 | if (!internal::glGetUniformIndices) return false; 1108 | internal::glGetActiveUniformsiv = reinterpret_cast(internal::get_proc_address("glGetActiveUniformsiv")); 1109 | if (!internal::glGetActiveUniformsiv) return false; 1110 | internal::glGetActiveUniformName = reinterpret_cast(internal::get_proc_address("glGetActiveUniformName")); 1111 | if (!internal::glGetActiveUniformName) return false; 1112 | internal::glGetUniformBlockIndex = reinterpret_cast(internal::get_proc_address("glGetUniformBlockIndex")); 1113 | if (!internal::glGetUniformBlockIndex) return false; 1114 | internal::glGetActiveUniformBlockiv = reinterpret_cast(internal::get_proc_address("glGetActiveUniformBlockiv")); 1115 | if (!internal::glGetActiveUniformBlockiv) return false; 1116 | internal::glGetActiveUniformBlockName = reinterpret_cast(internal::get_proc_address("glGetActiveUniformBlockName")); 1117 | if (!internal::glGetActiveUniformBlockName) return false; 1118 | internal::glUniformBlockBinding = reinterpret_cast(internal::get_proc_address("glUniformBlockBinding")); 1119 | if (!internal::glUniformBlockBinding) return false; 1120 | 1121 | // OpenGL 3.2 1122 | 1123 | internal::glDrawElementsBaseVertex = reinterpret_cast(internal::get_proc_address("glDrawElementsBaseVertex")); 1124 | if (!internal::glDrawElementsBaseVertex) return false; 1125 | internal::glDrawRangeElementsBaseVertex = reinterpret_cast(internal::get_proc_address("glDrawRangeElementsBaseVertex")); 1126 | if (!internal::glDrawRangeElementsBaseVertex) return false; 1127 | internal::glDrawElementsInstancedBaseVertex = reinterpret_cast(internal::get_proc_address("glDrawElementsInstancedBaseVertex")); 1128 | if (!internal::glDrawElementsInstancedBaseVertex) return false; 1129 | internal::glMultiDrawElementsBaseVertex = reinterpret_cast(internal::get_proc_address("glMultiDrawElementsBaseVertex")); 1130 | if (!internal::glMultiDrawElementsBaseVertex) return false; 1131 | internal::glProvokingVertex = reinterpret_cast(internal::get_proc_address("glProvokingVertex")); 1132 | if (!internal::glProvokingVertex) return false; 1133 | internal::glFenceSync = reinterpret_cast(internal::get_proc_address("glFenceSync")); 1134 | if (!internal::glFenceSync) return false; 1135 | internal::glIsSync = reinterpret_cast(internal::get_proc_address("glIsSync")); 1136 | if (!internal::glIsSync) return false; 1137 | internal::glDeleteSync = reinterpret_cast(internal::get_proc_address("glDeleteSync")); 1138 | if (!internal::glDeleteSync) return false; 1139 | internal::glClientWaitSync = reinterpret_cast(internal::get_proc_address("glClientWaitSync")); 1140 | if (!internal::glClientWaitSync) return false; 1141 | internal::glWaitSync = reinterpret_cast(internal::get_proc_address("glWaitSync")); 1142 | if (!internal::glWaitSync) return false; 1143 | internal::glGetInteger64v = reinterpret_cast(internal::get_proc_address("glGetInteger64v")); 1144 | if (!internal::glGetInteger64v) return false; 1145 | internal::glGetSynciv = reinterpret_cast(internal::get_proc_address("glGetSynciv")); 1146 | if (!internal::glGetSynciv) return false; 1147 | internal::glGetInteger64i_v = reinterpret_cast(internal::get_proc_address("glGetInteger64i_v")); 1148 | if (!internal::glGetInteger64i_v) return false; 1149 | internal::glGetBufferParameteri64v = reinterpret_cast(internal::get_proc_address("glGetBufferParameteri64v")); 1150 | if (!internal::glGetBufferParameteri64v) return false; 1151 | internal::glFramebufferTexture = reinterpret_cast(internal::get_proc_address("glFramebufferTexture")); 1152 | if (!internal::glFramebufferTexture) return false; 1153 | internal::glTexImage2DMultisample = reinterpret_cast(internal::get_proc_address("glTexImage2DMultisample")); 1154 | if (!internal::glTexImage2DMultisample) return false; 1155 | internal::glTexImage3DMultisample = reinterpret_cast(internal::get_proc_address("glTexImage3DMultisample")); 1156 | if (!internal::glTexImage3DMultisample) return false; 1157 | internal::glGetMultisamplefv = reinterpret_cast(internal::get_proc_address("glGetMultisamplefv")); 1158 | if (!internal::glGetMultisamplefv) return false; 1159 | internal::glSampleMaski = reinterpret_cast(internal::get_proc_address("glSampleMaski")); 1160 | if (!internal::glSampleMaski) return false; 1161 | 1162 | // OpenGL 3.3 1163 | 1164 | internal::glBindFragDataLocationIndexed = reinterpret_cast(internal::get_proc_address("glBindFragDataLocationIndexed")); 1165 | if (!internal::glBindFragDataLocationIndexed) return false; 1166 | internal::glGetFragDataIndex = reinterpret_cast(internal::get_proc_address("glGetFragDataIndex")); 1167 | if (!internal::glGetFragDataIndex) return false; 1168 | internal::glGenSamplers = reinterpret_cast(internal::get_proc_address("glGenSamplers")); 1169 | if (!internal::glGenSamplers) return false; 1170 | internal::glDeleteSamplers = reinterpret_cast(internal::get_proc_address("glDeleteSamplers")); 1171 | if (!internal::glDeleteSamplers) return false; 1172 | internal::glIsSampler = reinterpret_cast(internal::get_proc_address("glIsSampler")); 1173 | if (!internal::glIsSampler) return false; 1174 | internal::glBindSampler = reinterpret_cast(internal::get_proc_address("glBindSampler")); 1175 | if (!internal::glBindSampler) return false; 1176 | internal::glSamplerParameteri = reinterpret_cast(internal::get_proc_address("glSamplerParameteri")); 1177 | if (!internal::glSamplerParameteri) return false; 1178 | internal::glSamplerParameteriv = reinterpret_cast(internal::get_proc_address("glSamplerParameteriv")); 1179 | if (!internal::glSamplerParameteriv) return false; 1180 | internal::glSamplerParameterf = reinterpret_cast(internal::get_proc_address("glSamplerParameterf")); 1181 | if (!internal::glSamplerParameterf) return false; 1182 | internal::glSamplerParameterfv = reinterpret_cast(internal::get_proc_address("glSamplerParameterfv")); 1183 | if (!internal::glSamplerParameterfv) return false; 1184 | internal::glSamplerParameterIiv = reinterpret_cast(internal::get_proc_address("glSamplerParameterIiv")); 1185 | if (!internal::glSamplerParameterIiv) return false; 1186 | internal::glSamplerParameterIuiv = reinterpret_cast(internal::get_proc_address("glSamplerParameterIuiv")); 1187 | if (!internal::glSamplerParameterIuiv) return false; 1188 | internal::glGetSamplerParameteriv = reinterpret_cast(internal::get_proc_address("glGetSamplerParameteriv")); 1189 | if (!internal::glGetSamplerParameteriv) return false; 1190 | internal::glGetSamplerParameterIiv = reinterpret_cast(internal::get_proc_address("glGetSamplerParameterIiv")); 1191 | if (!internal::glGetSamplerParameterIiv) return false; 1192 | internal::glGetSamplerParameterfv = reinterpret_cast(internal::get_proc_address("glGetSamplerParameterfv")); 1193 | if (!internal::glGetSamplerParameterfv) return false; 1194 | internal::glGetSamplerParameterIuiv = reinterpret_cast(internal::get_proc_address("glGetSamplerParameterIuiv")); 1195 | if (!internal::glGetSamplerParameterIuiv) return false; 1196 | internal::glQueryCounter = reinterpret_cast(internal::get_proc_address("glQueryCounter")); 1197 | if (!internal::glQueryCounter) return false; 1198 | internal::glGetQueryObjecti64v = reinterpret_cast(internal::get_proc_address("glGetQueryObjecti64v")); 1199 | if (!internal::glGetQueryObjecti64v) return false; 1200 | internal::glGetQueryObjectui64v = reinterpret_cast(internal::get_proc_address("glGetQueryObjectui64v")); 1201 | if (!internal::glGetQueryObjectui64v) return false; 1202 | internal::glVertexAttribDivisor = reinterpret_cast(internal::get_proc_address("glVertexAttribDivisor")); 1203 | if (!internal::glVertexAttribDivisor) return false; 1204 | internal::glVertexAttribP1ui = reinterpret_cast(internal::get_proc_address("glVertexAttribP1ui")); 1205 | if (!internal::glVertexAttribP1ui) return false; 1206 | internal::glVertexAttribP1uiv = reinterpret_cast(internal::get_proc_address("glVertexAttribP1uiv")); 1207 | if (!internal::glVertexAttribP1uiv) return false; 1208 | internal::glVertexAttribP2ui = reinterpret_cast(internal::get_proc_address("glVertexAttribP2ui")); 1209 | if (!internal::glVertexAttribP2ui) return false; 1210 | internal::glVertexAttribP2uiv = reinterpret_cast(internal::get_proc_address("glVertexAttribP2uiv")); 1211 | if (!internal::glVertexAttribP2uiv) return false; 1212 | internal::glVertexAttribP3ui = reinterpret_cast(internal::get_proc_address("glVertexAttribP3ui")); 1213 | if (!internal::glVertexAttribP3ui) return false; 1214 | internal::glVertexAttribP3uiv = reinterpret_cast(internal::get_proc_address("glVertexAttribP3uiv")); 1215 | if (!internal::glVertexAttribP3uiv) return false; 1216 | internal::glVertexAttribP4ui = reinterpret_cast(internal::get_proc_address("glVertexAttribP4ui")); 1217 | if (!internal::glVertexAttribP4ui) return false; 1218 | internal::glVertexAttribP4uiv = reinterpret_cast(internal::get_proc_address("glVertexAttribP4uiv")); 1219 | if (!internal::glVertexAttribP4uiv) return false; 1220 | 1221 | return true; 1222 | } 1223 | 1224 | static bool load_ext_GL_ARB_compute_shader() 1225 | { 1226 | internal::glDispatchCompute = reinterpret_cast(internal::get_proc_address("glDispatchCompute")); 1227 | if (!internal::glDispatchCompute) return false; 1228 | internal::glDispatchComputeIndirect = reinterpret_cast(internal::get_proc_address("glDispatchComputeIndirect")); 1229 | if (!internal::glDispatchComputeIndirect) return false; 1230 | 1231 | return true; 1232 | } 1233 | 1234 | static bool load_ext_GL_ARB_texture_filter_anisotropic() 1235 | { 1236 | 1237 | return true; 1238 | } 1239 | 1240 | static std::unordered_set extensions; 1241 | bool initialize() 1242 | { 1243 | if (!load_core()) return false; 1244 | 1245 | GLint num_extensions; 1246 | internal::glGetIntegerv(0x821D, &num_extensions); 1247 | for (GLint i = 0; i < num_extensions; ++i) 1248 | extensions.insert(reinterpret_cast(internal::glGetStringi(0x1F03, i))); 1249 | 1250 | if (extensions.count("GL_ARB_compute_shader") > 0) 1251 | ext_GL_ARB_compute_shader_loaded = load_ext_GL_ARB_compute_shader(); 1252 | if (extensions.count("GL_ARB_texture_filter_anisotropic") > 0) 1253 | ext_GL_ARB_texture_filter_anisotropic_loaded = load_ext_GL_ARB_texture_filter_anisotropic(); 1254 | 1255 | return true; 1256 | } 1257 | 1258 | const char * api(){ return "OpenGL"; } 1259 | 1260 | int major_version(){ return 3; } 1261 | 1262 | int minor_version(){ return 3; } 1263 | 1264 | bool has_extension(const char * name){ return extensions.contains(name); } 1265 | 1266 | bool ext_ARB_compute_shader(){ return ext_GL_ARB_compute_shader_loaded; } 1267 | bool ext_ARB_texture_filter_anisotropic(){ return ext_GL_ARB_texture_filter_anisotropic_loaded; } 1268 | 1269 | } // namespace sys 1270 | 1271 | } // namespace gl 1272 | 1273 | -------------------------------------------------------------------------------- /test.cpp: -------------------------------------------------------------------------------- 1 | #include "gl.hpp" 2 | #include 3 | 4 | #include 5 | 6 | int main(int argc, char ** argv) 7 | { 8 | SDL_Init(SDL_INIT_VIDEO); 9 | 10 | SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); 11 | SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, gl::sys::major_version()); 12 | SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, gl::sys::minor_version()); 13 | SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); 14 | SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); 15 | SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); 16 | SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8); 17 | SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); 18 | 19 | auto window = SDL_CreateWindow("Test", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 800, 600, SDL_WINDOW_RESIZABLE | SDL_WINDOW_OPENGL | SDL_WINDOW_MAXIMIZED | SDL_WINDOW_HIDDEN); 20 | 21 | auto gl_context = SDL_GL_CreateContext(window); 22 | 23 | if (!gl::sys::initialize()) 24 | { 25 | std::cout << "Failed to load OpenGL functions\n"; 26 | return 1; 27 | } 28 | 29 | int major, minor; 30 | gl::GetIntegerv(gl::MAJOR_VERSION, &major); 31 | gl::GetIntegerv(gl::MINOR_VERSION, &minor); 32 | 33 | std::cout << "Loaded OpenGL " << major << "." << minor << "\n"; 34 | std::cout << "Vendor: " << (const char *)gl::GetString(gl::VENDOR) << "\n"; 35 | std::cout << "Renderer: " << (const char *)gl::GetString(gl::RENDERER) << "\n"; 36 | std::cout << "GL_ARB_compute_shader: " << gl::sys::ext_ARB_compute_shader() << "\n"; 37 | std::cout << "GL_ARB_texture_filter_anisotropic: " << gl::sys::ext_ARB_texture_filter_anisotropic() << "\n"; 38 | } 39 | --------------------------------------------------------------------------------