├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── examples ├── win32-custom-implementation │ ├── build.bat │ ├── wglext.h │ └── win32-custom-implementation.cpp ├── win32 │ ├── build-optimized.bat │ ├── build.bat │ ├── wglext.h │ └── win32-example.c ├── x11-custom-implementation │ ├── Makefile │ └── x11-custom-implementation.cc └── x11 │ ├── Makefile │ └── x11-example.c └── simple-opengl-loader.h /.gitignore: -------------------------------------------------------------------------------- 1 | **/*.exe 2 | **/*.obj 3 | **/*.pdb 4 | **/*.ilk 5 | .vs 6 | **/core 7 | examples/x11/x11-example 8 | examples/x11-custom-implementation/x11-custom-implementation 9 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 25/1/2021 2 | - Fully single-file. 3 | - Win32 and X11 platform functions in header and included using `SOGL_IMPLEMENTATION_WIN32` and `SOGL_IMPLEMENTATION_X11` defines, respectively. -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2017 Tarek Sherif 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Simple OpenGL Loader 2 | ==================== 3 | 4 | An extensible, cross-platform, single-header C/C++ OpenGL loader library. 5 | 6 | Usage 7 | ----- 8 | For Windows Win32 or Linux X11 applications, the simplest usage involves defining `SOGL_MAJOR_VERSION`, `SOGL_MINOR_VERSION`and either `SOGL_IMPLEMENTATION_WIN32` or `SOGL_IMPLEMENTATION_X11` before including the `simple-opengl-loader.h` header file, and then calling `sogl_loadOpenGL()` after setting up an OpenGL context. 9 | 10 | ```C 11 | #define SOGL_MAJOR_VERSION 4 12 | #define SOGL_MINOR_VERSION 5 13 | #define SOGL_IMPLEMENTATION_WIN32 /* or SOGL_IMPLEMENTATION_X11 */ 14 | #include "simple-opengl-loader.h" 15 | 16 | int main() { 17 | 18 | /* Set up OpenGL context */ 19 | 20 | sogl_loadOpenGL(); 21 | 22 | /* Use OpenGL functions */ 23 | } 24 | ``` 25 | 26 | It is recommended that `simple-opengl-loader.h` be the first include to prevent other OpenGL headers from setting up their own definitions. 27 | 28 | Platform support is included for Windows Win32 and Linux X11 applications by defining the `SOGL_IMPLEMENTATION_WIN32` or `SOGL_IMPLEMENTATION_X11` constants, respectively. The `SOGL_IMPLEMENTATION_X11` implementation requires the application be linked against `libdl`. See below to implement support for other platforms. 29 | 30 | OpenGL extensions can be loaded by defining a constant of the format `SOGL_` before including the `simple-opengl-loader.h` header. 31 | 32 | ```C 33 | #define SOGL_MAJOR_VERSION 4 34 | #define SOGL_MINOR_VERSION 5 35 | #define SOGL_OVR_multiview 36 | #define SOGL_KHR_parallel_shader_compile 37 | #define SOGL_IMPLEMENTATION_WIN32 38 | #include "simple-opengl-loader.h" 39 | ``` 40 | 41 | Note that the loader makes no guarantees about OpenGL version or extension support. `sogl_loadOpenGL()` returns a boolean value indicating whether it was able to load all requested functions, and the function `sogl_getFailures` returns a null-terminated array of the names of the functions that failed to load (up to a maximum defined by `SOGL_MAX_REPORTED_FAILURES`). 42 | 43 | ```C 44 | if (!sogl_loadOpenGL()) { 45 | const char **failures = sogl_getFailures(); 46 | int i = 1; 47 | while (*failures) { 48 | fprintf(stderr, "Failed to load function %s\n", *failures); 49 | failures++; 50 | } 51 | } 52 | ``` 53 | 54 | Platform Support 55 | ---------------- 56 | 57 | Platform-specific logic is encapsulated in two functions `sogl_loadOpenGLFunction()` which takes the name of an OpenGL function as a null-terminated ASCII string and returns a pointer to the appropriate function, and `sogl_cleanup()`, which should perform any cleanup necessary after loading is complete, e.g. freeing library handles. 58 | 59 | ```C 60 | void *sogl_loadOpenGLFunction(const char *name); 61 | void sogl_cleanup(); 62 | ``` 63 | 64 | Implementations for these functions are provided out-of-the-box for Windows Win32 and Linux X11 applications (see above). Support for other platforms simply requires implementing these two functions for the target platform and defining the constant `SOGL_IMPLEMENTATION` instead of either of the platform-specific implementation constants. 65 | 66 | ```C 67 | #define SOGL_MAJOR_VERSION 4 68 | #define SOGL_MINOR_VERSION 5 69 | #define SOGL_IMPLEMENTATION 70 | #include "simple-opengl-loader.h" 71 | 72 | void *sogl_loadOpenGLFunction(const char *name) { 73 | /* Custom function loader implementation */ 74 | } 75 | 76 | void sogl_cleanup() { 77 | /* Custom cleanup implementation */ 78 | } 79 | ``` -------------------------------------------------------------------------------- /examples/win32-custom-implementation/build.bat: -------------------------------------------------------------------------------- 1 | cl /Zi /W3 /WX /D _UNICODE /D UNICODE /D SOGL_MAJOR_VERSION=4 /D SOGL_MINOR_VERSION=5 win32-custom-implementation.cpp user32.lib gdi32.lib opengl32.lib 2 | -------------------------------------------------------------------------------- /examples/win32-custom-implementation/wglext.h: -------------------------------------------------------------------------------- 1 | #ifndef __wgl_wglext_h_ 2 | #define __wgl_wglext_h_ 1 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | /* 9 | ** Copyright 2013-2020 The Khronos Group Inc. 10 | ** SPDX-License-Identifier: MIT 11 | ** 12 | ** This header is generated from the Khronos OpenGL / OpenGL ES XML 13 | ** API Registry. The current version of the Registry, generator scripts 14 | ** used to make the header, and the header can be found at 15 | ** https://github.com/KhronosGroup/OpenGL-Registry 16 | */ 17 | 18 | #if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) 19 | #define WIN32_LEAN_AND_MEAN 1 20 | #include 21 | #endif 22 | 23 | #define WGL_WGLEXT_VERSION 20200813 24 | 25 | /* Generated C header for: 26 | * API: wgl 27 | * Versions considered: .* 28 | * Versions emitted: _nomatch_^ 29 | * Default extensions included: wgl 30 | * Additional extensions included: _nomatch_^ 31 | * Extensions removed: _nomatch_^ 32 | */ 33 | 34 | #ifndef WGL_ARB_buffer_region 35 | #define WGL_ARB_buffer_region 1 36 | #define WGL_FRONT_COLOR_BUFFER_BIT_ARB 0x00000001 37 | #define WGL_BACK_COLOR_BUFFER_BIT_ARB 0x00000002 38 | #define WGL_DEPTH_BUFFER_BIT_ARB 0x00000004 39 | #define WGL_STENCIL_BUFFER_BIT_ARB 0x00000008 40 | typedef HANDLE (WINAPI * PFNWGLCREATEBUFFERREGIONARBPROC) (HDC hDC, int iLayerPlane, UINT uType); 41 | typedef VOID (WINAPI * PFNWGLDELETEBUFFERREGIONARBPROC) (HANDLE hRegion); 42 | typedef BOOL (WINAPI * PFNWGLSAVEBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height); 43 | typedef BOOL (WINAPI * PFNWGLRESTOREBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc); 44 | #ifdef WGL_WGLEXT_PROTOTYPES 45 | HANDLE WINAPI wglCreateBufferRegionARB (HDC hDC, int iLayerPlane, UINT uType); 46 | VOID WINAPI wglDeleteBufferRegionARB (HANDLE hRegion); 47 | BOOL WINAPI wglSaveBufferRegionARB (HANDLE hRegion, int x, int y, int width, int height); 48 | BOOL WINAPI wglRestoreBufferRegionARB (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc); 49 | #endif 50 | #endif /* WGL_ARB_buffer_region */ 51 | 52 | #ifndef WGL_ARB_context_flush_control 53 | #define WGL_ARB_context_flush_control 1 54 | #define WGL_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097 55 | #define WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0 56 | #define WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098 57 | #endif /* WGL_ARB_context_flush_control */ 58 | 59 | #ifndef WGL_ARB_create_context 60 | #define WGL_ARB_create_context 1 61 | #define WGL_CONTEXT_DEBUG_BIT_ARB 0x00000001 62 | #define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002 63 | #define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 64 | #define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 65 | #define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093 66 | #define WGL_CONTEXT_FLAGS_ARB 0x2094 67 | #define ERROR_INVALID_VERSION_ARB 0x2095 68 | typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, HGLRC hShareContext, const int *attribList); 69 | #ifdef WGL_WGLEXT_PROTOTYPES 70 | HGLRC WINAPI wglCreateContextAttribsARB (HDC hDC, HGLRC hShareContext, const int *attribList); 71 | #endif 72 | #endif /* WGL_ARB_create_context */ 73 | 74 | #ifndef WGL_ARB_create_context_no_error 75 | #define WGL_ARB_create_context_no_error 1 76 | #define WGL_CONTEXT_OPENGL_NO_ERROR_ARB 0x31B3 77 | #endif /* WGL_ARB_create_context_no_error */ 78 | 79 | #ifndef WGL_ARB_create_context_profile 80 | #define WGL_ARB_create_context_profile 1 81 | #define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126 82 | #define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 83 | #define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 84 | #define ERROR_INVALID_PROFILE_ARB 0x2096 85 | #endif /* WGL_ARB_create_context_profile */ 86 | 87 | #ifndef WGL_ARB_create_context_robustness 88 | #define WGL_ARB_create_context_robustness 1 89 | #define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004 90 | #define WGL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 91 | #define WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 92 | #define WGL_NO_RESET_NOTIFICATION_ARB 0x8261 93 | #endif /* WGL_ARB_create_context_robustness */ 94 | 95 | #ifndef WGL_ARB_extensions_string 96 | #define WGL_ARB_extensions_string 1 97 | typedef const char *(WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC hdc); 98 | #ifdef WGL_WGLEXT_PROTOTYPES 99 | const char *WINAPI wglGetExtensionsStringARB (HDC hdc); 100 | #endif 101 | #endif /* WGL_ARB_extensions_string */ 102 | 103 | #ifndef WGL_ARB_framebuffer_sRGB 104 | #define WGL_ARB_framebuffer_sRGB 1 105 | #define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20A9 106 | #endif /* WGL_ARB_framebuffer_sRGB */ 107 | 108 | #ifndef WGL_ARB_make_current_read 109 | #define WGL_ARB_make_current_read 1 110 | #define ERROR_INVALID_PIXEL_TYPE_ARB 0x2043 111 | #define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054 112 | typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTARBPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); 113 | typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCARBPROC) (void); 114 | #ifdef WGL_WGLEXT_PROTOTYPES 115 | BOOL WINAPI wglMakeContextCurrentARB (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); 116 | HDC WINAPI wglGetCurrentReadDCARB (void); 117 | #endif 118 | #endif /* WGL_ARB_make_current_read */ 119 | 120 | #ifndef WGL_ARB_multisample 121 | #define WGL_ARB_multisample 1 122 | #define WGL_SAMPLE_BUFFERS_ARB 0x2041 123 | #define WGL_SAMPLES_ARB 0x2042 124 | #endif /* WGL_ARB_multisample */ 125 | 126 | #ifndef WGL_ARB_pbuffer 127 | #define WGL_ARB_pbuffer 1 128 | DECLARE_HANDLE(HPBUFFERARB); 129 | #define WGL_DRAW_TO_PBUFFER_ARB 0x202D 130 | #define WGL_MAX_PBUFFER_PIXELS_ARB 0x202E 131 | #define WGL_MAX_PBUFFER_WIDTH_ARB 0x202F 132 | #define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030 133 | #define WGL_PBUFFER_LARGEST_ARB 0x2033 134 | #define WGL_PBUFFER_WIDTH_ARB 0x2034 135 | #define WGL_PBUFFER_HEIGHT_ARB 0x2035 136 | #define WGL_PBUFFER_LOST_ARB 0x2036 137 | typedef HPBUFFERARB (WINAPI * PFNWGLCREATEPBUFFERARBPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); 138 | typedef HDC (WINAPI * PFNWGLGETPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer); 139 | typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer, HDC hDC); 140 | typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFERARBPROC) (HPBUFFERARB hPbuffer); 141 | typedef BOOL (WINAPI * PFNWGLQUERYPBUFFERARBPROC) (HPBUFFERARB hPbuffer, int iAttribute, int *piValue); 142 | #ifdef WGL_WGLEXT_PROTOTYPES 143 | HPBUFFERARB WINAPI wglCreatePbufferARB (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); 144 | HDC WINAPI wglGetPbufferDCARB (HPBUFFERARB hPbuffer); 145 | int WINAPI wglReleasePbufferDCARB (HPBUFFERARB hPbuffer, HDC hDC); 146 | BOOL WINAPI wglDestroyPbufferARB (HPBUFFERARB hPbuffer); 147 | BOOL WINAPI wglQueryPbufferARB (HPBUFFERARB hPbuffer, int iAttribute, int *piValue); 148 | #endif 149 | #endif /* WGL_ARB_pbuffer */ 150 | 151 | #ifndef WGL_ARB_pixel_format 152 | #define WGL_ARB_pixel_format 1 153 | #define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000 154 | #define WGL_DRAW_TO_WINDOW_ARB 0x2001 155 | #define WGL_DRAW_TO_BITMAP_ARB 0x2002 156 | #define WGL_ACCELERATION_ARB 0x2003 157 | #define WGL_NEED_PALETTE_ARB 0x2004 158 | #define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005 159 | #define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006 160 | #define WGL_SWAP_METHOD_ARB 0x2007 161 | #define WGL_NUMBER_OVERLAYS_ARB 0x2008 162 | #define WGL_NUMBER_UNDERLAYS_ARB 0x2009 163 | #define WGL_TRANSPARENT_ARB 0x200A 164 | #define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037 165 | #define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038 166 | #define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039 167 | #define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A 168 | #define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B 169 | #define WGL_SHARE_DEPTH_ARB 0x200C 170 | #define WGL_SHARE_STENCIL_ARB 0x200D 171 | #define WGL_SHARE_ACCUM_ARB 0x200E 172 | #define WGL_SUPPORT_GDI_ARB 0x200F 173 | #define WGL_SUPPORT_OPENGL_ARB 0x2010 174 | #define WGL_DOUBLE_BUFFER_ARB 0x2011 175 | #define WGL_STEREO_ARB 0x2012 176 | #define WGL_PIXEL_TYPE_ARB 0x2013 177 | #define WGL_COLOR_BITS_ARB 0x2014 178 | #define WGL_RED_BITS_ARB 0x2015 179 | #define WGL_RED_SHIFT_ARB 0x2016 180 | #define WGL_GREEN_BITS_ARB 0x2017 181 | #define WGL_GREEN_SHIFT_ARB 0x2018 182 | #define WGL_BLUE_BITS_ARB 0x2019 183 | #define WGL_BLUE_SHIFT_ARB 0x201A 184 | #define WGL_ALPHA_BITS_ARB 0x201B 185 | #define WGL_ALPHA_SHIFT_ARB 0x201C 186 | #define WGL_ACCUM_BITS_ARB 0x201D 187 | #define WGL_ACCUM_RED_BITS_ARB 0x201E 188 | #define WGL_ACCUM_GREEN_BITS_ARB 0x201F 189 | #define WGL_ACCUM_BLUE_BITS_ARB 0x2020 190 | #define WGL_ACCUM_ALPHA_BITS_ARB 0x2021 191 | #define WGL_DEPTH_BITS_ARB 0x2022 192 | #define WGL_STENCIL_BITS_ARB 0x2023 193 | #define WGL_AUX_BUFFERS_ARB 0x2024 194 | #define WGL_NO_ACCELERATION_ARB 0x2025 195 | #define WGL_GENERIC_ACCELERATION_ARB 0x2026 196 | #define WGL_FULL_ACCELERATION_ARB 0x2027 197 | #define WGL_SWAP_EXCHANGE_ARB 0x2028 198 | #define WGL_SWAP_COPY_ARB 0x2029 199 | #define WGL_SWAP_UNDEFINED_ARB 0x202A 200 | #define WGL_TYPE_RGBA_ARB 0x202B 201 | #define WGL_TYPE_COLORINDEX_ARB 0x202C 202 | typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues); 203 | typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues); 204 | typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); 205 | #ifdef WGL_WGLEXT_PROTOTYPES 206 | BOOL WINAPI wglGetPixelFormatAttribivARB (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues); 207 | BOOL WINAPI wglGetPixelFormatAttribfvARB (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues); 208 | BOOL WINAPI wglChoosePixelFormatARB (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); 209 | #endif 210 | #endif /* WGL_ARB_pixel_format */ 211 | 212 | #ifndef WGL_ARB_pixel_format_float 213 | #define WGL_ARB_pixel_format_float 1 214 | #define WGL_TYPE_RGBA_FLOAT_ARB 0x21A0 215 | #endif /* WGL_ARB_pixel_format_float */ 216 | 217 | #ifndef WGL_ARB_render_texture 218 | #define WGL_ARB_render_texture 1 219 | #define WGL_BIND_TO_TEXTURE_RGB_ARB 0x2070 220 | #define WGL_BIND_TO_TEXTURE_RGBA_ARB 0x2071 221 | #define WGL_TEXTURE_FORMAT_ARB 0x2072 222 | #define WGL_TEXTURE_TARGET_ARB 0x2073 223 | #define WGL_MIPMAP_TEXTURE_ARB 0x2074 224 | #define WGL_TEXTURE_RGB_ARB 0x2075 225 | #define WGL_TEXTURE_RGBA_ARB 0x2076 226 | #define WGL_NO_TEXTURE_ARB 0x2077 227 | #define WGL_TEXTURE_CUBE_MAP_ARB 0x2078 228 | #define WGL_TEXTURE_1D_ARB 0x2079 229 | #define WGL_TEXTURE_2D_ARB 0x207A 230 | #define WGL_MIPMAP_LEVEL_ARB 0x207B 231 | #define WGL_CUBE_MAP_FACE_ARB 0x207C 232 | #define WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x207D 233 | #define WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x207E 234 | #define WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x207F 235 | #define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x2080 236 | #define WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x2081 237 | #define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x2082 238 | #define WGL_FRONT_LEFT_ARB 0x2083 239 | #define WGL_FRONT_RIGHT_ARB 0x2084 240 | #define WGL_BACK_LEFT_ARB 0x2085 241 | #define WGL_BACK_RIGHT_ARB 0x2086 242 | #define WGL_AUX0_ARB 0x2087 243 | #define WGL_AUX1_ARB 0x2088 244 | #define WGL_AUX2_ARB 0x2089 245 | #define WGL_AUX3_ARB 0x208A 246 | #define WGL_AUX4_ARB 0x208B 247 | #define WGL_AUX5_ARB 0x208C 248 | #define WGL_AUX6_ARB 0x208D 249 | #define WGL_AUX7_ARB 0x208E 250 | #define WGL_AUX8_ARB 0x208F 251 | #define WGL_AUX9_ARB 0x2090 252 | typedef BOOL (WINAPI * PFNWGLBINDTEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); 253 | typedef BOOL (WINAPI * PFNWGLRELEASETEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); 254 | typedef BOOL (WINAPI * PFNWGLSETPBUFFERATTRIBARBPROC) (HPBUFFERARB hPbuffer, const int *piAttribList); 255 | #ifdef WGL_WGLEXT_PROTOTYPES 256 | BOOL WINAPI wglBindTexImageARB (HPBUFFERARB hPbuffer, int iBuffer); 257 | BOOL WINAPI wglReleaseTexImageARB (HPBUFFERARB hPbuffer, int iBuffer); 258 | BOOL WINAPI wglSetPbufferAttribARB (HPBUFFERARB hPbuffer, const int *piAttribList); 259 | #endif 260 | #endif /* WGL_ARB_render_texture */ 261 | 262 | #ifndef WGL_ARB_robustness_application_isolation 263 | #define WGL_ARB_robustness_application_isolation 1 264 | #define WGL_CONTEXT_RESET_ISOLATION_BIT_ARB 0x00000008 265 | #endif /* WGL_ARB_robustness_application_isolation */ 266 | 267 | #ifndef WGL_ARB_robustness_share_group_isolation 268 | #define WGL_ARB_robustness_share_group_isolation 1 269 | #endif /* WGL_ARB_robustness_share_group_isolation */ 270 | 271 | #ifndef WGL_3DFX_multisample 272 | #define WGL_3DFX_multisample 1 273 | #define WGL_SAMPLE_BUFFERS_3DFX 0x2060 274 | #define WGL_SAMPLES_3DFX 0x2061 275 | #endif /* WGL_3DFX_multisample */ 276 | 277 | #ifndef WGL_3DL_stereo_control 278 | #define WGL_3DL_stereo_control 1 279 | #define WGL_STEREO_EMITTER_ENABLE_3DL 0x2055 280 | #define WGL_STEREO_EMITTER_DISABLE_3DL 0x2056 281 | #define WGL_STEREO_POLARITY_NORMAL_3DL 0x2057 282 | #define WGL_STEREO_POLARITY_INVERT_3DL 0x2058 283 | typedef BOOL (WINAPI * PFNWGLSETSTEREOEMITTERSTATE3DLPROC) (HDC hDC, UINT uState); 284 | #ifdef WGL_WGLEXT_PROTOTYPES 285 | BOOL WINAPI wglSetStereoEmitterState3DL (HDC hDC, UINT uState); 286 | #endif 287 | #endif /* WGL_3DL_stereo_control */ 288 | 289 | #ifndef WGL_AMD_gpu_association 290 | #define WGL_AMD_gpu_association 1 291 | #define WGL_GPU_VENDOR_AMD 0x1F00 292 | #define WGL_GPU_RENDERER_STRING_AMD 0x1F01 293 | #define WGL_GPU_OPENGL_VERSION_STRING_AMD 0x1F02 294 | #define WGL_GPU_FASTEST_TARGET_GPUS_AMD 0x21A2 295 | #define WGL_GPU_RAM_AMD 0x21A3 296 | #define WGL_GPU_CLOCK_AMD 0x21A4 297 | #define WGL_GPU_NUM_PIPES_AMD 0x21A5 298 | #define WGL_GPU_NUM_SIMD_AMD 0x21A6 299 | #define WGL_GPU_NUM_RB_AMD 0x21A7 300 | #define WGL_GPU_NUM_SPI_AMD 0x21A8 301 | typedef UINT (WINAPI * PFNWGLGETGPUIDSAMDPROC) (UINT maxCount, UINT *ids); 302 | typedef INT (WINAPI * PFNWGLGETGPUINFOAMDPROC) (UINT id, INT property, GLenum dataType, UINT size, void *data); 303 | typedef UINT (WINAPI * PFNWGLGETCONTEXTGPUIDAMDPROC) (HGLRC hglrc); 304 | typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTAMDPROC) (UINT id); 305 | typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC) (UINT id, HGLRC hShareContext, const int *attribList); 306 | typedef BOOL (WINAPI * PFNWGLDELETEASSOCIATEDCONTEXTAMDPROC) (HGLRC hglrc); 307 | typedef BOOL (WINAPI * PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC) (HGLRC hglrc); 308 | typedef HGLRC (WINAPI * PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC) (void); 309 | typedef VOID (WINAPI * PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC) (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); 310 | #ifdef WGL_WGLEXT_PROTOTYPES 311 | UINT WINAPI wglGetGPUIDsAMD (UINT maxCount, UINT *ids); 312 | INT WINAPI wglGetGPUInfoAMD (UINT id, INT property, GLenum dataType, UINT size, void *data); 313 | UINT WINAPI wglGetContextGPUIDAMD (HGLRC hglrc); 314 | HGLRC WINAPI wglCreateAssociatedContextAMD (UINT id); 315 | HGLRC WINAPI wglCreateAssociatedContextAttribsAMD (UINT id, HGLRC hShareContext, const int *attribList); 316 | BOOL WINAPI wglDeleteAssociatedContextAMD (HGLRC hglrc); 317 | BOOL WINAPI wglMakeAssociatedContextCurrentAMD (HGLRC hglrc); 318 | HGLRC WINAPI wglGetCurrentAssociatedContextAMD (void); 319 | VOID WINAPI wglBlitContextFramebufferAMD (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); 320 | #endif 321 | #endif /* WGL_AMD_gpu_association */ 322 | 323 | #ifndef WGL_ATI_pixel_format_float 324 | #define WGL_ATI_pixel_format_float 1 325 | #define WGL_TYPE_RGBA_FLOAT_ATI 0x21A0 326 | #endif /* WGL_ATI_pixel_format_float */ 327 | 328 | #ifndef WGL_ATI_render_texture_rectangle 329 | #define WGL_ATI_render_texture_rectangle 1 330 | #define WGL_TEXTURE_RECTANGLE_ATI 0x21A5 331 | #endif /* WGL_ATI_render_texture_rectangle */ 332 | 333 | #ifndef WGL_EXT_colorspace 334 | #define WGL_EXT_colorspace 1 335 | #define WGL_COLORSPACE_EXT 0x309D 336 | #define WGL_COLORSPACE_SRGB_EXT 0x3089 337 | #define WGL_COLORSPACE_LINEAR_EXT 0x308A 338 | #endif /* WGL_EXT_colorspace */ 339 | 340 | #ifndef WGL_EXT_create_context_es2_profile 341 | #define WGL_EXT_create_context_es2_profile 1 342 | #define WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004 343 | #endif /* WGL_EXT_create_context_es2_profile */ 344 | 345 | #ifndef WGL_EXT_create_context_es_profile 346 | #define WGL_EXT_create_context_es_profile 1 347 | #define WGL_CONTEXT_ES_PROFILE_BIT_EXT 0x00000004 348 | #endif /* WGL_EXT_create_context_es_profile */ 349 | 350 | #ifndef WGL_EXT_depth_float 351 | #define WGL_EXT_depth_float 1 352 | #define WGL_DEPTH_FLOAT_EXT 0x2040 353 | #endif /* WGL_EXT_depth_float */ 354 | 355 | #ifndef WGL_EXT_display_color_table 356 | #define WGL_EXT_display_color_table 1 357 | typedef GLboolean (WINAPI * PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC) (GLushort id); 358 | typedef GLboolean (WINAPI * PFNWGLLOADDISPLAYCOLORTABLEEXTPROC) (const GLushort *table, GLuint length); 359 | typedef GLboolean (WINAPI * PFNWGLBINDDISPLAYCOLORTABLEEXTPROC) (GLushort id); 360 | typedef VOID (WINAPI * PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC) (GLushort id); 361 | #ifdef WGL_WGLEXT_PROTOTYPES 362 | GLboolean WINAPI wglCreateDisplayColorTableEXT (GLushort id); 363 | GLboolean WINAPI wglLoadDisplayColorTableEXT (const GLushort *table, GLuint length); 364 | GLboolean WINAPI wglBindDisplayColorTableEXT (GLushort id); 365 | VOID WINAPI wglDestroyDisplayColorTableEXT (GLushort id); 366 | #endif 367 | #endif /* WGL_EXT_display_color_table */ 368 | 369 | #ifndef WGL_EXT_extensions_string 370 | #define WGL_EXT_extensions_string 1 371 | typedef const char *(WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC) (void); 372 | #ifdef WGL_WGLEXT_PROTOTYPES 373 | const char *WINAPI wglGetExtensionsStringEXT (void); 374 | #endif 375 | #endif /* WGL_EXT_extensions_string */ 376 | 377 | #ifndef WGL_EXT_framebuffer_sRGB 378 | #define WGL_EXT_framebuffer_sRGB 1 379 | #define WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20A9 380 | #endif /* WGL_EXT_framebuffer_sRGB */ 381 | 382 | #ifndef WGL_EXT_make_current_read 383 | #define WGL_EXT_make_current_read 1 384 | #define ERROR_INVALID_PIXEL_TYPE_EXT 0x2043 385 | typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTEXTPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); 386 | typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCEXTPROC) (void); 387 | #ifdef WGL_WGLEXT_PROTOTYPES 388 | BOOL WINAPI wglMakeContextCurrentEXT (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); 389 | HDC WINAPI wglGetCurrentReadDCEXT (void); 390 | #endif 391 | #endif /* WGL_EXT_make_current_read */ 392 | 393 | #ifndef WGL_EXT_multisample 394 | #define WGL_EXT_multisample 1 395 | #define WGL_SAMPLE_BUFFERS_EXT 0x2041 396 | #define WGL_SAMPLES_EXT 0x2042 397 | #endif /* WGL_EXT_multisample */ 398 | 399 | #ifndef WGL_EXT_pbuffer 400 | #define WGL_EXT_pbuffer 1 401 | DECLARE_HANDLE(HPBUFFEREXT); 402 | #define WGL_DRAW_TO_PBUFFER_EXT 0x202D 403 | #define WGL_MAX_PBUFFER_PIXELS_EXT 0x202E 404 | #define WGL_MAX_PBUFFER_WIDTH_EXT 0x202F 405 | #define WGL_MAX_PBUFFER_HEIGHT_EXT 0x2030 406 | #define WGL_OPTIMAL_PBUFFER_WIDTH_EXT 0x2031 407 | #define WGL_OPTIMAL_PBUFFER_HEIGHT_EXT 0x2032 408 | #define WGL_PBUFFER_LARGEST_EXT 0x2033 409 | #define WGL_PBUFFER_WIDTH_EXT 0x2034 410 | #define WGL_PBUFFER_HEIGHT_EXT 0x2035 411 | typedef HPBUFFEREXT (WINAPI * PFNWGLCREATEPBUFFEREXTPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); 412 | typedef HDC (WINAPI * PFNWGLGETPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer); 413 | typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer, HDC hDC); 414 | typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer); 415 | typedef BOOL (WINAPI * PFNWGLQUERYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer, int iAttribute, int *piValue); 416 | #ifdef WGL_WGLEXT_PROTOTYPES 417 | HPBUFFEREXT WINAPI wglCreatePbufferEXT (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); 418 | HDC WINAPI wglGetPbufferDCEXT (HPBUFFEREXT hPbuffer); 419 | int WINAPI wglReleasePbufferDCEXT (HPBUFFEREXT hPbuffer, HDC hDC); 420 | BOOL WINAPI wglDestroyPbufferEXT (HPBUFFEREXT hPbuffer); 421 | BOOL WINAPI wglQueryPbufferEXT (HPBUFFEREXT hPbuffer, int iAttribute, int *piValue); 422 | #endif 423 | #endif /* WGL_EXT_pbuffer */ 424 | 425 | #ifndef WGL_EXT_pixel_format 426 | #define WGL_EXT_pixel_format 1 427 | #define WGL_NUMBER_PIXEL_FORMATS_EXT 0x2000 428 | #define WGL_DRAW_TO_WINDOW_EXT 0x2001 429 | #define WGL_DRAW_TO_BITMAP_EXT 0x2002 430 | #define WGL_ACCELERATION_EXT 0x2003 431 | #define WGL_NEED_PALETTE_EXT 0x2004 432 | #define WGL_NEED_SYSTEM_PALETTE_EXT 0x2005 433 | #define WGL_SWAP_LAYER_BUFFERS_EXT 0x2006 434 | #define WGL_SWAP_METHOD_EXT 0x2007 435 | #define WGL_NUMBER_OVERLAYS_EXT 0x2008 436 | #define WGL_NUMBER_UNDERLAYS_EXT 0x2009 437 | #define WGL_TRANSPARENT_EXT 0x200A 438 | #define WGL_TRANSPARENT_VALUE_EXT 0x200B 439 | #define WGL_SHARE_DEPTH_EXT 0x200C 440 | #define WGL_SHARE_STENCIL_EXT 0x200D 441 | #define WGL_SHARE_ACCUM_EXT 0x200E 442 | #define WGL_SUPPORT_GDI_EXT 0x200F 443 | #define WGL_SUPPORT_OPENGL_EXT 0x2010 444 | #define WGL_DOUBLE_BUFFER_EXT 0x2011 445 | #define WGL_STEREO_EXT 0x2012 446 | #define WGL_PIXEL_TYPE_EXT 0x2013 447 | #define WGL_COLOR_BITS_EXT 0x2014 448 | #define WGL_RED_BITS_EXT 0x2015 449 | #define WGL_RED_SHIFT_EXT 0x2016 450 | #define WGL_GREEN_BITS_EXT 0x2017 451 | #define WGL_GREEN_SHIFT_EXT 0x2018 452 | #define WGL_BLUE_BITS_EXT 0x2019 453 | #define WGL_BLUE_SHIFT_EXT 0x201A 454 | #define WGL_ALPHA_BITS_EXT 0x201B 455 | #define WGL_ALPHA_SHIFT_EXT 0x201C 456 | #define WGL_ACCUM_BITS_EXT 0x201D 457 | #define WGL_ACCUM_RED_BITS_EXT 0x201E 458 | #define WGL_ACCUM_GREEN_BITS_EXT 0x201F 459 | #define WGL_ACCUM_BLUE_BITS_EXT 0x2020 460 | #define WGL_ACCUM_ALPHA_BITS_EXT 0x2021 461 | #define WGL_DEPTH_BITS_EXT 0x2022 462 | #define WGL_STENCIL_BITS_EXT 0x2023 463 | #define WGL_AUX_BUFFERS_EXT 0x2024 464 | #define WGL_NO_ACCELERATION_EXT 0x2025 465 | #define WGL_GENERIC_ACCELERATION_EXT 0x2026 466 | #define WGL_FULL_ACCELERATION_EXT 0x2027 467 | #define WGL_SWAP_EXCHANGE_EXT 0x2028 468 | #define WGL_SWAP_COPY_EXT 0x2029 469 | #define WGL_SWAP_UNDEFINED_EXT 0x202A 470 | #define WGL_TYPE_RGBA_EXT 0x202B 471 | #define WGL_TYPE_COLORINDEX_EXT 0x202C 472 | typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues); 473 | typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, FLOAT *pfValues); 474 | typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATEXTPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); 475 | #ifdef WGL_WGLEXT_PROTOTYPES 476 | BOOL WINAPI wglGetPixelFormatAttribivEXT (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues); 477 | BOOL WINAPI wglGetPixelFormatAttribfvEXT (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, FLOAT *pfValues); 478 | BOOL WINAPI wglChoosePixelFormatEXT (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); 479 | #endif 480 | #endif /* WGL_EXT_pixel_format */ 481 | 482 | #ifndef WGL_EXT_pixel_format_packed_float 483 | #define WGL_EXT_pixel_format_packed_float 1 484 | #define WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT 0x20A8 485 | #endif /* WGL_EXT_pixel_format_packed_float */ 486 | 487 | #ifndef WGL_EXT_swap_control 488 | #define WGL_EXT_swap_control 1 489 | typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC) (int interval); 490 | typedef int (WINAPI * PFNWGLGETSWAPINTERVALEXTPROC) (void); 491 | #ifdef WGL_WGLEXT_PROTOTYPES 492 | BOOL WINAPI wglSwapIntervalEXT (int interval); 493 | int WINAPI wglGetSwapIntervalEXT (void); 494 | #endif 495 | #endif /* WGL_EXT_swap_control */ 496 | 497 | #ifndef WGL_EXT_swap_control_tear 498 | #define WGL_EXT_swap_control_tear 1 499 | #endif /* WGL_EXT_swap_control_tear */ 500 | 501 | #ifndef WGL_I3D_digital_video_control 502 | #define WGL_I3D_digital_video_control 1 503 | #define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_FRAMEBUFFER_I3D 0x2050 504 | #define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_VALUE_I3D 0x2051 505 | #define WGL_DIGITAL_VIDEO_CURSOR_INCLUDED_I3D 0x2052 506 | #define WGL_DIGITAL_VIDEO_GAMMA_CORRECTED_I3D 0x2053 507 | typedef BOOL (WINAPI * PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue); 508 | typedef BOOL (WINAPI * PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue); 509 | #ifdef WGL_WGLEXT_PROTOTYPES 510 | BOOL WINAPI wglGetDigitalVideoParametersI3D (HDC hDC, int iAttribute, int *piValue); 511 | BOOL WINAPI wglSetDigitalVideoParametersI3D (HDC hDC, int iAttribute, const int *piValue); 512 | #endif 513 | #endif /* WGL_I3D_digital_video_control */ 514 | 515 | #ifndef WGL_I3D_gamma 516 | #define WGL_I3D_gamma 1 517 | #define WGL_GAMMA_TABLE_SIZE_I3D 0x204E 518 | #define WGL_GAMMA_EXCLUDE_DESKTOP_I3D 0x204F 519 | typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue); 520 | typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue); 521 | typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, USHORT *puRed, USHORT *puGreen, USHORT *puBlue); 522 | typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, const USHORT *puRed, const USHORT *puGreen, const USHORT *puBlue); 523 | #ifdef WGL_WGLEXT_PROTOTYPES 524 | BOOL WINAPI wglGetGammaTableParametersI3D (HDC hDC, int iAttribute, int *piValue); 525 | BOOL WINAPI wglSetGammaTableParametersI3D (HDC hDC, int iAttribute, const int *piValue); 526 | BOOL WINAPI wglGetGammaTableI3D (HDC hDC, int iEntries, USHORT *puRed, USHORT *puGreen, USHORT *puBlue); 527 | BOOL WINAPI wglSetGammaTableI3D (HDC hDC, int iEntries, const USHORT *puRed, const USHORT *puGreen, const USHORT *puBlue); 528 | #endif 529 | #endif /* WGL_I3D_gamma */ 530 | 531 | #ifndef WGL_I3D_genlock 532 | #define WGL_I3D_genlock 1 533 | #define WGL_GENLOCK_SOURCE_MULTIVIEW_I3D 0x2044 534 | #define WGL_GENLOCK_SOURCE_EXTERNAL_SYNC_I3D 0x2045 535 | #define WGL_GENLOCK_SOURCE_EXTERNAL_FIELD_I3D 0x2046 536 | #define WGL_GENLOCK_SOURCE_EXTERNAL_TTL_I3D 0x2047 537 | #define WGL_GENLOCK_SOURCE_DIGITAL_SYNC_I3D 0x2048 538 | #define WGL_GENLOCK_SOURCE_DIGITAL_FIELD_I3D 0x2049 539 | #define WGL_GENLOCK_SOURCE_EDGE_FALLING_I3D 0x204A 540 | #define WGL_GENLOCK_SOURCE_EDGE_RISING_I3D 0x204B 541 | #define WGL_GENLOCK_SOURCE_EDGE_BOTH_I3D 0x204C 542 | typedef BOOL (WINAPI * PFNWGLENABLEGENLOCKI3DPROC) (HDC hDC); 543 | typedef BOOL (WINAPI * PFNWGLDISABLEGENLOCKI3DPROC) (HDC hDC); 544 | typedef BOOL (WINAPI * PFNWGLISENABLEDGENLOCKI3DPROC) (HDC hDC, BOOL *pFlag); 545 | typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEI3DPROC) (HDC hDC, UINT uSource); 546 | typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEI3DPROC) (HDC hDC, UINT *uSource); 547 | typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT uEdge); 548 | typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT *uEdge); 549 | typedef BOOL (WINAPI * PFNWGLGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT uRate); 550 | typedef BOOL (WINAPI * PFNWGLGETGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT *uRate); 551 | typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT uDelay); 552 | typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT *uDelay); 553 | typedef BOOL (WINAPI * PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC) (HDC hDC, UINT *uMaxLineDelay, UINT *uMaxPixelDelay); 554 | #ifdef WGL_WGLEXT_PROTOTYPES 555 | BOOL WINAPI wglEnableGenlockI3D (HDC hDC); 556 | BOOL WINAPI wglDisableGenlockI3D (HDC hDC); 557 | BOOL WINAPI wglIsEnabledGenlockI3D (HDC hDC, BOOL *pFlag); 558 | BOOL WINAPI wglGenlockSourceI3D (HDC hDC, UINT uSource); 559 | BOOL WINAPI wglGetGenlockSourceI3D (HDC hDC, UINT *uSource); 560 | BOOL WINAPI wglGenlockSourceEdgeI3D (HDC hDC, UINT uEdge); 561 | BOOL WINAPI wglGetGenlockSourceEdgeI3D (HDC hDC, UINT *uEdge); 562 | BOOL WINAPI wglGenlockSampleRateI3D (HDC hDC, UINT uRate); 563 | BOOL WINAPI wglGetGenlockSampleRateI3D (HDC hDC, UINT *uRate); 564 | BOOL WINAPI wglGenlockSourceDelayI3D (HDC hDC, UINT uDelay); 565 | BOOL WINAPI wglGetGenlockSourceDelayI3D (HDC hDC, UINT *uDelay); 566 | BOOL WINAPI wglQueryGenlockMaxSourceDelayI3D (HDC hDC, UINT *uMaxLineDelay, UINT *uMaxPixelDelay); 567 | #endif 568 | #endif /* WGL_I3D_genlock */ 569 | 570 | #ifndef WGL_I3D_image_buffer 571 | #define WGL_I3D_image_buffer 1 572 | #define WGL_IMAGE_BUFFER_MIN_ACCESS_I3D 0x00000001 573 | #define WGL_IMAGE_BUFFER_LOCK_I3D 0x00000002 574 | typedef LPVOID (WINAPI * PFNWGLCREATEIMAGEBUFFERI3DPROC) (HDC hDC, DWORD dwSize, UINT uFlags); 575 | typedef BOOL (WINAPI * PFNWGLDESTROYIMAGEBUFFERI3DPROC) (HDC hDC, LPVOID pAddress); 576 | typedef BOOL (WINAPI * PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const HANDLE *pEvent, const LPVOID *pAddress, const DWORD *pSize, UINT count); 577 | typedef BOOL (WINAPI * PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const LPVOID *pAddress, UINT count); 578 | #ifdef WGL_WGLEXT_PROTOTYPES 579 | LPVOID WINAPI wglCreateImageBufferI3D (HDC hDC, DWORD dwSize, UINT uFlags); 580 | BOOL WINAPI wglDestroyImageBufferI3D (HDC hDC, LPVOID pAddress); 581 | BOOL WINAPI wglAssociateImageBufferEventsI3D (HDC hDC, const HANDLE *pEvent, const LPVOID *pAddress, const DWORD *pSize, UINT count); 582 | BOOL WINAPI wglReleaseImageBufferEventsI3D (HDC hDC, const LPVOID *pAddress, UINT count); 583 | #endif 584 | #endif /* WGL_I3D_image_buffer */ 585 | 586 | #ifndef WGL_I3D_swap_frame_lock 587 | #define WGL_I3D_swap_frame_lock 1 588 | typedef BOOL (WINAPI * PFNWGLENABLEFRAMELOCKI3DPROC) (void); 589 | typedef BOOL (WINAPI * PFNWGLDISABLEFRAMELOCKI3DPROC) (void); 590 | typedef BOOL (WINAPI * PFNWGLISENABLEDFRAMELOCKI3DPROC) (BOOL *pFlag); 591 | typedef BOOL (WINAPI * PFNWGLQUERYFRAMELOCKMASTERI3DPROC) (BOOL *pFlag); 592 | #ifdef WGL_WGLEXT_PROTOTYPES 593 | BOOL WINAPI wglEnableFrameLockI3D (void); 594 | BOOL WINAPI wglDisableFrameLockI3D (void); 595 | BOOL WINAPI wglIsEnabledFrameLockI3D (BOOL *pFlag); 596 | BOOL WINAPI wglQueryFrameLockMasterI3D (BOOL *pFlag); 597 | #endif 598 | #endif /* WGL_I3D_swap_frame_lock */ 599 | 600 | #ifndef WGL_I3D_swap_frame_usage 601 | #define WGL_I3D_swap_frame_usage 1 602 | typedef BOOL (WINAPI * PFNWGLGETFRAMEUSAGEI3DPROC) (float *pUsage); 603 | typedef BOOL (WINAPI * PFNWGLBEGINFRAMETRACKINGI3DPROC) (void); 604 | typedef BOOL (WINAPI * PFNWGLENDFRAMETRACKINGI3DPROC) (void); 605 | typedef BOOL (WINAPI * PFNWGLQUERYFRAMETRACKINGI3DPROC) (DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage); 606 | #ifdef WGL_WGLEXT_PROTOTYPES 607 | BOOL WINAPI wglGetFrameUsageI3D (float *pUsage); 608 | BOOL WINAPI wglBeginFrameTrackingI3D (void); 609 | BOOL WINAPI wglEndFrameTrackingI3D (void); 610 | BOOL WINAPI wglQueryFrameTrackingI3D (DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage); 611 | #endif 612 | #endif /* WGL_I3D_swap_frame_usage */ 613 | 614 | #ifndef WGL_NV_DX_interop 615 | #define WGL_NV_DX_interop 1 616 | #define WGL_ACCESS_READ_ONLY_NV 0x00000000 617 | #define WGL_ACCESS_READ_WRITE_NV 0x00000001 618 | #define WGL_ACCESS_WRITE_DISCARD_NV 0x00000002 619 | typedef BOOL (WINAPI * PFNWGLDXSETRESOURCESHAREHANDLENVPROC) (void *dxObject, HANDLE shareHandle); 620 | typedef HANDLE (WINAPI * PFNWGLDXOPENDEVICENVPROC) (void *dxDevice); 621 | typedef BOOL (WINAPI * PFNWGLDXCLOSEDEVICENVPROC) (HANDLE hDevice); 622 | typedef HANDLE (WINAPI * PFNWGLDXREGISTEROBJECTNVPROC) (HANDLE hDevice, void *dxObject, GLuint name, GLenum type, GLenum access); 623 | typedef BOOL (WINAPI * PFNWGLDXUNREGISTEROBJECTNVPROC) (HANDLE hDevice, HANDLE hObject); 624 | typedef BOOL (WINAPI * PFNWGLDXOBJECTACCESSNVPROC) (HANDLE hObject, GLenum access); 625 | typedef BOOL (WINAPI * PFNWGLDXLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE *hObjects); 626 | typedef BOOL (WINAPI * PFNWGLDXUNLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE *hObjects); 627 | #ifdef WGL_WGLEXT_PROTOTYPES 628 | BOOL WINAPI wglDXSetResourceShareHandleNV (void *dxObject, HANDLE shareHandle); 629 | HANDLE WINAPI wglDXOpenDeviceNV (void *dxDevice); 630 | BOOL WINAPI wglDXCloseDeviceNV (HANDLE hDevice); 631 | HANDLE WINAPI wglDXRegisterObjectNV (HANDLE hDevice, void *dxObject, GLuint name, GLenum type, GLenum access); 632 | BOOL WINAPI wglDXUnregisterObjectNV (HANDLE hDevice, HANDLE hObject); 633 | BOOL WINAPI wglDXObjectAccessNV (HANDLE hObject, GLenum access); 634 | BOOL WINAPI wglDXLockObjectsNV (HANDLE hDevice, GLint count, HANDLE *hObjects); 635 | BOOL WINAPI wglDXUnlockObjectsNV (HANDLE hDevice, GLint count, HANDLE *hObjects); 636 | #endif 637 | #endif /* WGL_NV_DX_interop */ 638 | 639 | #ifndef WGL_NV_DX_interop2 640 | #define WGL_NV_DX_interop2 1 641 | #endif /* WGL_NV_DX_interop2 */ 642 | 643 | #ifndef WGL_NV_copy_image 644 | #define WGL_NV_copy_image 1 645 | typedef BOOL (WINAPI * PFNWGLCOPYIMAGESUBDATANVPROC) (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); 646 | #ifdef WGL_WGLEXT_PROTOTYPES 647 | BOOL WINAPI wglCopyImageSubDataNV (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); 648 | #endif 649 | #endif /* WGL_NV_copy_image */ 650 | 651 | #ifndef WGL_NV_delay_before_swap 652 | #define WGL_NV_delay_before_swap 1 653 | typedef BOOL (WINAPI * PFNWGLDELAYBEFORESWAPNVPROC) (HDC hDC, GLfloat seconds); 654 | #ifdef WGL_WGLEXT_PROTOTYPES 655 | BOOL WINAPI wglDelayBeforeSwapNV (HDC hDC, GLfloat seconds); 656 | #endif 657 | #endif /* WGL_NV_delay_before_swap */ 658 | 659 | #ifndef WGL_NV_float_buffer 660 | #define WGL_NV_float_buffer 1 661 | #define WGL_FLOAT_COMPONENTS_NV 0x20B0 662 | #define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV 0x20B1 663 | #define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV 0x20B2 664 | #define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV 0x20B3 665 | #define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV 0x20B4 666 | #define WGL_TEXTURE_FLOAT_R_NV 0x20B5 667 | #define WGL_TEXTURE_FLOAT_RG_NV 0x20B6 668 | #define WGL_TEXTURE_FLOAT_RGB_NV 0x20B7 669 | #define WGL_TEXTURE_FLOAT_RGBA_NV 0x20B8 670 | #endif /* WGL_NV_float_buffer */ 671 | 672 | #ifndef WGL_NV_gpu_affinity 673 | #define WGL_NV_gpu_affinity 1 674 | DECLARE_HANDLE(HGPUNV); 675 | struct _GPU_DEVICE { 676 | DWORD cb; 677 | CHAR DeviceName[32]; 678 | CHAR DeviceString[128]; 679 | DWORD Flags; 680 | RECT rcVirtualScreen; 681 | }; 682 | typedef struct _GPU_DEVICE *PGPU_DEVICE; 683 | #define ERROR_INCOMPATIBLE_AFFINITY_MASKS_NV 0x20D0 684 | #define ERROR_MISSING_AFFINITY_MASK_NV 0x20D1 685 | typedef BOOL (WINAPI * PFNWGLENUMGPUSNVPROC) (UINT iGpuIndex, HGPUNV *phGpu); 686 | typedef BOOL (WINAPI * PFNWGLENUMGPUDEVICESNVPROC) (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice); 687 | typedef HDC (WINAPI * PFNWGLCREATEAFFINITYDCNVPROC) (const HGPUNV *phGpuList); 688 | typedef BOOL (WINAPI * PFNWGLENUMGPUSFROMAFFINITYDCNVPROC) (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu); 689 | typedef BOOL (WINAPI * PFNWGLDELETEDCNVPROC) (HDC hdc); 690 | #ifdef WGL_WGLEXT_PROTOTYPES 691 | BOOL WINAPI wglEnumGpusNV (UINT iGpuIndex, HGPUNV *phGpu); 692 | BOOL WINAPI wglEnumGpuDevicesNV (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice); 693 | HDC WINAPI wglCreateAffinityDCNV (const HGPUNV *phGpuList); 694 | BOOL WINAPI wglEnumGpusFromAffinityDCNV (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu); 695 | BOOL WINAPI wglDeleteDCNV (HDC hdc); 696 | #endif 697 | #endif /* WGL_NV_gpu_affinity */ 698 | 699 | #ifndef WGL_NV_multigpu_context 700 | #define WGL_NV_multigpu_context 1 701 | #define WGL_CONTEXT_MULTIGPU_ATTRIB_NV 0x20AA 702 | #define WGL_CONTEXT_MULTIGPU_ATTRIB_SINGLE_NV 0x20AB 703 | #define WGL_CONTEXT_MULTIGPU_ATTRIB_AFR_NV 0x20AC 704 | #define WGL_CONTEXT_MULTIGPU_ATTRIB_MULTICAST_NV 0x20AD 705 | #define WGL_CONTEXT_MULTIGPU_ATTRIB_MULTI_DISPLAY_MULTICAST_NV 0x20AE 706 | #endif /* WGL_NV_multigpu_context */ 707 | 708 | #ifndef WGL_NV_multisample_coverage 709 | #define WGL_NV_multisample_coverage 1 710 | #define WGL_COVERAGE_SAMPLES_NV 0x2042 711 | #define WGL_COLOR_SAMPLES_NV 0x20B9 712 | #endif /* WGL_NV_multisample_coverage */ 713 | 714 | #ifndef WGL_NV_present_video 715 | #define WGL_NV_present_video 1 716 | DECLARE_HANDLE(HVIDEOOUTPUTDEVICENV); 717 | #define WGL_NUM_VIDEO_SLOTS_NV 0x20F0 718 | typedef int (WINAPI * PFNWGLENUMERATEVIDEODEVICESNVPROC) (HDC hDc, HVIDEOOUTPUTDEVICENV *phDeviceList); 719 | typedef BOOL (WINAPI * PFNWGLBINDVIDEODEVICENVPROC) (HDC hDc, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList); 720 | typedef BOOL (WINAPI * PFNWGLQUERYCURRENTCONTEXTNVPROC) (int iAttribute, int *piValue); 721 | #ifdef WGL_WGLEXT_PROTOTYPES 722 | int WINAPI wglEnumerateVideoDevicesNV (HDC hDc, HVIDEOOUTPUTDEVICENV *phDeviceList); 723 | BOOL WINAPI wglBindVideoDeviceNV (HDC hDc, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList); 724 | BOOL WINAPI wglQueryCurrentContextNV (int iAttribute, int *piValue); 725 | #endif 726 | #endif /* WGL_NV_present_video */ 727 | 728 | #ifndef WGL_NV_render_depth_texture 729 | #define WGL_NV_render_depth_texture 1 730 | #define WGL_BIND_TO_TEXTURE_DEPTH_NV 0x20A3 731 | #define WGL_BIND_TO_TEXTURE_RECTANGLE_DEPTH_NV 0x20A4 732 | #define WGL_DEPTH_TEXTURE_FORMAT_NV 0x20A5 733 | #define WGL_TEXTURE_DEPTH_COMPONENT_NV 0x20A6 734 | #define WGL_DEPTH_COMPONENT_NV 0x20A7 735 | #endif /* WGL_NV_render_depth_texture */ 736 | 737 | #ifndef WGL_NV_render_texture_rectangle 738 | #define WGL_NV_render_texture_rectangle 1 739 | #define WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV 0x20A0 740 | #define WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV 0x20A1 741 | #define WGL_TEXTURE_RECTANGLE_NV 0x20A2 742 | #endif /* WGL_NV_render_texture_rectangle */ 743 | 744 | #ifndef WGL_NV_swap_group 745 | #define WGL_NV_swap_group 1 746 | typedef BOOL (WINAPI * PFNWGLJOINSWAPGROUPNVPROC) (HDC hDC, GLuint group); 747 | typedef BOOL (WINAPI * PFNWGLBINDSWAPBARRIERNVPROC) (GLuint group, GLuint barrier); 748 | typedef BOOL (WINAPI * PFNWGLQUERYSWAPGROUPNVPROC) (HDC hDC, GLuint *group, GLuint *barrier); 749 | typedef BOOL (WINAPI * PFNWGLQUERYMAXSWAPGROUPSNVPROC) (HDC hDC, GLuint *maxGroups, GLuint *maxBarriers); 750 | typedef BOOL (WINAPI * PFNWGLQUERYFRAMECOUNTNVPROC) (HDC hDC, GLuint *count); 751 | typedef BOOL (WINAPI * PFNWGLRESETFRAMECOUNTNVPROC) (HDC hDC); 752 | #ifdef WGL_WGLEXT_PROTOTYPES 753 | BOOL WINAPI wglJoinSwapGroupNV (HDC hDC, GLuint group); 754 | BOOL WINAPI wglBindSwapBarrierNV (GLuint group, GLuint barrier); 755 | BOOL WINAPI wglQuerySwapGroupNV (HDC hDC, GLuint *group, GLuint *barrier); 756 | BOOL WINAPI wglQueryMaxSwapGroupsNV (HDC hDC, GLuint *maxGroups, GLuint *maxBarriers); 757 | BOOL WINAPI wglQueryFrameCountNV (HDC hDC, GLuint *count); 758 | BOOL WINAPI wglResetFrameCountNV (HDC hDC); 759 | #endif 760 | #endif /* WGL_NV_swap_group */ 761 | 762 | #ifndef WGL_NV_vertex_array_range 763 | #define WGL_NV_vertex_array_range 1 764 | typedef void *(WINAPI * PFNWGLALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority); 765 | typedef void (WINAPI * PFNWGLFREEMEMORYNVPROC) (void *pointer); 766 | #ifdef WGL_WGLEXT_PROTOTYPES 767 | void *WINAPI wglAllocateMemoryNV (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority); 768 | void WINAPI wglFreeMemoryNV (void *pointer); 769 | #endif 770 | #endif /* WGL_NV_vertex_array_range */ 771 | 772 | #ifndef WGL_NV_video_capture 773 | #define WGL_NV_video_capture 1 774 | DECLARE_HANDLE(HVIDEOINPUTDEVICENV); 775 | #define WGL_UNIQUE_ID_NV 0x20CE 776 | #define WGL_NUM_VIDEO_CAPTURE_SLOTS_NV 0x20CF 777 | typedef BOOL (WINAPI * PFNWGLBINDVIDEOCAPTUREDEVICENVPROC) (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice); 778 | typedef UINT (WINAPI * PFNWGLENUMERATEVIDEOCAPTUREDEVICESNVPROC) (HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList); 779 | typedef BOOL (WINAPI * PFNWGLLOCKVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice); 780 | typedef BOOL (WINAPI * PFNWGLQUERYVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue); 781 | typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice); 782 | #ifdef WGL_WGLEXT_PROTOTYPES 783 | BOOL WINAPI wglBindVideoCaptureDeviceNV (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice); 784 | UINT WINAPI wglEnumerateVideoCaptureDevicesNV (HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList); 785 | BOOL WINAPI wglLockVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice); 786 | BOOL WINAPI wglQueryVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue); 787 | BOOL WINAPI wglReleaseVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice); 788 | #endif 789 | #endif /* WGL_NV_video_capture */ 790 | 791 | #ifndef WGL_NV_video_output 792 | #define WGL_NV_video_output 1 793 | DECLARE_HANDLE(HPVIDEODEV); 794 | #define WGL_BIND_TO_VIDEO_RGB_NV 0x20C0 795 | #define WGL_BIND_TO_VIDEO_RGBA_NV 0x20C1 796 | #define WGL_BIND_TO_VIDEO_RGB_AND_DEPTH_NV 0x20C2 797 | #define WGL_VIDEO_OUT_COLOR_NV 0x20C3 798 | #define WGL_VIDEO_OUT_ALPHA_NV 0x20C4 799 | #define WGL_VIDEO_OUT_DEPTH_NV 0x20C5 800 | #define WGL_VIDEO_OUT_COLOR_AND_ALPHA_NV 0x20C6 801 | #define WGL_VIDEO_OUT_COLOR_AND_DEPTH_NV 0x20C7 802 | #define WGL_VIDEO_OUT_FRAME 0x20C8 803 | #define WGL_VIDEO_OUT_FIELD_1 0x20C9 804 | #define WGL_VIDEO_OUT_FIELD_2 0x20CA 805 | #define WGL_VIDEO_OUT_STACKED_FIELDS_1_2 0x20CB 806 | #define WGL_VIDEO_OUT_STACKED_FIELDS_2_1 0x20CC 807 | typedef BOOL (WINAPI * PFNWGLGETVIDEODEVICENVPROC) (HDC hDC, int numDevices, HPVIDEODEV *hVideoDevice); 808 | typedef BOOL (WINAPI * PFNWGLRELEASEVIDEODEVICENVPROC) (HPVIDEODEV hVideoDevice); 809 | typedef BOOL (WINAPI * PFNWGLBINDVIDEOIMAGENVPROC) (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer); 810 | typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOIMAGENVPROC) (HPBUFFERARB hPbuffer, int iVideoBuffer); 811 | typedef BOOL (WINAPI * PFNWGLSENDPBUFFERTOVIDEONVPROC) (HPBUFFERARB hPbuffer, int iBufferType, unsigned long *pulCounterPbuffer, BOOL bBlock); 812 | typedef BOOL (WINAPI * PFNWGLGETVIDEOINFONVPROC) (HPVIDEODEV hpVideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo); 813 | #ifdef WGL_WGLEXT_PROTOTYPES 814 | BOOL WINAPI wglGetVideoDeviceNV (HDC hDC, int numDevices, HPVIDEODEV *hVideoDevice); 815 | BOOL WINAPI wglReleaseVideoDeviceNV (HPVIDEODEV hVideoDevice); 816 | BOOL WINAPI wglBindVideoImageNV (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer); 817 | BOOL WINAPI wglReleaseVideoImageNV (HPBUFFERARB hPbuffer, int iVideoBuffer); 818 | BOOL WINAPI wglSendPbufferToVideoNV (HPBUFFERARB hPbuffer, int iBufferType, unsigned long *pulCounterPbuffer, BOOL bBlock); 819 | BOOL WINAPI wglGetVideoInfoNV (HPVIDEODEV hpVideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo); 820 | #endif 821 | #endif /* WGL_NV_video_output */ 822 | 823 | #ifndef WGL_OML_sync_control 824 | #define WGL_OML_sync_control 1 825 | typedef BOOL (WINAPI * PFNWGLGETSYNCVALUESOMLPROC) (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc); 826 | typedef BOOL (WINAPI * PFNWGLGETMSCRATEOMLPROC) (HDC hdc, INT32 *numerator, INT32 *denominator); 827 | typedef INT64 (WINAPI * PFNWGLSWAPBUFFERSMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder); 828 | typedef INT64 (WINAPI * PFNWGLSWAPLAYERBUFFERSMSCOMLPROC) (HDC hdc, INT fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder); 829 | typedef BOOL (WINAPI * PFNWGLWAITFORMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc); 830 | typedef BOOL (WINAPI * PFNWGLWAITFORSBCOMLPROC) (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc); 831 | #ifdef WGL_WGLEXT_PROTOTYPES 832 | BOOL WINAPI wglGetSyncValuesOML (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc); 833 | BOOL WINAPI wglGetMscRateOML (HDC hdc, INT32 *numerator, INT32 *denominator); 834 | INT64 WINAPI wglSwapBuffersMscOML (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder); 835 | INT64 WINAPI wglSwapLayerBuffersMscOML (HDC hdc, INT fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder); 836 | BOOL WINAPI wglWaitForMscOML (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc); 837 | BOOL WINAPI wglWaitForSbcOML (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc); 838 | #endif 839 | #endif /* WGL_OML_sync_control */ 840 | 841 | #ifdef __cplusplus 842 | } 843 | #endif 844 | 845 | #endif 846 | -------------------------------------------------------------------------------- /examples/win32-custom-implementation/win32-custom-implementation.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************************* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2020 Tarek Sherif 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | * this software and associated documentation files (the "Software"), to deal in 8 | * the Software without restriction, including without limitation the rights to 9 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | * the Software, and to permit persons to whom the Software is furnished to do so, 11 | * subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | **********************************************************************************/ 23 | 24 | ////////////////////////////////////////////////////// 25 | // Example of basic C++ usage of Simple OpenGL 26 | // Loader with a custom Win32 implementation and 27 | // constants defined at the command line. 28 | ////////////////////////////////////////////////////// 29 | 30 | #define WIN32_LEAN_AND_MEAN 31 | #define SOGL_IMPLEMENTATION 32 | #include "../../simple-opengl-loader.h" 33 | #include 34 | #include 35 | #include "wglext.h" 36 | #include 37 | #include 38 | 39 | typedef PROC (*wglGetProcAddressFP)(LPCSTR Arg1); 40 | static HMODULE openGLLibHandle = NULL; 41 | 42 | void *sogl_loadOpenGLFunction(const char *name) { 43 | static wglGetProcAddressFP wglGetProcAddress = NULL; 44 | 45 | if (!openGLLibHandle) { 46 | openGLLibHandle = LoadLibraryA("opengl32.dll"); 47 | wglGetProcAddress = (wglGetProcAddressFP) GetProcAddress(openGLLibHandle, "wglGetProcAddress"); 48 | } 49 | void *fn = (void *)wglGetProcAddress(name); 50 | if(fn == 0 || (fn == (void *) 0x1) || (fn == (void *) 0x2) || (fn == (void*) 0x3) || (fn == (void *) -1)) { 51 | fn = (void *) GetProcAddress(openGLLibHandle, name); 52 | } 53 | 54 | return fn; 55 | } 56 | 57 | void sogl_cleanup() { 58 | if (openGLLibHandle) { 59 | FreeLibrary(openGLLibHandle); 60 | openGLLibHandle = NULL; 61 | } 62 | } 63 | 64 | ///////////////////////////////////// 65 | // WGL loading helper functions 66 | ///////////////////////////////////// 67 | 68 | #define DECLARE_WGL_EXT_FUNC(returnType, name, ...) typedef returnType (WINAPI *name##FUNC)(__VA_ARGS__);\ 69 | name##FUNC name = (name##FUNC)0; 70 | #define LOAD_WGL_EXT_FUNC(name) name = (name##FUNC) wglGetProcAddress(#name) 71 | 72 | ///////////////////////////////////// 73 | // Set up OpenGL function pointers 74 | ///////////////////////////////////// 75 | 76 | DECLARE_WGL_EXT_FUNC(BOOL, wglChoosePixelFormatARB, HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); 77 | DECLARE_WGL_EXT_FUNC(HGLRC, wglCreateContextAttribsARB, HDC hDC, HGLRC hshareContext, const int *attribList); 78 | 79 | //////////////// 80 | // WIN32 setup 81 | //////////////// 82 | 83 | const WCHAR WIN_CLASS_NAME[] = L"OPENGL_WINDOW_CLASS"; 84 | 85 | LRESULT CALLBACK winProc(HWND window, UINT message, WPARAM wParam, LPARAM lParam) { 86 | switch (message) { 87 | case WM_SIZING: { 88 | if (glViewport) { 89 | RECT* bounds = (RECT *) lParam; 90 | UINT width = bounds->right - bounds->left; 91 | UINT height = bounds->bottom - bounds->top; 92 | glViewport(0, 0, width, height); 93 | } 94 | return 0; 95 | } break; 96 | case WM_PAINT: { 97 | if (glClear) { 98 | HDC deviceContext = GetDC(window); 99 | glClear(GL_COLOR_BUFFER_BIT); 100 | glDrawArrays(GL_TRIANGLES, 0, 3); 101 | SwapBuffers(deviceContext); 102 | } 103 | } break; 104 | case WM_CLOSE: { 105 | PostQuitMessage(0); 106 | return 0; 107 | } break; 108 | } 109 | 110 | return DefWindowProc(window, message, wParam, lParam); 111 | } 112 | 113 | int CALLBACK WinMain(HINSTANCE instance, HINSTANCE prevInstance, LPSTR cmdLine, int showWindow) { 114 | WNDCLASSEX winClass = {0}; 115 | winClass.cbSize = sizeof(winClass); 116 | winClass.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; 117 | winClass.lpfnWndProc = winProc; 118 | winClass.hInstance = instance; 119 | winClass.hIcon = LoadIcon(instance, IDI_APPLICATION); 120 | winClass.hIconSm = LoadIcon(instance, IDI_APPLICATION); 121 | winClass.hCursor = LoadCursor(NULL, IDC_ARROW); 122 | winClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); 123 | winClass.lpszClassName = WIN_CLASS_NAME; 124 | 125 | if (!RegisterClassEx(&winClass)) { 126 | MessageBox(NULL, L"Failed to register window class!", L"FAILURE", MB_OK); 127 | 128 | return 1; 129 | } 130 | 131 | //////////////////////////////////////////////////////////////////// 132 | // Create a dummy window so we can get WGL extension functions 133 | //////////////////////////////////////////////////////////////////// 134 | 135 | HWND dummyWindow = CreateWindow(WIN_CLASS_NAME, L"DUMMY", WS_OVERLAPPEDWINDOW, 0, 0, 1, 1, NULL, NULL, instance, NULL); 136 | 137 | if (!dummyWindow) { 138 | MessageBox(NULL, L"Failed to create window!", L"FAILURE", MB_OK); 139 | 140 | return 1; 141 | } 142 | 143 | HDC dummyContext = GetDC(dummyWindow); 144 | 145 | PIXELFORMATDESCRIPTOR pfd = {0}; 146 | pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR); 147 | pfd.nVersion = 1; 148 | pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, 149 | pfd.iPixelType = PFD_TYPE_RGBA, 150 | pfd.cColorBits = 32; 151 | pfd.cDepthBits = 24; 152 | pfd.cStencilBits = 8; 153 | pfd.iLayerType = PFD_MAIN_PLANE; 154 | 155 | int pixelFormat = ChoosePixelFormat(dummyContext, &pfd); 156 | SetPixelFormat(dummyContext, pixelFormat, &pfd); 157 | HGLRC dummyGL = wglCreateContext(dummyContext); 158 | wglMakeCurrent(dummyContext, dummyGL); 159 | 160 | LOAD_WGL_EXT_FUNC(wglChoosePixelFormatARB); 161 | LOAD_WGL_EXT_FUNC(wglCreateContextAttribsARB); 162 | 163 | if (!wglCreateContextAttribsARB || !wglCreateContextAttribsARB) { 164 | MessageBox(NULL, L"Didn't get wgl ARB functions!", L"FAILURE", MB_OK); 165 | return 1; 166 | } 167 | 168 | wglMakeCurrent(NULL, NULL); 169 | wglDeleteContext(dummyGL); 170 | DestroyWindow(dummyWindow); 171 | 172 | ///////////////////////////////////////////// 173 | // Create real window and rendering context 174 | ///////////////////////////////////////////// 175 | 176 | HWND window = CreateWindow( 177 | WIN_CLASS_NAME, 178 | L"Simple OpenGL Loader Win32 C++ Custom Implementation Example", 179 | WS_OVERLAPPEDWINDOW, 180 | CW_USEDEFAULT, CW_USEDEFAULT, 181 | 800, 800, 182 | NULL, 183 | NULL, 184 | instance, 185 | NULL 186 | ); 187 | 188 | if (!window) { 189 | MessageBox(NULL, L"Failed to create window!", L"FAILURE", MB_OK); 190 | 191 | return 1; 192 | } 193 | 194 | HDC deviceContext = GetDC(window); 195 | 196 | const int pixelAttribList[] = { 197 | WGL_DRAW_TO_WINDOW_ARB, GL_TRUE, 198 | WGL_SUPPORT_OPENGL_ARB, GL_TRUE, 199 | WGL_DOUBLE_BUFFER_ARB, GL_TRUE, 200 | WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB, 201 | WGL_COLOR_BITS_ARB, 32, 202 | WGL_DEPTH_BITS_ARB, 24, 203 | WGL_STENCIL_BITS_ARB, 8, 204 | WGL_ACCELERATION_ARB, WGL_FULL_ACCELERATION_ARB, 205 | WGL_SAMPLE_BUFFERS_ARB, GL_TRUE, 206 | WGL_SAMPLES_ARB, 4, 207 | 0 208 | }; 209 | 210 | UINT numFormats; 211 | BOOL success; 212 | success = wglChoosePixelFormatARB(deviceContext, pixelAttribList, NULL, 1, &pixelFormat, &numFormats); 213 | 214 | if (!success || numFormats == 0) { 215 | MessageBox(NULL, L"Didn't get ARB pixel format!", L"FAILURE", MB_OK); 216 | return 1; 217 | } 218 | 219 | DescribePixelFormat(deviceContext, pixelFormat, sizeof(pfd), &pfd); 220 | SetPixelFormat(deviceContext, pixelFormat, &pfd); 221 | 222 | const int contextAttribList[] = { 223 | WGL_CONTEXT_MAJOR_VERSION_ARB, 4, 224 | WGL_CONTEXT_MINOR_VERSION_ARB, 5, 225 | WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB, 226 | 0 227 | }; 228 | 229 | HGLRC gl = wglCreateContextAttribsARB(deviceContext, NULL, contextAttribList); 230 | 231 | if (!gl) { 232 | MessageBox(NULL, L"Didn't get ARB GL context!", L"FAILURE", MB_OK); 233 | return 1; 234 | } 235 | 236 | wglMakeCurrent(deviceContext, gl); 237 | 238 | if (!sogl_loadOpenGL()) { 239 | const char **failures = sogl_getFailures(); 240 | while (*failures) { 241 | char debugMessage[256]; 242 | snprintf(debugMessage, 256, "SOGL WIN32 EXAMPLE: Failed to load function %s\n", *failures); 243 | OutputDebugStringA(debugMessage); 244 | failures++; 245 | } 246 | } 247 | 248 | /////////////////////////// 249 | // Set up GL resources 250 | /////////////////////////// 251 | 252 | glClearColor(0.0f, 0.0f, 0.0f, 1.0f); 253 | 254 | const char* vsSource = R"GLSL(#version 450 255 | layout (location=0) in vec4 position; 256 | layout (location=1) in vec3 color; 257 | out vec3 vColor; 258 | void main() { 259 | vColor = color; 260 | gl_Position = position; 261 | }; 262 | )GLSL"; 263 | 264 | const char* fsSource = R"GLSL(#version 450 265 | in vec3 vColor; 266 | out vec4 fragColor; 267 | void main() { 268 | fragColor = vec4(vColor, 1.0); 269 | } 270 | )GLSL"; 271 | 272 | GLuint vertexShader = glCreateShader(GL_VERTEX_SHADER); 273 | glShaderSource(vertexShader, 1, &vsSource, NULL); 274 | glCompileShader(vertexShader); 275 | 276 | GLuint fragmentShader = glCreateShader(GL_FRAGMENT_SHADER); 277 | glShaderSource(fragmentShader, 1, &fsSource, NULL); 278 | glCompileShader(fragmentShader); 279 | 280 | GLuint program = glCreateProgram(); 281 | glAttachShader(program, vertexShader); 282 | glAttachShader(program, fragmentShader); 283 | glLinkProgram(program); 284 | 285 | GLint result; 286 | glGetProgramiv(program, GL_LINK_STATUS, &result); 287 | 288 | if (result != GL_TRUE) { 289 | MessageBox(NULL, L"Program failed to link!", L"FAILURE", MB_OK); 290 | } 291 | 292 | glUseProgram(program); 293 | 294 | GLuint triangleArray; 295 | glGenVertexArrays(1, &triangleArray); 296 | glBindVertexArray(triangleArray); 297 | 298 | float positions[] = { 299 | -0.5, -0.5, 300 | 0.5, -0.5, 301 | 0.0, 0.5 302 | }; 303 | 304 | GLuint positionBuffer; 305 | glGenBuffers(1, &positionBuffer); 306 | glBindBuffer(GL_ARRAY_BUFFER, positionBuffer); 307 | glBufferData(GL_ARRAY_BUFFER, sizeof(positions), positions, GL_STATIC_DRAW); 308 | glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, NULL); 309 | glEnableVertexAttribArray(0); 310 | 311 | uint8_t colors[] = { 312 | 255, 0, 0, 313 | 0, 255, 0, 314 | 0, 0, 255 315 | }; 316 | 317 | GLuint colorBuffer; 318 | glGenBuffers(1, &colorBuffer); 319 | glBindBuffer(GL_ARRAY_BUFFER, colorBuffer); 320 | glBufferData(GL_ARRAY_BUFFER, sizeof(colors), colors, GL_STATIC_DRAW); 321 | glVertexAttribPointer(1, 3, GL_UNSIGNED_BYTE, GL_TRUE, 0, NULL); 322 | glEnableVertexAttribArray(1); 323 | 324 | /////////////////// 325 | // Display window 326 | /////////////////// 327 | 328 | ShowWindow(window, showWindow); 329 | 330 | ////////////////////////////////// 331 | // Start render and message loop 332 | ////////////////////////////////// 333 | 334 | MSG message; 335 | while (GetMessage(&message, NULL, 0, 0) > 0) { 336 | TranslateMessage(&message); 337 | DispatchMessage(&message); 338 | 339 | glClear(GL_COLOR_BUFFER_BIT); 340 | glDrawArrays(GL_TRIANGLES, 0, 3); 341 | SwapBuffers(deviceContext); 342 | } 343 | 344 | return (int) message.wParam; 345 | } 346 | -------------------------------------------------------------------------------- /examples/win32/build-optimized.bat: -------------------------------------------------------------------------------- 1 | cl /O2 /W3 /WX /D "_UNICODE" /D "UNICODE" win32-example.c user32.lib gdi32.lib opengl32.lib 2 | -------------------------------------------------------------------------------- /examples/win32/build.bat: -------------------------------------------------------------------------------- 1 | cl /Zi /W3 /WX /D "_UNICODE" /D "UNICODE" win32-example.c user32.lib gdi32.lib opengl32.lib 2 | -------------------------------------------------------------------------------- /examples/win32/wglext.h: -------------------------------------------------------------------------------- 1 | #ifndef __wgl_wglext_h_ 2 | #define __wgl_wglext_h_ 1 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | /* 9 | ** Copyright 2013-2020 The Khronos Group Inc. 10 | ** SPDX-License-Identifier: MIT 11 | ** 12 | ** This header is generated from the Khronos OpenGL / OpenGL ES XML 13 | ** API Registry. The current version of the Registry, generator scripts 14 | ** used to make the header, and the header can be found at 15 | ** https://github.com/KhronosGroup/OpenGL-Registry 16 | */ 17 | 18 | #if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) 19 | #define WIN32_LEAN_AND_MEAN 1 20 | #include 21 | #endif 22 | 23 | #define WGL_WGLEXT_VERSION 20200813 24 | 25 | /* Generated C header for: 26 | * API: wgl 27 | * Versions considered: .* 28 | * Versions emitted: _nomatch_^ 29 | * Default extensions included: wgl 30 | * Additional extensions included: _nomatch_^ 31 | * Extensions removed: _nomatch_^ 32 | */ 33 | 34 | #ifndef WGL_ARB_buffer_region 35 | #define WGL_ARB_buffer_region 1 36 | #define WGL_FRONT_COLOR_BUFFER_BIT_ARB 0x00000001 37 | #define WGL_BACK_COLOR_BUFFER_BIT_ARB 0x00000002 38 | #define WGL_DEPTH_BUFFER_BIT_ARB 0x00000004 39 | #define WGL_STENCIL_BUFFER_BIT_ARB 0x00000008 40 | typedef HANDLE (WINAPI * PFNWGLCREATEBUFFERREGIONARBPROC) (HDC hDC, int iLayerPlane, UINT uType); 41 | typedef VOID (WINAPI * PFNWGLDELETEBUFFERREGIONARBPROC) (HANDLE hRegion); 42 | typedef BOOL (WINAPI * PFNWGLSAVEBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height); 43 | typedef BOOL (WINAPI * PFNWGLRESTOREBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc); 44 | #ifdef WGL_WGLEXT_PROTOTYPES 45 | HANDLE WINAPI wglCreateBufferRegionARB (HDC hDC, int iLayerPlane, UINT uType); 46 | VOID WINAPI wglDeleteBufferRegionARB (HANDLE hRegion); 47 | BOOL WINAPI wglSaveBufferRegionARB (HANDLE hRegion, int x, int y, int width, int height); 48 | BOOL WINAPI wglRestoreBufferRegionARB (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc); 49 | #endif 50 | #endif /* WGL_ARB_buffer_region */ 51 | 52 | #ifndef WGL_ARB_context_flush_control 53 | #define WGL_ARB_context_flush_control 1 54 | #define WGL_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097 55 | #define WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0 56 | #define WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098 57 | #endif /* WGL_ARB_context_flush_control */ 58 | 59 | #ifndef WGL_ARB_create_context 60 | #define WGL_ARB_create_context 1 61 | #define WGL_CONTEXT_DEBUG_BIT_ARB 0x00000001 62 | #define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002 63 | #define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 64 | #define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 65 | #define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093 66 | #define WGL_CONTEXT_FLAGS_ARB 0x2094 67 | #define ERROR_INVALID_VERSION_ARB 0x2095 68 | typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, HGLRC hShareContext, const int *attribList); 69 | #ifdef WGL_WGLEXT_PROTOTYPES 70 | HGLRC WINAPI wglCreateContextAttribsARB (HDC hDC, HGLRC hShareContext, const int *attribList); 71 | #endif 72 | #endif /* WGL_ARB_create_context */ 73 | 74 | #ifndef WGL_ARB_create_context_no_error 75 | #define WGL_ARB_create_context_no_error 1 76 | #define WGL_CONTEXT_OPENGL_NO_ERROR_ARB 0x31B3 77 | #endif /* WGL_ARB_create_context_no_error */ 78 | 79 | #ifndef WGL_ARB_create_context_profile 80 | #define WGL_ARB_create_context_profile 1 81 | #define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126 82 | #define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 83 | #define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 84 | #define ERROR_INVALID_PROFILE_ARB 0x2096 85 | #endif /* WGL_ARB_create_context_profile */ 86 | 87 | #ifndef WGL_ARB_create_context_robustness 88 | #define WGL_ARB_create_context_robustness 1 89 | #define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004 90 | #define WGL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 91 | #define WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 92 | #define WGL_NO_RESET_NOTIFICATION_ARB 0x8261 93 | #endif /* WGL_ARB_create_context_robustness */ 94 | 95 | #ifndef WGL_ARB_extensions_string 96 | #define WGL_ARB_extensions_string 1 97 | typedef const char *(WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC hdc); 98 | #ifdef WGL_WGLEXT_PROTOTYPES 99 | const char *WINAPI wglGetExtensionsStringARB (HDC hdc); 100 | #endif 101 | #endif /* WGL_ARB_extensions_string */ 102 | 103 | #ifndef WGL_ARB_framebuffer_sRGB 104 | #define WGL_ARB_framebuffer_sRGB 1 105 | #define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20A9 106 | #endif /* WGL_ARB_framebuffer_sRGB */ 107 | 108 | #ifndef WGL_ARB_make_current_read 109 | #define WGL_ARB_make_current_read 1 110 | #define ERROR_INVALID_PIXEL_TYPE_ARB 0x2043 111 | #define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054 112 | typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTARBPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); 113 | typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCARBPROC) (void); 114 | #ifdef WGL_WGLEXT_PROTOTYPES 115 | BOOL WINAPI wglMakeContextCurrentARB (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); 116 | HDC WINAPI wglGetCurrentReadDCARB (void); 117 | #endif 118 | #endif /* WGL_ARB_make_current_read */ 119 | 120 | #ifndef WGL_ARB_multisample 121 | #define WGL_ARB_multisample 1 122 | #define WGL_SAMPLE_BUFFERS_ARB 0x2041 123 | #define WGL_SAMPLES_ARB 0x2042 124 | #endif /* WGL_ARB_multisample */ 125 | 126 | #ifndef WGL_ARB_pbuffer 127 | #define WGL_ARB_pbuffer 1 128 | DECLARE_HANDLE(HPBUFFERARB); 129 | #define WGL_DRAW_TO_PBUFFER_ARB 0x202D 130 | #define WGL_MAX_PBUFFER_PIXELS_ARB 0x202E 131 | #define WGL_MAX_PBUFFER_WIDTH_ARB 0x202F 132 | #define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030 133 | #define WGL_PBUFFER_LARGEST_ARB 0x2033 134 | #define WGL_PBUFFER_WIDTH_ARB 0x2034 135 | #define WGL_PBUFFER_HEIGHT_ARB 0x2035 136 | #define WGL_PBUFFER_LOST_ARB 0x2036 137 | typedef HPBUFFERARB (WINAPI * PFNWGLCREATEPBUFFERARBPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); 138 | typedef HDC (WINAPI * PFNWGLGETPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer); 139 | typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer, HDC hDC); 140 | typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFERARBPROC) (HPBUFFERARB hPbuffer); 141 | typedef BOOL (WINAPI * PFNWGLQUERYPBUFFERARBPROC) (HPBUFFERARB hPbuffer, int iAttribute, int *piValue); 142 | #ifdef WGL_WGLEXT_PROTOTYPES 143 | HPBUFFERARB WINAPI wglCreatePbufferARB (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); 144 | HDC WINAPI wglGetPbufferDCARB (HPBUFFERARB hPbuffer); 145 | int WINAPI wglReleasePbufferDCARB (HPBUFFERARB hPbuffer, HDC hDC); 146 | BOOL WINAPI wglDestroyPbufferARB (HPBUFFERARB hPbuffer); 147 | BOOL WINAPI wglQueryPbufferARB (HPBUFFERARB hPbuffer, int iAttribute, int *piValue); 148 | #endif 149 | #endif /* WGL_ARB_pbuffer */ 150 | 151 | #ifndef WGL_ARB_pixel_format 152 | #define WGL_ARB_pixel_format 1 153 | #define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000 154 | #define WGL_DRAW_TO_WINDOW_ARB 0x2001 155 | #define WGL_DRAW_TO_BITMAP_ARB 0x2002 156 | #define WGL_ACCELERATION_ARB 0x2003 157 | #define WGL_NEED_PALETTE_ARB 0x2004 158 | #define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005 159 | #define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006 160 | #define WGL_SWAP_METHOD_ARB 0x2007 161 | #define WGL_NUMBER_OVERLAYS_ARB 0x2008 162 | #define WGL_NUMBER_UNDERLAYS_ARB 0x2009 163 | #define WGL_TRANSPARENT_ARB 0x200A 164 | #define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037 165 | #define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038 166 | #define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039 167 | #define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A 168 | #define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B 169 | #define WGL_SHARE_DEPTH_ARB 0x200C 170 | #define WGL_SHARE_STENCIL_ARB 0x200D 171 | #define WGL_SHARE_ACCUM_ARB 0x200E 172 | #define WGL_SUPPORT_GDI_ARB 0x200F 173 | #define WGL_SUPPORT_OPENGL_ARB 0x2010 174 | #define WGL_DOUBLE_BUFFER_ARB 0x2011 175 | #define WGL_STEREO_ARB 0x2012 176 | #define WGL_PIXEL_TYPE_ARB 0x2013 177 | #define WGL_COLOR_BITS_ARB 0x2014 178 | #define WGL_RED_BITS_ARB 0x2015 179 | #define WGL_RED_SHIFT_ARB 0x2016 180 | #define WGL_GREEN_BITS_ARB 0x2017 181 | #define WGL_GREEN_SHIFT_ARB 0x2018 182 | #define WGL_BLUE_BITS_ARB 0x2019 183 | #define WGL_BLUE_SHIFT_ARB 0x201A 184 | #define WGL_ALPHA_BITS_ARB 0x201B 185 | #define WGL_ALPHA_SHIFT_ARB 0x201C 186 | #define WGL_ACCUM_BITS_ARB 0x201D 187 | #define WGL_ACCUM_RED_BITS_ARB 0x201E 188 | #define WGL_ACCUM_GREEN_BITS_ARB 0x201F 189 | #define WGL_ACCUM_BLUE_BITS_ARB 0x2020 190 | #define WGL_ACCUM_ALPHA_BITS_ARB 0x2021 191 | #define WGL_DEPTH_BITS_ARB 0x2022 192 | #define WGL_STENCIL_BITS_ARB 0x2023 193 | #define WGL_AUX_BUFFERS_ARB 0x2024 194 | #define WGL_NO_ACCELERATION_ARB 0x2025 195 | #define WGL_GENERIC_ACCELERATION_ARB 0x2026 196 | #define WGL_FULL_ACCELERATION_ARB 0x2027 197 | #define WGL_SWAP_EXCHANGE_ARB 0x2028 198 | #define WGL_SWAP_COPY_ARB 0x2029 199 | #define WGL_SWAP_UNDEFINED_ARB 0x202A 200 | #define WGL_TYPE_RGBA_ARB 0x202B 201 | #define WGL_TYPE_COLORINDEX_ARB 0x202C 202 | typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues); 203 | typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues); 204 | typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); 205 | #ifdef WGL_WGLEXT_PROTOTYPES 206 | BOOL WINAPI wglGetPixelFormatAttribivARB (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues); 207 | BOOL WINAPI wglGetPixelFormatAttribfvARB (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues); 208 | BOOL WINAPI wglChoosePixelFormatARB (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); 209 | #endif 210 | #endif /* WGL_ARB_pixel_format */ 211 | 212 | #ifndef WGL_ARB_pixel_format_float 213 | #define WGL_ARB_pixel_format_float 1 214 | #define WGL_TYPE_RGBA_FLOAT_ARB 0x21A0 215 | #endif /* WGL_ARB_pixel_format_float */ 216 | 217 | #ifndef WGL_ARB_render_texture 218 | #define WGL_ARB_render_texture 1 219 | #define WGL_BIND_TO_TEXTURE_RGB_ARB 0x2070 220 | #define WGL_BIND_TO_TEXTURE_RGBA_ARB 0x2071 221 | #define WGL_TEXTURE_FORMAT_ARB 0x2072 222 | #define WGL_TEXTURE_TARGET_ARB 0x2073 223 | #define WGL_MIPMAP_TEXTURE_ARB 0x2074 224 | #define WGL_TEXTURE_RGB_ARB 0x2075 225 | #define WGL_TEXTURE_RGBA_ARB 0x2076 226 | #define WGL_NO_TEXTURE_ARB 0x2077 227 | #define WGL_TEXTURE_CUBE_MAP_ARB 0x2078 228 | #define WGL_TEXTURE_1D_ARB 0x2079 229 | #define WGL_TEXTURE_2D_ARB 0x207A 230 | #define WGL_MIPMAP_LEVEL_ARB 0x207B 231 | #define WGL_CUBE_MAP_FACE_ARB 0x207C 232 | #define WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x207D 233 | #define WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x207E 234 | #define WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x207F 235 | #define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x2080 236 | #define WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x2081 237 | #define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x2082 238 | #define WGL_FRONT_LEFT_ARB 0x2083 239 | #define WGL_FRONT_RIGHT_ARB 0x2084 240 | #define WGL_BACK_LEFT_ARB 0x2085 241 | #define WGL_BACK_RIGHT_ARB 0x2086 242 | #define WGL_AUX0_ARB 0x2087 243 | #define WGL_AUX1_ARB 0x2088 244 | #define WGL_AUX2_ARB 0x2089 245 | #define WGL_AUX3_ARB 0x208A 246 | #define WGL_AUX4_ARB 0x208B 247 | #define WGL_AUX5_ARB 0x208C 248 | #define WGL_AUX6_ARB 0x208D 249 | #define WGL_AUX7_ARB 0x208E 250 | #define WGL_AUX8_ARB 0x208F 251 | #define WGL_AUX9_ARB 0x2090 252 | typedef BOOL (WINAPI * PFNWGLBINDTEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); 253 | typedef BOOL (WINAPI * PFNWGLRELEASETEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); 254 | typedef BOOL (WINAPI * PFNWGLSETPBUFFERATTRIBARBPROC) (HPBUFFERARB hPbuffer, const int *piAttribList); 255 | #ifdef WGL_WGLEXT_PROTOTYPES 256 | BOOL WINAPI wglBindTexImageARB (HPBUFFERARB hPbuffer, int iBuffer); 257 | BOOL WINAPI wglReleaseTexImageARB (HPBUFFERARB hPbuffer, int iBuffer); 258 | BOOL WINAPI wglSetPbufferAttribARB (HPBUFFERARB hPbuffer, const int *piAttribList); 259 | #endif 260 | #endif /* WGL_ARB_render_texture */ 261 | 262 | #ifndef WGL_ARB_robustness_application_isolation 263 | #define WGL_ARB_robustness_application_isolation 1 264 | #define WGL_CONTEXT_RESET_ISOLATION_BIT_ARB 0x00000008 265 | #endif /* WGL_ARB_robustness_application_isolation */ 266 | 267 | #ifndef WGL_ARB_robustness_share_group_isolation 268 | #define WGL_ARB_robustness_share_group_isolation 1 269 | #endif /* WGL_ARB_robustness_share_group_isolation */ 270 | 271 | #ifndef WGL_3DFX_multisample 272 | #define WGL_3DFX_multisample 1 273 | #define WGL_SAMPLE_BUFFERS_3DFX 0x2060 274 | #define WGL_SAMPLES_3DFX 0x2061 275 | #endif /* WGL_3DFX_multisample */ 276 | 277 | #ifndef WGL_3DL_stereo_control 278 | #define WGL_3DL_stereo_control 1 279 | #define WGL_STEREO_EMITTER_ENABLE_3DL 0x2055 280 | #define WGL_STEREO_EMITTER_DISABLE_3DL 0x2056 281 | #define WGL_STEREO_POLARITY_NORMAL_3DL 0x2057 282 | #define WGL_STEREO_POLARITY_INVERT_3DL 0x2058 283 | typedef BOOL (WINAPI * PFNWGLSETSTEREOEMITTERSTATE3DLPROC) (HDC hDC, UINT uState); 284 | #ifdef WGL_WGLEXT_PROTOTYPES 285 | BOOL WINAPI wglSetStereoEmitterState3DL (HDC hDC, UINT uState); 286 | #endif 287 | #endif /* WGL_3DL_stereo_control */ 288 | 289 | #ifndef WGL_AMD_gpu_association 290 | #define WGL_AMD_gpu_association 1 291 | #define WGL_GPU_VENDOR_AMD 0x1F00 292 | #define WGL_GPU_RENDERER_STRING_AMD 0x1F01 293 | #define WGL_GPU_OPENGL_VERSION_STRING_AMD 0x1F02 294 | #define WGL_GPU_FASTEST_TARGET_GPUS_AMD 0x21A2 295 | #define WGL_GPU_RAM_AMD 0x21A3 296 | #define WGL_GPU_CLOCK_AMD 0x21A4 297 | #define WGL_GPU_NUM_PIPES_AMD 0x21A5 298 | #define WGL_GPU_NUM_SIMD_AMD 0x21A6 299 | #define WGL_GPU_NUM_RB_AMD 0x21A7 300 | #define WGL_GPU_NUM_SPI_AMD 0x21A8 301 | typedef UINT (WINAPI * PFNWGLGETGPUIDSAMDPROC) (UINT maxCount, UINT *ids); 302 | typedef INT (WINAPI * PFNWGLGETGPUINFOAMDPROC) (UINT id, INT property, GLenum dataType, UINT size, void *data); 303 | typedef UINT (WINAPI * PFNWGLGETCONTEXTGPUIDAMDPROC) (HGLRC hglrc); 304 | typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTAMDPROC) (UINT id); 305 | typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC) (UINT id, HGLRC hShareContext, const int *attribList); 306 | typedef BOOL (WINAPI * PFNWGLDELETEASSOCIATEDCONTEXTAMDPROC) (HGLRC hglrc); 307 | typedef BOOL (WINAPI * PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC) (HGLRC hglrc); 308 | typedef HGLRC (WINAPI * PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC) (void); 309 | typedef VOID (WINAPI * PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC) (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); 310 | #ifdef WGL_WGLEXT_PROTOTYPES 311 | UINT WINAPI wglGetGPUIDsAMD (UINT maxCount, UINT *ids); 312 | INT WINAPI wglGetGPUInfoAMD (UINT id, INT property, GLenum dataType, UINT size, void *data); 313 | UINT WINAPI wglGetContextGPUIDAMD (HGLRC hglrc); 314 | HGLRC WINAPI wglCreateAssociatedContextAMD (UINT id); 315 | HGLRC WINAPI wglCreateAssociatedContextAttribsAMD (UINT id, HGLRC hShareContext, const int *attribList); 316 | BOOL WINAPI wglDeleteAssociatedContextAMD (HGLRC hglrc); 317 | BOOL WINAPI wglMakeAssociatedContextCurrentAMD (HGLRC hglrc); 318 | HGLRC WINAPI wglGetCurrentAssociatedContextAMD (void); 319 | VOID WINAPI wglBlitContextFramebufferAMD (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); 320 | #endif 321 | #endif /* WGL_AMD_gpu_association */ 322 | 323 | #ifndef WGL_ATI_pixel_format_float 324 | #define WGL_ATI_pixel_format_float 1 325 | #define WGL_TYPE_RGBA_FLOAT_ATI 0x21A0 326 | #endif /* WGL_ATI_pixel_format_float */ 327 | 328 | #ifndef WGL_ATI_render_texture_rectangle 329 | #define WGL_ATI_render_texture_rectangle 1 330 | #define WGL_TEXTURE_RECTANGLE_ATI 0x21A5 331 | #endif /* WGL_ATI_render_texture_rectangle */ 332 | 333 | #ifndef WGL_EXT_colorspace 334 | #define WGL_EXT_colorspace 1 335 | #define WGL_COLORSPACE_EXT 0x309D 336 | #define WGL_COLORSPACE_SRGB_EXT 0x3089 337 | #define WGL_COLORSPACE_LINEAR_EXT 0x308A 338 | #endif /* WGL_EXT_colorspace */ 339 | 340 | #ifndef WGL_EXT_create_context_es2_profile 341 | #define WGL_EXT_create_context_es2_profile 1 342 | #define WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004 343 | #endif /* WGL_EXT_create_context_es2_profile */ 344 | 345 | #ifndef WGL_EXT_create_context_es_profile 346 | #define WGL_EXT_create_context_es_profile 1 347 | #define WGL_CONTEXT_ES_PROFILE_BIT_EXT 0x00000004 348 | #endif /* WGL_EXT_create_context_es_profile */ 349 | 350 | #ifndef WGL_EXT_depth_float 351 | #define WGL_EXT_depth_float 1 352 | #define WGL_DEPTH_FLOAT_EXT 0x2040 353 | #endif /* WGL_EXT_depth_float */ 354 | 355 | #ifndef WGL_EXT_display_color_table 356 | #define WGL_EXT_display_color_table 1 357 | typedef GLboolean (WINAPI * PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC) (GLushort id); 358 | typedef GLboolean (WINAPI * PFNWGLLOADDISPLAYCOLORTABLEEXTPROC) (const GLushort *table, GLuint length); 359 | typedef GLboolean (WINAPI * PFNWGLBINDDISPLAYCOLORTABLEEXTPROC) (GLushort id); 360 | typedef VOID (WINAPI * PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC) (GLushort id); 361 | #ifdef WGL_WGLEXT_PROTOTYPES 362 | GLboolean WINAPI wglCreateDisplayColorTableEXT (GLushort id); 363 | GLboolean WINAPI wglLoadDisplayColorTableEXT (const GLushort *table, GLuint length); 364 | GLboolean WINAPI wglBindDisplayColorTableEXT (GLushort id); 365 | VOID WINAPI wglDestroyDisplayColorTableEXT (GLushort id); 366 | #endif 367 | #endif /* WGL_EXT_display_color_table */ 368 | 369 | #ifndef WGL_EXT_extensions_string 370 | #define WGL_EXT_extensions_string 1 371 | typedef const char *(WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC) (void); 372 | #ifdef WGL_WGLEXT_PROTOTYPES 373 | const char *WINAPI wglGetExtensionsStringEXT (void); 374 | #endif 375 | #endif /* WGL_EXT_extensions_string */ 376 | 377 | #ifndef WGL_EXT_framebuffer_sRGB 378 | #define WGL_EXT_framebuffer_sRGB 1 379 | #define WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20A9 380 | #endif /* WGL_EXT_framebuffer_sRGB */ 381 | 382 | #ifndef WGL_EXT_make_current_read 383 | #define WGL_EXT_make_current_read 1 384 | #define ERROR_INVALID_PIXEL_TYPE_EXT 0x2043 385 | typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTEXTPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); 386 | typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCEXTPROC) (void); 387 | #ifdef WGL_WGLEXT_PROTOTYPES 388 | BOOL WINAPI wglMakeContextCurrentEXT (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); 389 | HDC WINAPI wglGetCurrentReadDCEXT (void); 390 | #endif 391 | #endif /* WGL_EXT_make_current_read */ 392 | 393 | #ifndef WGL_EXT_multisample 394 | #define WGL_EXT_multisample 1 395 | #define WGL_SAMPLE_BUFFERS_EXT 0x2041 396 | #define WGL_SAMPLES_EXT 0x2042 397 | #endif /* WGL_EXT_multisample */ 398 | 399 | #ifndef WGL_EXT_pbuffer 400 | #define WGL_EXT_pbuffer 1 401 | DECLARE_HANDLE(HPBUFFEREXT); 402 | #define WGL_DRAW_TO_PBUFFER_EXT 0x202D 403 | #define WGL_MAX_PBUFFER_PIXELS_EXT 0x202E 404 | #define WGL_MAX_PBUFFER_WIDTH_EXT 0x202F 405 | #define WGL_MAX_PBUFFER_HEIGHT_EXT 0x2030 406 | #define WGL_OPTIMAL_PBUFFER_WIDTH_EXT 0x2031 407 | #define WGL_OPTIMAL_PBUFFER_HEIGHT_EXT 0x2032 408 | #define WGL_PBUFFER_LARGEST_EXT 0x2033 409 | #define WGL_PBUFFER_WIDTH_EXT 0x2034 410 | #define WGL_PBUFFER_HEIGHT_EXT 0x2035 411 | typedef HPBUFFEREXT (WINAPI * PFNWGLCREATEPBUFFEREXTPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); 412 | typedef HDC (WINAPI * PFNWGLGETPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer); 413 | typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer, HDC hDC); 414 | typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer); 415 | typedef BOOL (WINAPI * PFNWGLQUERYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer, int iAttribute, int *piValue); 416 | #ifdef WGL_WGLEXT_PROTOTYPES 417 | HPBUFFEREXT WINAPI wglCreatePbufferEXT (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); 418 | HDC WINAPI wglGetPbufferDCEXT (HPBUFFEREXT hPbuffer); 419 | int WINAPI wglReleasePbufferDCEXT (HPBUFFEREXT hPbuffer, HDC hDC); 420 | BOOL WINAPI wglDestroyPbufferEXT (HPBUFFEREXT hPbuffer); 421 | BOOL WINAPI wglQueryPbufferEXT (HPBUFFEREXT hPbuffer, int iAttribute, int *piValue); 422 | #endif 423 | #endif /* WGL_EXT_pbuffer */ 424 | 425 | #ifndef WGL_EXT_pixel_format 426 | #define WGL_EXT_pixel_format 1 427 | #define WGL_NUMBER_PIXEL_FORMATS_EXT 0x2000 428 | #define WGL_DRAW_TO_WINDOW_EXT 0x2001 429 | #define WGL_DRAW_TO_BITMAP_EXT 0x2002 430 | #define WGL_ACCELERATION_EXT 0x2003 431 | #define WGL_NEED_PALETTE_EXT 0x2004 432 | #define WGL_NEED_SYSTEM_PALETTE_EXT 0x2005 433 | #define WGL_SWAP_LAYER_BUFFERS_EXT 0x2006 434 | #define WGL_SWAP_METHOD_EXT 0x2007 435 | #define WGL_NUMBER_OVERLAYS_EXT 0x2008 436 | #define WGL_NUMBER_UNDERLAYS_EXT 0x2009 437 | #define WGL_TRANSPARENT_EXT 0x200A 438 | #define WGL_TRANSPARENT_VALUE_EXT 0x200B 439 | #define WGL_SHARE_DEPTH_EXT 0x200C 440 | #define WGL_SHARE_STENCIL_EXT 0x200D 441 | #define WGL_SHARE_ACCUM_EXT 0x200E 442 | #define WGL_SUPPORT_GDI_EXT 0x200F 443 | #define WGL_SUPPORT_OPENGL_EXT 0x2010 444 | #define WGL_DOUBLE_BUFFER_EXT 0x2011 445 | #define WGL_STEREO_EXT 0x2012 446 | #define WGL_PIXEL_TYPE_EXT 0x2013 447 | #define WGL_COLOR_BITS_EXT 0x2014 448 | #define WGL_RED_BITS_EXT 0x2015 449 | #define WGL_RED_SHIFT_EXT 0x2016 450 | #define WGL_GREEN_BITS_EXT 0x2017 451 | #define WGL_GREEN_SHIFT_EXT 0x2018 452 | #define WGL_BLUE_BITS_EXT 0x2019 453 | #define WGL_BLUE_SHIFT_EXT 0x201A 454 | #define WGL_ALPHA_BITS_EXT 0x201B 455 | #define WGL_ALPHA_SHIFT_EXT 0x201C 456 | #define WGL_ACCUM_BITS_EXT 0x201D 457 | #define WGL_ACCUM_RED_BITS_EXT 0x201E 458 | #define WGL_ACCUM_GREEN_BITS_EXT 0x201F 459 | #define WGL_ACCUM_BLUE_BITS_EXT 0x2020 460 | #define WGL_ACCUM_ALPHA_BITS_EXT 0x2021 461 | #define WGL_DEPTH_BITS_EXT 0x2022 462 | #define WGL_STENCIL_BITS_EXT 0x2023 463 | #define WGL_AUX_BUFFERS_EXT 0x2024 464 | #define WGL_NO_ACCELERATION_EXT 0x2025 465 | #define WGL_GENERIC_ACCELERATION_EXT 0x2026 466 | #define WGL_FULL_ACCELERATION_EXT 0x2027 467 | #define WGL_SWAP_EXCHANGE_EXT 0x2028 468 | #define WGL_SWAP_COPY_EXT 0x2029 469 | #define WGL_SWAP_UNDEFINED_EXT 0x202A 470 | #define WGL_TYPE_RGBA_EXT 0x202B 471 | #define WGL_TYPE_COLORINDEX_EXT 0x202C 472 | typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues); 473 | typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, FLOAT *pfValues); 474 | typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATEXTPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); 475 | #ifdef WGL_WGLEXT_PROTOTYPES 476 | BOOL WINAPI wglGetPixelFormatAttribivEXT (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues); 477 | BOOL WINAPI wglGetPixelFormatAttribfvEXT (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, FLOAT *pfValues); 478 | BOOL WINAPI wglChoosePixelFormatEXT (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); 479 | #endif 480 | #endif /* WGL_EXT_pixel_format */ 481 | 482 | #ifndef WGL_EXT_pixel_format_packed_float 483 | #define WGL_EXT_pixel_format_packed_float 1 484 | #define WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT 0x20A8 485 | #endif /* WGL_EXT_pixel_format_packed_float */ 486 | 487 | #ifndef WGL_EXT_swap_control 488 | #define WGL_EXT_swap_control 1 489 | typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC) (int interval); 490 | typedef int (WINAPI * PFNWGLGETSWAPINTERVALEXTPROC) (void); 491 | #ifdef WGL_WGLEXT_PROTOTYPES 492 | BOOL WINAPI wglSwapIntervalEXT (int interval); 493 | int WINAPI wglGetSwapIntervalEXT (void); 494 | #endif 495 | #endif /* WGL_EXT_swap_control */ 496 | 497 | #ifndef WGL_EXT_swap_control_tear 498 | #define WGL_EXT_swap_control_tear 1 499 | #endif /* WGL_EXT_swap_control_tear */ 500 | 501 | #ifndef WGL_I3D_digital_video_control 502 | #define WGL_I3D_digital_video_control 1 503 | #define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_FRAMEBUFFER_I3D 0x2050 504 | #define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_VALUE_I3D 0x2051 505 | #define WGL_DIGITAL_VIDEO_CURSOR_INCLUDED_I3D 0x2052 506 | #define WGL_DIGITAL_VIDEO_GAMMA_CORRECTED_I3D 0x2053 507 | typedef BOOL (WINAPI * PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue); 508 | typedef BOOL (WINAPI * PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue); 509 | #ifdef WGL_WGLEXT_PROTOTYPES 510 | BOOL WINAPI wglGetDigitalVideoParametersI3D (HDC hDC, int iAttribute, int *piValue); 511 | BOOL WINAPI wglSetDigitalVideoParametersI3D (HDC hDC, int iAttribute, const int *piValue); 512 | #endif 513 | #endif /* WGL_I3D_digital_video_control */ 514 | 515 | #ifndef WGL_I3D_gamma 516 | #define WGL_I3D_gamma 1 517 | #define WGL_GAMMA_TABLE_SIZE_I3D 0x204E 518 | #define WGL_GAMMA_EXCLUDE_DESKTOP_I3D 0x204F 519 | typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue); 520 | typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue); 521 | typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, USHORT *puRed, USHORT *puGreen, USHORT *puBlue); 522 | typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, const USHORT *puRed, const USHORT *puGreen, const USHORT *puBlue); 523 | #ifdef WGL_WGLEXT_PROTOTYPES 524 | BOOL WINAPI wglGetGammaTableParametersI3D (HDC hDC, int iAttribute, int *piValue); 525 | BOOL WINAPI wglSetGammaTableParametersI3D (HDC hDC, int iAttribute, const int *piValue); 526 | BOOL WINAPI wglGetGammaTableI3D (HDC hDC, int iEntries, USHORT *puRed, USHORT *puGreen, USHORT *puBlue); 527 | BOOL WINAPI wglSetGammaTableI3D (HDC hDC, int iEntries, const USHORT *puRed, const USHORT *puGreen, const USHORT *puBlue); 528 | #endif 529 | #endif /* WGL_I3D_gamma */ 530 | 531 | #ifndef WGL_I3D_genlock 532 | #define WGL_I3D_genlock 1 533 | #define WGL_GENLOCK_SOURCE_MULTIVIEW_I3D 0x2044 534 | #define WGL_GENLOCK_SOURCE_EXTERNAL_SYNC_I3D 0x2045 535 | #define WGL_GENLOCK_SOURCE_EXTERNAL_FIELD_I3D 0x2046 536 | #define WGL_GENLOCK_SOURCE_EXTERNAL_TTL_I3D 0x2047 537 | #define WGL_GENLOCK_SOURCE_DIGITAL_SYNC_I3D 0x2048 538 | #define WGL_GENLOCK_SOURCE_DIGITAL_FIELD_I3D 0x2049 539 | #define WGL_GENLOCK_SOURCE_EDGE_FALLING_I3D 0x204A 540 | #define WGL_GENLOCK_SOURCE_EDGE_RISING_I3D 0x204B 541 | #define WGL_GENLOCK_SOURCE_EDGE_BOTH_I3D 0x204C 542 | typedef BOOL (WINAPI * PFNWGLENABLEGENLOCKI3DPROC) (HDC hDC); 543 | typedef BOOL (WINAPI * PFNWGLDISABLEGENLOCKI3DPROC) (HDC hDC); 544 | typedef BOOL (WINAPI * PFNWGLISENABLEDGENLOCKI3DPROC) (HDC hDC, BOOL *pFlag); 545 | typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEI3DPROC) (HDC hDC, UINT uSource); 546 | typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEI3DPROC) (HDC hDC, UINT *uSource); 547 | typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT uEdge); 548 | typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT *uEdge); 549 | typedef BOOL (WINAPI * PFNWGLGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT uRate); 550 | typedef BOOL (WINAPI * PFNWGLGETGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT *uRate); 551 | typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT uDelay); 552 | typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT *uDelay); 553 | typedef BOOL (WINAPI * PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC) (HDC hDC, UINT *uMaxLineDelay, UINT *uMaxPixelDelay); 554 | #ifdef WGL_WGLEXT_PROTOTYPES 555 | BOOL WINAPI wglEnableGenlockI3D (HDC hDC); 556 | BOOL WINAPI wglDisableGenlockI3D (HDC hDC); 557 | BOOL WINAPI wglIsEnabledGenlockI3D (HDC hDC, BOOL *pFlag); 558 | BOOL WINAPI wglGenlockSourceI3D (HDC hDC, UINT uSource); 559 | BOOL WINAPI wglGetGenlockSourceI3D (HDC hDC, UINT *uSource); 560 | BOOL WINAPI wglGenlockSourceEdgeI3D (HDC hDC, UINT uEdge); 561 | BOOL WINAPI wglGetGenlockSourceEdgeI3D (HDC hDC, UINT *uEdge); 562 | BOOL WINAPI wglGenlockSampleRateI3D (HDC hDC, UINT uRate); 563 | BOOL WINAPI wglGetGenlockSampleRateI3D (HDC hDC, UINT *uRate); 564 | BOOL WINAPI wglGenlockSourceDelayI3D (HDC hDC, UINT uDelay); 565 | BOOL WINAPI wglGetGenlockSourceDelayI3D (HDC hDC, UINT *uDelay); 566 | BOOL WINAPI wglQueryGenlockMaxSourceDelayI3D (HDC hDC, UINT *uMaxLineDelay, UINT *uMaxPixelDelay); 567 | #endif 568 | #endif /* WGL_I3D_genlock */ 569 | 570 | #ifndef WGL_I3D_image_buffer 571 | #define WGL_I3D_image_buffer 1 572 | #define WGL_IMAGE_BUFFER_MIN_ACCESS_I3D 0x00000001 573 | #define WGL_IMAGE_BUFFER_LOCK_I3D 0x00000002 574 | typedef LPVOID (WINAPI * PFNWGLCREATEIMAGEBUFFERI3DPROC) (HDC hDC, DWORD dwSize, UINT uFlags); 575 | typedef BOOL (WINAPI * PFNWGLDESTROYIMAGEBUFFERI3DPROC) (HDC hDC, LPVOID pAddress); 576 | typedef BOOL (WINAPI * PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const HANDLE *pEvent, const LPVOID *pAddress, const DWORD *pSize, UINT count); 577 | typedef BOOL (WINAPI * PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const LPVOID *pAddress, UINT count); 578 | #ifdef WGL_WGLEXT_PROTOTYPES 579 | LPVOID WINAPI wglCreateImageBufferI3D (HDC hDC, DWORD dwSize, UINT uFlags); 580 | BOOL WINAPI wglDestroyImageBufferI3D (HDC hDC, LPVOID pAddress); 581 | BOOL WINAPI wglAssociateImageBufferEventsI3D (HDC hDC, const HANDLE *pEvent, const LPVOID *pAddress, const DWORD *pSize, UINT count); 582 | BOOL WINAPI wglReleaseImageBufferEventsI3D (HDC hDC, const LPVOID *pAddress, UINT count); 583 | #endif 584 | #endif /* WGL_I3D_image_buffer */ 585 | 586 | #ifndef WGL_I3D_swap_frame_lock 587 | #define WGL_I3D_swap_frame_lock 1 588 | typedef BOOL (WINAPI * PFNWGLENABLEFRAMELOCKI3DPROC) (void); 589 | typedef BOOL (WINAPI * PFNWGLDISABLEFRAMELOCKI3DPROC) (void); 590 | typedef BOOL (WINAPI * PFNWGLISENABLEDFRAMELOCKI3DPROC) (BOOL *pFlag); 591 | typedef BOOL (WINAPI * PFNWGLQUERYFRAMELOCKMASTERI3DPROC) (BOOL *pFlag); 592 | #ifdef WGL_WGLEXT_PROTOTYPES 593 | BOOL WINAPI wglEnableFrameLockI3D (void); 594 | BOOL WINAPI wglDisableFrameLockI3D (void); 595 | BOOL WINAPI wglIsEnabledFrameLockI3D (BOOL *pFlag); 596 | BOOL WINAPI wglQueryFrameLockMasterI3D (BOOL *pFlag); 597 | #endif 598 | #endif /* WGL_I3D_swap_frame_lock */ 599 | 600 | #ifndef WGL_I3D_swap_frame_usage 601 | #define WGL_I3D_swap_frame_usage 1 602 | typedef BOOL (WINAPI * PFNWGLGETFRAMEUSAGEI3DPROC) (float *pUsage); 603 | typedef BOOL (WINAPI * PFNWGLBEGINFRAMETRACKINGI3DPROC) (void); 604 | typedef BOOL (WINAPI * PFNWGLENDFRAMETRACKINGI3DPROC) (void); 605 | typedef BOOL (WINAPI * PFNWGLQUERYFRAMETRACKINGI3DPROC) (DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage); 606 | #ifdef WGL_WGLEXT_PROTOTYPES 607 | BOOL WINAPI wglGetFrameUsageI3D (float *pUsage); 608 | BOOL WINAPI wglBeginFrameTrackingI3D (void); 609 | BOOL WINAPI wglEndFrameTrackingI3D (void); 610 | BOOL WINAPI wglQueryFrameTrackingI3D (DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage); 611 | #endif 612 | #endif /* WGL_I3D_swap_frame_usage */ 613 | 614 | #ifndef WGL_NV_DX_interop 615 | #define WGL_NV_DX_interop 1 616 | #define WGL_ACCESS_READ_ONLY_NV 0x00000000 617 | #define WGL_ACCESS_READ_WRITE_NV 0x00000001 618 | #define WGL_ACCESS_WRITE_DISCARD_NV 0x00000002 619 | typedef BOOL (WINAPI * PFNWGLDXSETRESOURCESHAREHANDLENVPROC) (void *dxObject, HANDLE shareHandle); 620 | typedef HANDLE (WINAPI * PFNWGLDXOPENDEVICENVPROC) (void *dxDevice); 621 | typedef BOOL (WINAPI * PFNWGLDXCLOSEDEVICENVPROC) (HANDLE hDevice); 622 | typedef HANDLE (WINAPI * PFNWGLDXREGISTEROBJECTNVPROC) (HANDLE hDevice, void *dxObject, GLuint name, GLenum type, GLenum access); 623 | typedef BOOL (WINAPI * PFNWGLDXUNREGISTEROBJECTNVPROC) (HANDLE hDevice, HANDLE hObject); 624 | typedef BOOL (WINAPI * PFNWGLDXOBJECTACCESSNVPROC) (HANDLE hObject, GLenum access); 625 | typedef BOOL (WINAPI * PFNWGLDXLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE *hObjects); 626 | typedef BOOL (WINAPI * PFNWGLDXUNLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE *hObjects); 627 | #ifdef WGL_WGLEXT_PROTOTYPES 628 | BOOL WINAPI wglDXSetResourceShareHandleNV (void *dxObject, HANDLE shareHandle); 629 | HANDLE WINAPI wglDXOpenDeviceNV (void *dxDevice); 630 | BOOL WINAPI wglDXCloseDeviceNV (HANDLE hDevice); 631 | HANDLE WINAPI wglDXRegisterObjectNV (HANDLE hDevice, void *dxObject, GLuint name, GLenum type, GLenum access); 632 | BOOL WINAPI wglDXUnregisterObjectNV (HANDLE hDevice, HANDLE hObject); 633 | BOOL WINAPI wglDXObjectAccessNV (HANDLE hObject, GLenum access); 634 | BOOL WINAPI wglDXLockObjectsNV (HANDLE hDevice, GLint count, HANDLE *hObjects); 635 | BOOL WINAPI wglDXUnlockObjectsNV (HANDLE hDevice, GLint count, HANDLE *hObjects); 636 | #endif 637 | #endif /* WGL_NV_DX_interop */ 638 | 639 | #ifndef WGL_NV_DX_interop2 640 | #define WGL_NV_DX_interop2 1 641 | #endif /* WGL_NV_DX_interop2 */ 642 | 643 | #ifndef WGL_NV_copy_image 644 | #define WGL_NV_copy_image 1 645 | typedef BOOL (WINAPI * PFNWGLCOPYIMAGESUBDATANVPROC) (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); 646 | #ifdef WGL_WGLEXT_PROTOTYPES 647 | BOOL WINAPI wglCopyImageSubDataNV (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); 648 | #endif 649 | #endif /* WGL_NV_copy_image */ 650 | 651 | #ifndef WGL_NV_delay_before_swap 652 | #define WGL_NV_delay_before_swap 1 653 | typedef BOOL (WINAPI * PFNWGLDELAYBEFORESWAPNVPROC) (HDC hDC, GLfloat seconds); 654 | #ifdef WGL_WGLEXT_PROTOTYPES 655 | BOOL WINAPI wglDelayBeforeSwapNV (HDC hDC, GLfloat seconds); 656 | #endif 657 | #endif /* WGL_NV_delay_before_swap */ 658 | 659 | #ifndef WGL_NV_float_buffer 660 | #define WGL_NV_float_buffer 1 661 | #define WGL_FLOAT_COMPONENTS_NV 0x20B0 662 | #define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV 0x20B1 663 | #define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV 0x20B2 664 | #define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV 0x20B3 665 | #define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV 0x20B4 666 | #define WGL_TEXTURE_FLOAT_R_NV 0x20B5 667 | #define WGL_TEXTURE_FLOAT_RG_NV 0x20B6 668 | #define WGL_TEXTURE_FLOAT_RGB_NV 0x20B7 669 | #define WGL_TEXTURE_FLOAT_RGBA_NV 0x20B8 670 | #endif /* WGL_NV_float_buffer */ 671 | 672 | #ifndef WGL_NV_gpu_affinity 673 | #define WGL_NV_gpu_affinity 1 674 | DECLARE_HANDLE(HGPUNV); 675 | struct _GPU_DEVICE { 676 | DWORD cb; 677 | CHAR DeviceName[32]; 678 | CHAR DeviceString[128]; 679 | DWORD Flags; 680 | RECT rcVirtualScreen; 681 | }; 682 | typedef struct _GPU_DEVICE *PGPU_DEVICE; 683 | #define ERROR_INCOMPATIBLE_AFFINITY_MASKS_NV 0x20D0 684 | #define ERROR_MISSING_AFFINITY_MASK_NV 0x20D1 685 | typedef BOOL (WINAPI * PFNWGLENUMGPUSNVPROC) (UINT iGpuIndex, HGPUNV *phGpu); 686 | typedef BOOL (WINAPI * PFNWGLENUMGPUDEVICESNVPROC) (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice); 687 | typedef HDC (WINAPI * PFNWGLCREATEAFFINITYDCNVPROC) (const HGPUNV *phGpuList); 688 | typedef BOOL (WINAPI * PFNWGLENUMGPUSFROMAFFINITYDCNVPROC) (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu); 689 | typedef BOOL (WINAPI * PFNWGLDELETEDCNVPROC) (HDC hdc); 690 | #ifdef WGL_WGLEXT_PROTOTYPES 691 | BOOL WINAPI wglEnumGpusNV (UINT iGpuIndex, HGPUNV *phGpu); 692 | BOOL WINAPI wglEnumGpuDevicesNV (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice); 693 | HDC WINAPI wglCreateAffinityDCNV (const HGPUNV *phGpuList); 694 | BOOL WINAPI wglEnumGpusFromAffinityDCNV (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu); 695 | BOOL WINAPI wglDeleteDCNV (HDC hdc); 696 | #endif 697 | #endif /* WGL_NV_gpu_affinity */ 698 | 699 | #ifndef WGL_NV_multigpu_context 700 | #define WGL_NV_multigpu_context 1 701 | #define WGL_CONTEXT_MULTIGPU_ATTRIB_NV 0x20AA 702 | #define WGL_CONTEXT_MULTIGPU_ATTRIB_SINGLE_NV 0x20AB 703 | #define WGL_CONTEXT_MULTIGPU_ATTRIB_AFR_NV 0x20AC 704 | #define WGL_CONTEXT_MULTIGPU_ATTRIB_MULTICAST_NV 0x20AD 705 | #define WGL_CONTEXT_MULTIGPU_ATTRIB_MULTI_DISPLAY_MULTICAST_NV 0x20AE 706 | #endif /* WGL_NV_multigpu_context */ 707 | 708 | #ifndef WGL_NV_multisample_coverage 709 | #define WGL_NV_multisample_coverage 1 710 | #define WGL_COVERAGE_SAMPLES_NV 0x2042 711 | #define WGL_COLOR_SAMPLES_NV 0x20B9 712 | #endif /* WGL_NV_multisample_coverage */ 713 | 714 | #ifndef WGL_NV_present_video 715 | #define WGL_NV_present_video 1 716 | DECLARE_HANDLE(HVIDEOOUTPUTDEVICENV); 717 | #define WGL_NUM_VIDEO_SLOTS_NV 0x20F0 718 | typedef int (WINAPI * PFNWGLENUMERATEVIDEODEVICESNVPROC) (HDC hDc, HVIDEOOUTPUTDEVICENV *phDeviceList); 719 | typedef BOOL (WINAPI * PFNWGLBINDVIDEODEVICENVPROC) (HDC hDc, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList); 720 | typedef BOOL (WINAPI * PFNWGLQUERYCURRENTCONTEXTNVPROC) (int iAttribute, int *piValue); 721 | #ifdef WGL_WGLEXT_PROTOTYPES 722 | int WINAPI wglEnumerateVideoDevicesNV (HDC hDc, HVIDEOOUTPUTDEVICENV *phDeviceList); 723 | BOOL WINAPI wglBindVideoDeviceNV (HDC hDc, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList); 724 | BOOL WINAPI wglQueryCurrentContextNV (int iAttribute, int *piValue); 725 | #endif 726 | #endif /* WGL_NV_present_video */ 727 | 728 | #ifndef WGL_NV_render_depth_texture 729 | #define WGL_NV_render_depth_texture 1 730 | #define WGL_BIND_TO_TEXTURE_DEPTH_NV 0x20A3 731 | #define WGL_BIND_TO_TEXTURE_RECTANGLE_DEPTH_NV 0x20A4 732 | #define WGL_DEPTH_TEXTURE_FORMAT_NV 0x20A5 733 | #define WGL_TEXTURE_DEPTH_COMPONENT_NV 0x20A6 734 | #define WGL_DEPTH_COMPONENT_NV 0x20A7 735 | #endif /* WGL_NV_render_depth_texture */ 736 | 737 | #ifndef WGL_NV_render_texture_rectangle 738 | #define WGL_NV_render_texture_rectangle 1 739 | #define WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV 0x20A0 740 | #define WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV 0x20A1 741 | #define WGL_TEXTURE_RECTANGLE_NV 0x20A2 742 | #endif /* WGL_NV_render_texture_rectangle */ 743 | 744 | #ifndef WGL_NV_swap_group 745 | #define WGL_NV_swap_group 1 746 | typedef BOOL (WINAPI * PFNWGLJOINSWAPGROUPNVPROC) (HDC hDC, GLuint group); 747 | typedef BOOL (WINAPI * PFNWGLBINDSWAPBARRIERNVPROC) (GLuint group, GLuint barrier); 748 | typedef BOOL (WINAPI * PFNWGLQUERYSWAPGROUPNVPROC) (HDC hDC, GLuint *group, GLuint *barrier); 749 | typedef BOOL (WINAPI * PFNWGLQUERYMAXSWAPGROUPSNVPROC) (HDC hDC, GLuint *maxGroups, GLuint *maxBarriers); 750 | typedef BOOL (WINAPI * PFNWGLQUERYFRAMECOUNTNVPROC) (HDC hDC, GLuint *count); 751 | typedef BOOL (WINAPI * PFNWGLRESETFRAMECOUNTNVPROC) (HDC hDC); 752 | #ifdef WGL_WGLEXT_PROTOTYPES 753 | BOOL WINAPI wglJoinSwapGroupNV (HDC hDC, GLuint group); 754 | BOOL WINAPI wglBindSwapBarrierNV (GLuint group, GLuint barrier); 755 | BOOL WINAPI wglQuerySwapGroupNV (HDC hDC, GLuint *group, GLuint *barrier); 756 | BOOL WINAPI wglQueryMaxSwapGroupsNV (HDC hDC, GLuint *maxGroups, GLuint *maxBarriers); 757 | BOOL WINAPI wglQueryFrameCountNV (HDC hDC, GLuint *count); 758 | BOOL WINAPI wglResetFrameCountNV (HDC hDC); 759 | #endif 760 | #endif /* WGL_NV_swap_group */ 761 | 762 | #ifndef WGL_NV_vertex_array_range 763 | #define WGL_NV_vertex_array_range 1 764 | typedef void *(WINAPI * PFNWGLALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority); 765 | typedef void (WINAPI * PFNWGLFREEMEMORYNVPROC) (void *pointer); 766 | #ifdef WGL_WGLEXT_PROTOTYPES 767 | void *WINAPI wglAllocateMemoryNV (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority); 768 | void WINAPI wglFreeMemoryNV (void *pointer); 769 | #endif 770 | #endif /* WGL_NV_vertex_array_range */ 771 | 772 | #ifndef WGL_NV_video_capture 773 | #define WGL_NV_video_capture 1 774 | DECLARE_HANDLE(HVIDEOINPUTDEVICENV); 775 | #define WGL_UNIQUE_ID_NV 0x20CE 776 | #define WGL_NUM_VIDEO_CAPTURE_SLOTS_NV 0x20CF 777 | typedef BOOL (WINAPI * PFNWGLBINDVIDEOCAPTUREDEVICENVPROC) (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice); 778 | typedef UINT (WINAPI * PFNWGLENUMERATEVIDEOCAPTUREDEVICESNVPROC) (HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList); 779 | typedef BOOL (WINAPI * PFNWGLLOCKVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice); 780 | typedef BOOL (WINAPI * PFNWGLQUERYVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue); 781 | typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice); 782 | #ifdef WGL_WGLEXT_PROTOTYPES 783 | BOOL WINAPI wglBindVideoCaptureDeviceNV (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice); 784 | UINT WINAPI wglEnumerateVideoCaptureDevicesNV (HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList); 785 | BOOL WINAPI wglLockVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice); 786 | BOOL WINAPI wglQueryVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue); 787 | BOOL WINAPI wglReleaseVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice); 788 | #endif 789 | #endif /* WGL_NV_video_capture */ 790 | 791 | #ifndef WGL_NV_video_output 792 | #define WGL_NV_video_output 1 793 | DECLARE_HANDLE(HPVIDEODEV); 794 | #define WGL_BIND_TO_VIDEO_RGB_NV 0x20C0 795 | #define WGL_BIND_TO_VIDEO_RGBA_NV 0x20C1 796 | #define WGL_BIND_TO_VIDEO_RGB_AND_DEPTH_NV 0x20C2 797 | #define WGL_VIDEO_OUT_COLOR_NV 0x20C3 798 | #define WGL_VIDEO_OUT_ALPHA_NV 0x20C4 799 | #define WGL_VIDEO_OUT_DEPTH_NV 0x20C5 800 | #define WGL_VIDEO_OUT_COLOR_AND_ALPHA_NV 0x20C6 801 | #define WGL_VIDEO_OUT_COLOR_AND_DEPTH_NV 0x20C7 802 | #define WGL_VIDEO_OUT_FRAME 0x20C8 803 | #define WGL_VIDEO_OUT_FIELD_1 0x20C9 804 | #define WGL_VIDEO_OUT_FIELD_2 0x20CA 805 | #define WGL_VIDEO_OUT_STACKED_FIELDS_1_2 0x20CB 806 | #define WGL_VIDEO_OUT_STACKED_FIELDS_2_1 0x20CC 807 | typedef BOOL (WINAPI * PFNWGLGETVIDEODEVICENVPROC) (HDC hDC, int numDevices, HPVIDEODEV *hVideoDevice); 808 | typedef BOOL (WINAPI * PFNWGLRELEASEVIDEODEVICENVPROC) (HPVIDEODEV hVideoDevice); 809 | typedef BOOL (WINAPI * PFNWGLBINDVIDEOIMAGENVPROC) (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer); 810 | typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOIMAGENVPROC) (HPBUFFERARB hPbuffer, int iVideoBuffer); 811 | typedef BOOL (WINAPI * PFNWGLSENDPBUFFERTOVIDEONVPROC) (HPBUFFERARB hPbuffer, int iBufferType, unsigned long *pulCounterPbuffer, BOOL bBlock); 812 | typedef BOOL (WINAPI * PFNWGLGETVIDEOINFONVPROC) (HPVIDEODEV hpVideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo); 813 | #ifdef WGL_WGLEXT_PROTOTYPES 814 | BOOL WINAPI wglGetVideoDeviceNV (HDC hDC, int numDevices, HPVIDEODEV *hVideoDevice); 815 | BOOL WINAPI wglReleaseVideoDeviceNV (HPVIDEODEV hVideoDevice); 816 | BOOL WINAPI wglBindVideoImageNV (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer); 817 | BOOL WINAPI wglReleaseVideoImageNV (HPBUFFERARB hPbuffer, int iVideoBuffer); 818 | BOOL WINAPI wglSendPbufferToVideoNV (HPBUFFERARB hPbuffer, int iBufferType, unsigned long *pulCounterPbuffer, BOOL bBlock); 819 | BOOL WINAPI wglGetVideoInfoNV (HPVIDEODEV hpVideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo); 820 | #endif 821 | #endif /* WGL_NV_video_output */ 822 | 823 | #ifndef WGL_OML_sync_control 824 | #define WGL_OML_sync_control 1 825 | typedef BOOL (WINAPI * PFNWGLGETSYNCVALUESOMLPROC) (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc); 826 | typedef BOOL (WINAPI * PFNWGLGETMSCRATEOMLPROC) (HDC hdc, INT32 *numerator, INT32 *denominator); 827 | typedef INT64 (WINAPI * PFNWGLSWAPBUFFERSMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder); 828 | typedef INT64 (WINAPI * PFNWGLSWAPLAYERBUFFERSMSCOMLPROC) (HDC hdc, INT fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder); 829 | typedef BOOL (WINAPI * PFNWGLWAITFORMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc); 830 | typedef BOOL (WINAPI * PFNWGLWAITFORSBCOMLPROC) (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc); 831 | #ifdef WGL_WGLEXT_PROTOTYPES 832 | BOOL WINAPI wglGetSyncValuesOML (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc); 833 | BOOL WINAPI wglGetMscRateOML (HDC hdc, INT32 *numerator, INT32 *denominator); 834 | INT64 WINAPI wglSwapBuffersMscOML (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder); 835 | INT64 WINAPI wglSwapLayerBuffersMscOML (HDC hdc, INT fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder); 836 | BOOL WINAPI wglWaitForMscOML (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc); 837 | BOOL WINAPI wglWaitForSbcOML (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc); 838 | #endif 839 | #endif /* WGL_OML_sync_control */ 840 | 841 | #ifdef __cplusplus 842 | } 843 | #endif 844 | 845 | #endif 846 | -------------------------------------------------------------------------------- /examples/win32/win32-example.c: -------------------------------------------------------------------------------- 1 | /********************************************************************************* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2020 Tarek Sherif 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | * this software and associated documentation files (the "Software"), to deal in 8 | * the Software without restriction, including without limitation the rights to 9 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | * the Software, and to permit persons to whom the Software is furnished to do so, 11 | * subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | **********************************************************************************/ 23 | 24 | ////////////////////////////////////////////////////// 25 | // Example of basic usage of Simple OpenGL 26 | // Loader with Win32 using SOGL_IMPLEMENTATION_WIN32 27 | ////////////////////////////////////////////////////// 28 | 29 | #define WIN32_LEAN_AND_MEAN 30 | #define SOGL_MAJOR_VERSION 4 31 | #define SOGL_MINOR_VERSION 5 32 | #define SOGL_IMPLEMENTATION_WIN32 33 | #include "../../simple-opengl-loader.h" 34 | #include 35 | #include 36 | #include "wglext.h" 37 | #include 38 | #include 39 | 40 | ///////////////////////////////////// 41 | // WGL loading helper functions 42 | ///////////////////////////////////// 43 | 44 | #define DECLARE_WGL_EXT_FUNC(returnType, name, ...) typedef returnType (WINAPI *name##FUNC)(__VA_ARGS__);\ 45 | name##FUNC name = (name##FUNC)0; 46 | #define LOAD_WGL_EXT_FUNC(name) name = (name##FUNC) wglGetProcAddress(#name) 47 | 48 | ///////////////////////////////////// 49 | // Set up OpenGL function pointers 50 | ///////////////////////////////////// 51 | 52 | DECLARE_WGL_EXT_FUNC(BOOL, wglChoosePixelFormatARB, HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); 53 | DECLARE_WGL_EXT_FUNC(HGLRC, wglCreateContextAttribsARB, HDC hDC, HGLRC hshareContext, const int *attribList); 54 | 55 | //////////////// 56 | // WIN32 setup 57 | //////////////// 58 | 59 | const WCHAR WIN_CLASS_NAME[] = L"OPENGL_WINDOW_CLASS"; 60 | 61 | LRESULT CALLBACK winProc(HWND window, UINT message, WPARAM wParam, LPARAM lParam) { 62 | switch (message) { 63 | case WM_SIZING: { 64 | if (glViewport) { 65 | RECT* bounds = (RECT *) lParam; 66 | UINT width = bounds->right - bounds->left; 67 | UINT height = bounds->bottom - bounds->top; 68 | glViewport(0, 0, width, height); 69 | } 70 | return 0; 71 | } break; 72 | case WM_PAINT: { 73 | if (glClear) { 74 | HDC deviceContext = GetDC(window); 75 | glClear(GL_COLOR_BUFFER_BIT); 76 | glDrawArrays(GL_TRIANGLES, 0, 3); 77 | SwapBuffers(deviceContext); 78 | } 79 | } break; 80 | case WM_CLOSE: { 81 | PostQuitMessage(0); 82 | return 0; 83 | } break; 84 | } 85 | 86 | return DefWindowProc(window, message, wParam, lParam); 87 | } 88 | 89 | int CALLBACK WinMain(HINSTANCE instance, HINSTANCE prevInstance, LPSTR cmdLine, int showWindow) { 90 | WNDCLASSEX winClass = {0}; 91 | winClass.cbSize = sizeof(winClass); 92 | winClass.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; 93 | winClass.lpfnWndProc = winProc; 94 | winClass.hInstance = instance; 95 | winClass.hIcon = LoadIcon(instance, IDI_APPLICATION); 96 | winClass.hIconSm = LoadIcon(instance, IDI_APPLICATION); 97 | winClass.hCursor = LoadCursor(NULL, IDC_ARROW); 98 | winClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); 99 | winClass.lpszClassName = WIN_CLASS_NAME; 100 | 101 | if (!RegisterClassEx(&winClass)) { 102 | MessageBox(NULL, L"Failed to register window class!", L"FAILURE", MB_OK); 103 | 104 | return 1; 105 | } 106 | 107 | //////////////////////////////////////////////////////////////////// 108 | // Create a dummy window so we can get WGL extension functions 109 | //////////////////////////////////////////////////////////////////// 110 | 111 | HWND dummyWindow = CreateWindow(WIN_CLASS_NAME, L"DUMMY", WS_OVERLAPPEDWINDOW, 0, 0, 1, 1, NULL, NULL, instance, NULL); 112 | 113 | if (!dummyWindow) { 114 | MessageBox(NULL, L"Failed to create window!", L"FAILURE", MB_OK); 115 | 116 | return 1; 117 | } 118 | 119 | HDC dummyContext = GetDC(dummyWindow); 120 | 121 | PIXELFORMATDESCRIPTOR pfd = {0}; 122 | pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR); 123 | pfd.nVersion = 1; 124 | pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, 125 | pfd.iPixelType = PFD_TYPE_RGBA, 126 | pfd.cColorBits = 32; 127 | pfd.cDepthBits = 24; 128 | pfd.cStencilBits = 8; 129 | pfd.iLayerType = PFD_MAIN_PLANE; 130 | 131 | int pixelFormat = ChoosePixelFormat(dummyContext, &pfd); 132 | SetPixelFormat(dummyContext, pixelFormat, &pfd); 133 | HGLRC dummyGL = wglCreateContext(dummyContext); 134 | wglMakeCurrent(dummyContext, dummyGL); 135 | 136 | LOAD_WGL_EXT_FUNC(wglChoosePixelFormatARB); 137 | LOAD_WGL_EXT_FUNC(wglCreateContextAttribsARB); 138 | 139 | if (!wglCreateContextAttribsARB || !wglCreateContextAttribsARB) { 140 | MessageBox(NULL, L"Didn't get wgl ARB functions!", L"FAILURE", MB_OK); 141 | return 1; 142 | } 143 | 144 | wglMakeCurrent(NULL, NULL); 145 | wglDeleteContext(dummyGL); 146 | DestroyWindow(dummyWindow); 147 | 148 | ///////////////////////////////////////////// 149 | // Create real window and rendering context 150 | ///////////////////////////////////////////// 151 | 152 | HWND window = CreateWindow( 153 | WIN_CLASS_NAME, 154 | L"Simple OpenGL Loader Win32 Example", 155 | WS_OVERLAPPEDWINDOW, 156 | CW_USEDEFAULT, CW_USEDEFAULT, 157 | 800, 800, 158 | NULL, 159 | NULL, 160 | instance, 161 | NULL 162 | ); 163 | 164 | if (!window) { 165 | MessageBox(NULL, L"Failed to create window!", L"FAILURE", MB_OK); 166 | 167 | return 1; 168 | } 169 | 170 | HDC deviceContext = GetDC(window); 171 | 172 | const int pixelAttribList[] = { 173 | WGL_DRAW_TO_WINDOW_ARB, GL_TRUE, 174 | WGL_SUPPORT_OPENGL_ARB, GL_TRUE, 175 | WGL_DOUBLE_BUFFER_ARB, GL_TRUE, 176 | WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB, 177 | WGL_COLOR_BITS_ARB, 32, 178 | WGL_DEPTH_BITS_ARB, 24, 179 | WGL_STENCIL_BITS_ARB, 8, 180 | WGL_ACCELERATION_ARB, WGL_FULL_ACCELERATION_ARB, 181 | WGL_SAMPLE_BUFFERS_ARB, GL_TRUE, 182 | WGL_SAMPLES_ARB, 4, 183 | 0 184 | }; 185 | 186 | UINT numFormats; 187 | BOOL success; 188 | success = wglChoosePixelFormatARB(deviceContext, pixelAttribList, NULL, 1, &pixelFormat, &numFormats); 189 | 190 | if (!success || numFormats == 0) { 191 | MessageBox(NULL, L"Didn't get ARB pixel format!", L"FAILURE", MB_OK); 192 | return 1; 193 | } 194 | 195 | DescribePixelFormat(deviceContext, pixelFormat, sizeof(pfd), &pfd); 196 | SetPixelFormat(deviceContext, pixelFormat, &pfd); 197 | 198 | const int contextAttribList[] = { 199 | WGL_CONTEXT_MAJOR_VERSION_ARB, 4, 200 | WGL_CONTEXT_MINOR_VERSION_ARB, 5, 201 | WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB, 202 | 0 203 | }; 204 | 205 | HGLRC gl = wglCreateContextAttribsARB(deviceContext, NULL, contextAttribList); 206 | 207 | if (!gl) { 208 | MessageBox(NULL, L"Didn't get ARB GL context!", L"FAILURE", MB_OK); 209 | return 1; 210 | } 211 | 212 | wglMakeCurrent(deviceContext, gl); 213 | 214 | if (!sogl_loadOpenGL()) { 215 | const char **failures = sogl_getFailures(); 216 | while (*failures) { 217 | char debugMessage[256]; 218 | snprintf(debugMessage, 256, "SOGL WIN32 EXAMPLE: Failed to load function %s\n", *failures); 219 | OutputDebugStringA(debugMessage); 220 | failures++; 221 | } 222 | } 223 | 224 | /////////////////////////// 225 | // Set up GL resources 226 | /////////////////////////// 227 | 228 | glClearColor(0.0f, 0.0f, 0.0f, 1.0f); 229 | 230 | const char* vsSource = "#version 450\n" 231 | "layout (location=0) in vec4 position;\n" 232 | "layout (location=1) in vec3 color;\n" 233 | "out vec3 vColor;\n" 234 | "void main() {\n" 235 | " vColor = color;\n" 236 | " gl_Position = position;\n" 237 | "}\n"; 238 | 239 | const char* fsSource = "#version 450\n" 240 | "in vec3 vColor;\n" 241 | "out vec4 fragColor;\n" 242 | "void main() {\n" 243 | " fragColor = vec4(vColor, 1.0);\n" 244 | "}\n"; 245 | 246 | GLuint vertexShader = glCreateShader(GL_VERTEX_SHADER); 247 | glShaderSource(vertexShader, 1, &vsSource, NULL); 248 | glCompileShader(vertexShader); 249 | 250 | GLuint fragmentShader = glCreateShader(GL_FRAGMENT_SHADER); 251 | glShaderSource(fragmentShader, 1, &fsSource, NULL); 252 | glCompileShader(fragmentShader); 253 | 254 | GLuint program = glCreateProgram(); 255 | glAttachShader(program, vertexShader); 256 | glAttachShader(program, fragmentShader); 257 | glLinkProgram(program); 258 | 259 | GLint result; 260 | glGetProgramiv(program, GL_LINK_STATUS, &result); 261 | 262 | if (result != GL_TRUE) { 263 | MessageBox(NULL, L"Program failed to link!", L"FAILURE", MB_OK); 264 | } 265 | 266 | glUseProgram(program); 267 | 268 | GLuint triangleArray; 269 | glGenVertexArrays(1, &triangleArray); 270 | glBindVertexArray(triangleArray); 271 | 272 | float positions[] = { 273 | -0.5, -0.5, 274 | 0.5, -0.5, 275 | 0.0, 0.5 276 | }; 277 | 278 | GLuint positionBuffer; 279 | glGenBuffers(1, &positionBuffer); 280 | glBindBuffer(GL_ARRAY_BUFFER, positionBuffer); 281 | glBufferData(GL_ARRAY_BUFFER, sizeof(positions), positions, GL_STATIC_DRAW); 282 | glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, NULL); 283 | glEnableVertexAttribArray(0); 284 | 285 | uint8_t colors[] = { 286 | 255, 0, 0, 287 | 0, 255, 0, 288 | 0, 0, 255 289 | }; 290 | 291 | GLuint colorBuffer; 292 | glGenBuffers(1, &colorBuffer); 293 | glBindBuffer(GL_ARRAY_BUFFER, colorBuffer); 294 | glBufferData(GL_ARRAY_BUFFER, sizeof(colors), colors, GL_STATIC_DRAW); 295 | glVertexAttribPointer(1, 3, GL_UNSIGNED_BYTE, GL_TRUE, 0, NULL); 296 | glEnableVertexAttribArray(1); 297 | 298 | /////////////////// 299 | // Display window 300 | /////////////////// 301 | 302 | ShowWindow(window, showWindow); 303 | 304 | ////////////////////////////////// 305 | // Start render and message loop 306 | ////////////////////////////////// 307 | 308 | MSG message; 309 | while (GetMessage(&message, NULL, 0, 0) > 0) { 310 | TranslateMessage(&message); 311 | DispatchMessage(&message); 312 | 313 | glClear(GL_COLOR_BUFFER_BIT); 314 | glDrawArrays(GL_TRIANGLES, 0, 3); 315 | SwapBuffers(deviceContext); 316 | } 317 | 318 | return (int) message.wParam; 319 | } 320 | -------------------------------------------------------------------------------- /examples/x11-custom-implementation/Makefile: -------------------------------------------------------------------------------- 1 | CFLAGS=-g -Wall -Werror -std=c++11 -DSOGL_MAJOR_VERSION=4 -DSOGL_MINOR_VERSION=5 2 | CC=g++ 3 | LDLIBS=-lX11 -ldl -lGL 4 | 5 | all: 6 | $(CC) $(CFLAGS) -o x11-custom-implementation x11-custom-implementation.cc $(LDLIBS) 7 | -------------------------------------------------------------------------------- /examples/x11-custom-implementation/x11-custom-implementation.cc: -------------------------------------------------------------------------------- 1 | /********************************************************************************* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2020 Tarek Sherif 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | * this software and associated documentation files (the "Software"), to deal in 8 | * the Software without restriction, including without limitation the rights to 9 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | * the Software, and to permit persons to whom the Software is furnished to do so, 11 | * subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | **********************************************************************************/ 23 | ////////////////////////////////////////////////////// 24 | // Example of basic C++ usage of Simple OpenGL 25 | // Loader with a custom X11 implementation and 26 | // constants defined at the command line. 27 | ////////////////////////////////////////////////////// 28 | 29 | #define SOGL_IMPLEMENTATION 30 | #include "../../simple-opengl-loader.h" 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | static void* openGLLibHandle = NULL; 38 | 39 | void *sogl_loadOpenGLFunction(const char *name) { 40 | if (!openGLLibHandle) { 41 | openGLLibHandle = dlopen("libGL.so.1", RTLD_LAZY | RTLD_LOCAL); 42 | if (!openGLLibHandle) { 43 | openGLLibHandle = dlopen("libGL.so", RTLD_LAZY | RTLD_LOCAL); 44 | } 45 | } 46 | 47 | void *fn = dlsym(openGLLibHandle, name); 48 | 49 | return fn; 50 | } 51 | 52 | void sogl_cleanup() { 53 | if (openGLLibHandle) { 54 | dlclose(openGLLibHandle); 55 | openGLLibHandle = NULL; 56 | } 57 | } 58 | 59 | typedef GLXContext (*glXCreateContextAttribsARBFUNC)(Display*, GLXFBConfig, GLXContext, Bool, const int*); 60 | 61 | int main(int argc, char const *argv[]) { 62 | Display* display; 63 | Window window; 64 | XEvent event; 65 | XWindowAttributes xWinAtt; 66 | 67 | // X Windows stuff 68 | display = XOpenDisplay(NULL); 69 | 70 | if (display == NULL) { 71 | printf("Unable to connect to X Server\n"); 72 | return 1; 73 | } 74 | 75 | window = XCreateSimpleWindow(display, DefaultRootWindow(display), 20, 20, 800, 800, 0, 0, 0); 76 | 77 | 78 | XSelectInput(display, window, ExposureMask | KeyPressMask | ButtonPressMask); 79 | XStoreName(display, window, "Simple OpenGL Loader X11 C++ Custom Implementation Example"); 80 | XMapWindow(display, window); 81 | 82 | int numFBC = 0; 83 | GLint visualAtt[] = { 84 | GLX_RENDER_TYPE, GLX_RGBA_BIT, 85 | GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT, 86 | GLX_DOUBLEBUFFER, True, 87 | GLX_RED_SIZE, 1, 88 | GLX_GREEN_SIZE, 1, 89 | GLX_BLUE_SIZE, 1, 90 | GLX_DEPTH_SIZE, 1, 91 | GLX_STENCIL_SIZE, 1, 92 | None 93 | }; 94 | 95 | GLXFBConfig *fbc = glXChooseFBConfig(display, DefaultScreen(display), visualAtt, &numFBC); 96 | 97 | if (!fbc) { 98 | fprintf(stderr, "Unable to get framebuffer\n"); 99 | return -1; 100 | } 101 | 102 | glXCreateContextAttribsARBFUNC glXCreateContextAttribsARB = (glXCreateContextAttribsARBFUNC) glXGetProcAddress((const GLubyte *) "glXCreateContextAttribsARB"); 103 | 104 | if (!glXCreateContextAttribsARB) { 105 | fprintf(stderr, "Unable to get proc glXCreateContextAttribsARB\n"); 106 | XFree(fbc); 107 | return -1; 108 | } 109 | 110 | static int contextAttribs[] = { 111 | GLX_CONTEXT_MAJOR_VERSION_ARB, 4, 112 | GLX_CONTEXT_MINOR_VERSION_ARB, 5, 113 | GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_CORE_PROFILE_BIT_ARB, 114 | None 115 | }; 116 | 117 | GLXContext ctx = glXCreateContextAttribsARB(display, *fbc, NULL, True, contextAttribs); 118 | 119 | XFree(fbc); 120 | 121 | if (!ctx) { 122 | fprintf(stderr, "Unable to create OpenGL context\n"); 123 | return -1; 124 | } 125 | 126 | glXMakeCurrent(display, window, ctx); 127 | 128 | if (!sogl_loadOpenGL()) { 129 | const char **failures = sogl_getFailures(); 130 | while (*failures) { 131 | fprintf(stderr, "SOGL X11 EXAMPLE: Failed to load function %s\n", *failures); 132 | failures++; 133 | } 134 | } 135 | 136 | glClearColor(0.0, 0.0, 0.0, 1.0); 137 | 138 | GLuint vertexArray = 0; 139 | glGenVertexArrays(1, &vertexArray); 140 | glBindVertexArray(vertexArray); 141 | 142 | GLfloat positionData[] = { 143 | -0.5, -0.5, 144 | 0.5, -0.5, 145 | 0.0, 0.5 146 | }; 147 | 148 | GLuint positions = 0; 149 | glGenBuffers(1, &positions); 150 | glBindBuffer(GL_ARRAY_BUFFER, positions); 151 | glBufferData(GL_ARRAY_BUFFER, 3 * 2 * sizeof(GLfloat), positionData, GL_STATIC_DRAW); 152 | glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, NULL); 153 | glEnableVertexAttribArray(0); 154 | 155 | GLubyte colorData[] = { 156 | 255, 0, 0, 157 | 0, 255, 0, 158 | 0, 0, 255 159 | }; 160 | 161 | GLuint colors = 0; 162 | glGenBuffers(1, &colors); 163 | glBindBuffer(GL_ARRAY_BUFFER, colors); 164 | glBufferData(GL_ARRAY_BUFFER, 3 * 3 * sizeof(GLubyte), colorData, GL_STATIC_DRAW); 165 | glVertexAttribPointer(1, 3, GL_UNSIGNED_BYTE, GL_TRUE, 0, NULL); 166 | glEnableVertexAttribArray(1); 167 | 168 | const char* vsSource = R"GLSL(#version 450 169 | layout (location=0) in vec4 position; 170 | layout (location=1) in vec3 color; 171 | out vec3 vColor; 172 | void main() { 173 | vColor = color; 174 | gl_Position = position; 175 | }; 176 | )GLSL"; 177 | 178 | const char* fsSource = R"GLSL(#version 450 179 | in vec3 vColor; 180 | out vec4 fragColor; 181 | void main() { 182 | fragColor = vec4(vColor, 1.0); 183 | } 184 | )GLSL"; 185 | 186 | GLuint vs = glCreateShader(GL_VERTEX_SHADER); 187 | glShaderSource(vs, 1, &vsSource, NULL); 188 | glCompileShader(vs); 189 | 190 | GLuint fs = glCreateShader(GL_FRAGMENT_SHADER); 191 | glShaderSource(fs, 1, &fsSource, NULL); 192 | glCompileShader(fs); 193 | 194 | GLuint program = glCreateProgram(); 195 | glAttachShader(program, vs); 196 | glAttachShader(program, fs); 197 | glLinkProgram(program); 198 | 199 | int params = -1; 200 | glGetProgramiv(program, GL_LINK_STATUS, ¶ms); 201 | 202 | if (params != GL_TRUE) { 203 | fprintf(stderr, "Program did not link!\n"); 204 | } 205 | 206 | glUseProgram(program); 207 | 208 | Atom wmDeleteMessage = XInternAtom(display, "WM_DELETE_WINDOW", False); 209 | XSetWMProtocols(display, window, &wmDeleteMessage, 1); 210 | 211 | // Animation loop 212 | while (1) { 213 | if (XCheckTypedWindowEvent(display, window, Expose, &event) == True) { 214 | XGetWindowAttributes(display, window, &xWinAtt); 215 | glViewport(0, 0, xWinAtt.width, xWinAtt.height); 216 | } 217 | 218 | if (XCheckTypedWindowEvent(display, window, ClientMessage, &event) == True) { 219 | if (event.xclient.data.l[0] == (long) wmDeleteMessage) { 220 | break; 221 | } 222 | } 223 | 224 | glClear(GL_COLOR_BUFFER_BIT); 225 | glDrawArrays(GL_TRIANGLES, 0, 3); 226 | 227 | glXSwapBuffers(display, window); 228 | }; 229 | 230 | // Teardown 231 | XDestroyWindow(display, window); 232 | XCloseDisplay(display); 233 | } 234 | -------------------------------------------------------------------------------- /examples/x11/Makefile: -------------------------------------------------------------------------------- 1 | CFLAGS=-g -Wall -Werror 2 | CC=gcc 3 | LDLIBS=-lX11 -ldl -lGL 4 | 5 | all: 6 | $(CC) $(CFLAGS) -o x11-example x11-example.c $(LDLIBS) 7 | -------------------------------------------------------------------------------- /examples/x11/x11-example.c: -------------------------------------------------------------------------------- 1 | /********************************************************************************* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2020 Tarek Sherif 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | * this software and associated documentation files (the "Software"), to deal in 8 | * the Software without restriction, including without limitation the rights to 9 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | * the Software, and to permit persons to whom the Software is furnished to do so, 11 | * subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | **********************************************************************************/ 23 | 24 | ////////////////////////////////////////////////////// 25 | // Example of basic usage of Simple OpenGL 26 | // Loader with X11 using SOGL_IMPLEMENTATION_X11 27 | ////////////////////////////////////////////////////// 28 | 29 | #define SOGL_MAJOR_VERSION 4 30 | #define SOGL_MINOR_VERSION 5 31 | #define SOGL_IMPLEMENTATION_X11 32 | #include "../../simple-opengl-loader.h" 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | typedef GLXContext (*glXCreateContextAttribsARBFUNC)(Display*, GLXFBConfig, GLXContext, Bool, const int*); 39 | 40 | int main(int argc, char const *argv[]) { 41 | Display* display; 42 | Window window; 43 | XEvent event; 44 | XWindowAttributes xWinAtt; 45 | 46 | // X Windows stuff 47 | display = XOpenDisplay(NULL); 48 | 49 | if (display == NULL) { 50 | printf("Unable to connect to X Server\n"); 51 | return 1; 52 | } 53 | 54 | window = XCreateSimpleWindow(display, DefaultRootWindow(display), 20, 20, 800, 800, 0, 0, 0); 55 | 56 | 57 | XSelectInput(display, window, ExposureMask | KeyPressMask | ButtonPressMask); 58 | XStoreName(display, window, "Simple OpenGL Loader X11 Example"); 59 | XMapWindow(display, window); 60 | 61 | int numFBC = 0; 62 | GLint visualAtt[] = { 63 | GLX_RENDER_TYPE, GLX_RGBA_BIT, 64 | GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT, 65 | GLX_DOUBLEBUFFER, True, 66 | GLX_RED_SIZE, 1, 67 | GLX_GREEN_SIZE, 1, 68 | GLX_BLUE_SIZE, 1, 69 | GLX_DEPTH_SIZE, 1, 70 | GLX_STENCIL_SIZE, 1, 71 | None 72 | }; 73 | 74 | GLXFBConfig *fbc = glXChooseFBConfig(display, DefaultScreen(display), visualAtt, &numFBC); 75 | 76 | if (!fbc) { 77 | fprintf(stderr, "Unable to get framebuffer\n"); 78 | return -1; 79 | } 80 | 81 | glXCreateContextAttribsARBFUNC glXCreateContextAttribsARB = (glXCreateContextAttribsARBFUNC) glXGetProcAddress((const GLubyte *) "glXCreateContextAttribsARB"); 82 | 83 | if (!glXCreateContextAttribsARB) { 84 | fprintf(stderr, "Unable to get proc glXCreateContextAttribsARB\n"); 85 | XFree(fbc); 86 | return -1; 87 | } 88 | 89 | static int contextAttribs[] = { 90 | GLX_CONTEXT_MAJOR_VERSION_ARB, 4, 91 | GLX_CONTEXT_MINOR_VERSION_ARB, 5, 92 | GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_CORE_PROFILE_BIT_ARB, 93 | None 94 | }; 95 | 96 | GLXContext ctx = glXCreateContextAttribsARB(display, *fbc, NULL, True, contextAttribs); 97 | 98 | XFree(fbc); 99 | 100 | if (!ctx) { 101 | fprintf(stderr, "Unable to create OpenGL context\n"); 102 | return -1; 103 | } 104 | 105 | glXMakeCurrent(display, window, ctx); 106 | 107 | if (!sogl_loadOpenGL()) { 108 | const char **failures = sogl_getFailures(); 109 | while (*failures) { 110 | fprintf(stderr, "SOGL X11 EXAMPLE: Failed to load function %s\n", *failures); 111 | failures++; 112 | } 113 | } 114 | 115 | glClearColor(0.0, 0.0, 0.0, 1.0); 116 | 117 | GLuint vertexArray = 0; 118 | glGenVertexArrays(1, &vertexArray); 119 | glBindVertexArray(vertexArray); 120 | 121 | GLfloat positionData[] = { 122 | -0.5, -0.5, 123 | 0.5, -0.5, 124 | 0.0, 0.5 125 | }; 126 | 127 | GLuint positions = 0; 128 | glGenBuffers(1, &positions); 129 | glBindBuffer(GL_ARRAY_BUFFER, positions); 130 | glBufferData(GL_ARRAY_BUFFER, 3 * 2 * sizeof(GLfloat), positionData, GL_STATIC_DRAW); 131 | glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, NULL); 132 | glEnableVertexAttribArray(0); 133 | 134 | GLubyte colorData[] = { 135 | 255, 0, 0, 136 | 0, 255, 0, 137 | 0, 0, 255 138 | }; 139 | 140 | GLuint colors = 0; 141 | glGenBuffers(1, &colors); 142 | glBindBuffer(GL_ARRAY_BUFFER, colors); 143 | glBufferData(GL_ARRAY_BUFFER, 3 * 3 * sizeof(GLubyte), colorData, GL_STATIC_DRAW); 144 | glVertexAttribPointer(1, 3, GL_UNSIGNED_BYTE, GL_TRUE, 0, NULL); 145 | glEnableVertexAttribArray(1); 146 | 147 | const char* vsSource = 148 | "#version 450\n" 149 | "layout(location=0) in vec4 position;\n" 150 | "layout(location=1) in vec3 color;\n" 151 | "out vec3 vColor;\n" 152 | "void main() {\n" 153 | " vColor = color;\n" 154 | " gl_Position = position;\n" 155 | "}\n"; 156 | 157 | const char* fsSource = 158 | "#version 450\n" 159 | "in vec3 vColor;\n" 160 | "out vec4 fragColor;\n" 161 | "void main() {\n" 162 | " fragColor = vec4(vColor, 1.0);\n" 163 | "}\n"; 164 | 165 | GLuint vs = glCreateShader(GL_VERTEX_SHADER); 166 | glShaderSource(vs, 1, &vsSource, NULL); 167 | glCompileShader(vs); 168 | 169 | GLuint fs = glCreateShader(GL_FRAGMENT_SHADER); 170 | glShaderSource(fs, 1, &fsSource, NULL); 171 | glCompileShader(fs); 172 | 173 | GLuint program = glCreateProgram(); 174 | glAttachShader(program, vs); 175 | glAttachShader(program, fs); 176 | glLinkProgram(program); 177 | 178 | int params = -1; 179 | glGetProgramiv(program, GL_LINK_STATUS, ¶ms); 180 | 181 | if (params != GL_TRUE) { 182 | fprintf(stderr, "Program did not link!\n"); 183 | } 184 | 185 | glUseProgram(program); 186 | 187 | Atom wmDeleteMessage = XInternAtom(display, "WM_DELETE_WINDOW", False); 188 | XSetWMProtocols(display, window, &wmDeleteMessage, 1); 189 | 190 | // Animation loop 191 | while (1) { 192 | if (XCheckTypedWindowEvent(display, window, Expose, &event) == True) { 193 | XGetWindowAttributes(display, window, &xWinAtt); 194 | glViewport(0, 0, xWinAtt.width, xWinAtt.height); 195 | } 196 | 197 | if (XCheckTypedWindowEvent(display, window, ClientMessage, &event) == True) { 198 | if (event.xclient.data.l[0] == wmDeleteMessage) { 199 | break; 200 | } 201 | } 202 | 203 | glClear(GL_COLOR_BUFFER_BIT); 204 | glDrawArrays(GL_TRIANGLES, 0, 3); 205 | 206 | glXSwapBuffers(display, window); 207 | }; 208 | 209 | // Teardown 210 | XDestroyWindow(display, window); 211 | XCloseDisplay(display); 212 | } 213 | --------------------------------------------------------------------------------