1 2 // Copyright 2018 - 2021 Michael D. Parker 3 // Distributed under the Boost Software License, Version 1.0. 4 // (See accompanying file LICENSE_1_0.txt or copy at 5 // http://www.boost.org/LICENSE_1_0.txt) 6 7 module bindbc.opengl.bind.arb.core_33; 8 9 import bindbc.loader; 10 import bindbc.opengl.config, 11 bindbc.opengl.context; 12 import bindbc.opengl.bind.types; 13 14 static if(glSupport >= GLSupport.gl33) { 15 enum has33 = true; 16 } 17 else enum has33 = false; 18 19 // ARB_occlusion_query2 20 version(GL_ARB) enum useARBOcclusionQuery2 = true; 21 else version(GL_ARB_occlusion_query2) enum useARBOcclusionQuery2 = true; 22 else enum useARBOcclusionQuery2 = has33; 23 24 static if(useARBOcclusionQuery2) { 25 private bool _hasARBOcclusionQuery2; 26 @nogc nothrow bool hasARBOcclusionQuery2() { return _hasARBOcclusionQuery2; } 27 28 enum uint GL_ANY_SAMPLES_PASSED = 0x8C2F; 29 } 30 else enum hasARBOcclusionQuery2 = false; 31 32 // ARB_texture_rgb10_a2ui 33 version(GL_ARB) enum useARBTextureRGB10A2UI = true; 34 else version(GL_ARB_timer_query) enum useARBTextureRGB10A2UI = true; 35 else enum useARBTextureRGB10A2UI = has33; 36 37 static if(useARBTextureRGB10A2UI) { 38 enum uint GL_RGB10_A2UI = 0x906F; 39 private bool _hasARBTextureRGB10A2UI; 40 @nogc nothrow bool hasARBTextureRGB10A2UI() { return _hasARBTextureRGB10A2UI; } 41 } 42 43 // ARB_texture_swizzle 44 version(GL_ARB) enum useARBTextureSwizzle = true; 45 else version(GL_ARB_texture_swizzle) enum useARBTextureSwizzle = true; 46 else enum useARBTextureSwizzle = has33; 47 48 static if(useARBTextureSwizzle) { 49 private bool _hasARBTextureSwizzle; 50 @nogc nothrow bool hasARBTextureSwizzle() { return _hasARBTextureSwizzle; } 51 52 enum : uint { 53 GL_TEXTURE_SWIZZLE_R = 0x8E42, 54 GL_TEXTURE_SWIZZLE_G = 0x8E43, 55 GL_TEXTURE_SWIZZLE_B = 0x8E44, 56 GL_TEXTURE_SWIZZLE_A = 0x8E45, 57 GL_TEXTURE_SWIZZLE_RGBA = 0x8E46, 58 } 59 } 60 else enum hasARBTextureSwizzle = false; 61 62 // ARB_blend_func_extended 63 version(GL_ARB) enum useARBBlendFuncExtended = true; 64 else version(GL_ARB_blend_func_extended) enum useARBBlendFuncExtended = true; 65 else enum useARBBlendFuncExtended = has33; 66 67 static if(useARBBlendFuncExtended) { 68 private bool _hasARBBlendFuncExtended; 69 @nogc nothrow bool hasARBBlendFuncExtended() { return _hasARBBlendFuncExtended; } 70 71 enum : uint { 72 GL_SRC1_COLOR = 0x88F9, 73 GL_ONE_MINUS_SRC1_COLOR = 0x88FA, 74 GL_ONE_MINUS_SRC1_ALPHA = 0x88FB, 75 GL_MAX_DUAL_SOURCE_DRAW_BUFFERS = 0x88FC, 76 } 77 78 extern(System) @nogc nothrow { 79 alias pglBindFragDataLocationIndexed = void function(GLuint, GLuint, GLuint, const(GLchar)*); 80 alias pglGetFragDataIndex = GLint function(GLuint, const(GLchar)*); 81 } 82 83 __gshared { 84 pglBindFragDataLocationIndexed glBindFragDataLocationIndexed; 85 pglGetFragDataIndex glGetFragDataIndex; 86 } 87 88 private @nogc nothrow 89 bool loadARBBlendFuncExtended(SharedLib lib, GLSupport contextVersion) 90 { 91 lib.bindGLSymbol(cast(void**)&glBindFragDataLocationIndexed, "glBindFragDataLocationIndexed"); 92 lib.bindGLSymbol(cast(void**)&glGetFragDataIndex, "glGetFragDataIndex"); 93 return resetErrorCountGL(); 94 } 95 } 96 else enum hasARBBlendFuncExtended = false; 97 98 // ARB_sampler_objects 99 version(GL_ARB) enum useARBSamplerObjects = true; 100 else version(GL_ARB_sampler_objects) enum useARBSamplerObjects = true; 101 else enum useARBSamplerObjects = has33; 102 103 static if(useARBSamplerObjects) { 104 private bool _hasARBSamplerObjects; 105 @nogc nothrow bool hasARBSamplerObjects() { return _hasARBSamplerObjects; } 106 107 enum uint GL_SAMPLER_BINDING = 0x8919; 108 109 extern(System) @nogc nothrow { 110 alias pglGenSamplers = void function(GLsizei, GLuint*); 111 alias pglDeleteSamplers = void function(GLsizei, const(GLuint)*); 112 alias pglIsSampler = GLboolean function(GLuint); 113 alias pglBindSampler = void function(GLuint, GLuint); 114 alias pglSamplerParameteri = void function(GLuint, GLenum, GLint); 115 alias pglSamplerParameteriv = void function(GLuint, GLenum, const(GLint)*); 116 alias pglSamplerParameterf = void function(GLuint, GLenum, GLfloat); 117 alias pglSamplerParameterfv = void function(GLuint, GLenum, const(GLfloat)*); 118 alias pglSamplerParameterIiv = void function(GLuint, GLenum, const(GLint)*); 119 alias pglSamplerParameterIuiv = void function(GLuint, GLenum, const(GLuint)*); 120 alias pglGetSamplerParameteriv = void function(GLuint, GLenum, GLint*); 121 alias pglGetSamplerParameterIiv = void function(GLuint, GLenum, GLint*); 122 alias pglGetSamplerParameterfv = void function(GLuint, GLenum, GLfloat*); 123 alias pglGetSamplerParameterIuiv = void function(GLuint, GLenum, GLuint*); 124 } 125 126 __gshared { 127 pglGenSamplers glGenSamplers; 128 pglDeleteSamplers glDeleteSamplers; 129 pglIsSampler glIsSampler; 130 pglBindSampler glBindSampler; 131 pglSamplerParameteri glSamplerParameteri; 132 pglSamplerParameteriv glSamplerParameteriv; 133 pglSamplerParameterf glSamplerParameterf; 134 pglSamplerParameterfv glSamplerParameterfv; 135 pglSamplerParameterIiv glSamplerParameterIiv; 136 pglSamplerParameterIuiv glSamplerParameterIuiv; 137 pglGetSamplerParameteriv glGetSamplerParameteriv; 138 pglGetSamplerParameterIiv glGetSamplerParameterIiv; 139 pglGetSamplerParameterfv glGetSamplerParameterfv; 140 pglGetSamplerParameterIuiv glGetSamplerParameterIuiv; 141 } 142 143 private @nogc nothrow 144 bool loadARBSamplerObjects(SharedLib lib, GLSupport contextVersion) 145 { 146 lib.bindGLSymbol(cast(void**)&glGenSamplers, "glGenSamplers"); 147 lib.bindGLSymbol(cast(void**)&glDeleteSamplers, "glDeleteSamplers"); 148 lib.bindGLSymbol(cast(void**)&glIsSampler, "glIsSampler"); 149 lib.bindGLSymbol(cast(void**)&glBindSampler, "glBindSampler"); 150 lib.bindGLSymbol(cast(void**)&glSamplerParameteri, "glSamplerParameteri"); 151 lib.bindGLSymbol(cast(void**)&glSamplerParameteriv, "glSamplerParameteriv"); 152 lib.bindGLSymbol(cast(void**)&glSamplerParameterf, "glSamplerParameterf"); 153 lib.bindGLSymbol(cast(void**)&glSamplerParameterfv, "glSamplerParameterfv"); 154 lib.bindGLSymbol(cast(void**)&glSamplerParameterIiv, "glSamplerParameterIiv"); 155 lib.bindGLSymbol(cast(void**)&glSamplerParameterIuiv, "glSamplerParameterIuiv"); 156 lib.bindGLSymbol(cast(void**)&glGetSamplerParameteriv, "glGetSamplerParameteriv"); 157 lib.bindGLSymbol(cast(void**)&glGetSamplerParameterIiv, "glGetSamplerParameterIiv"); 158 lib.bindGLSymbol(cast(void**)&glGetSamplerParameterfv, "glGetSamplerParameterfv"); 159 lib.bindGLSymbol(cast(void**)&glGetSamplerParameterIuiv, "glGetSamplerParameterIuiv"); 160 return resetErrorCountGL(); 161 } 162 } 163 else enum hasARBSamplerObjects = false; 164 165 // ARB_timer_query 166 version(GL_ARB) enum useARBTimerQuery = true; 167 else version(GL_ARB_timer_query) enum useARBTimerQuery = true; 168 else enum useARBTimerQuery = has33; 169 170 static if(useARBTimerQuery) { 171 private bool _hasARBTimerQuery; 172 @nogc nothrow bool hasARBTimerQuery() { return _hasARBTimerQuery; } 173 174 enum : uint { 175 GL_TIME_ELAPSED = 0x88BF, 176 GL_TIMESTAMP = 0x8E28, 177 } 178 179 extern(System) @nogc nothrow { 180 alias pglQueryCounter = void function(GLuint, GLenum); 181 alias pglGetQueryObjecti64v = void function(GLuint, GLenum, GLint64*); 182 alias pglGetQueryObjectui64v = void function(GLuint, GLenum, GLuint64*); 183 } 184 185 __gshared { 186 pglQueryCounter glQueryCounter; 187 pglGetQueryObjecti64v glGetQueryObjecti64v; 188 pglGetQueryObjectui64v glGetQueryObjectui64v; 189 } 190 191 private @nogc nothrow 192 bool loadARBTimerQuery(SharedLib lib, GLSupport contextVersion) 193 { 194 lib.bindGLSymbol(cast(void**)&glQueryCounter, "glQueryCounter"); 195 lib.bindGLSymbol(cast(void**)&glGetQueryObjecti64v, "glGetQueryObjecti64v"); 196 lib.bindGLSymbol(cast(void**)&glGetQueryObjectui64v, "glGetQueryObjectui64v"); 197 return resetErrorCountGL(); 198 } 199 } 200 else enum hasARBTimerQuery = false; 201 202 // ARB_vertex_type_2_10_10_10_rev 203 version(GL_ARB) enum useARBVertexType2101010Rev = true; 204 else version(GL_ARB_vertex_type_2_10_10_10_rev) enum useARBVertexType2101010Rev = true; 205 else enum useARBVertexType2101010Rev = has33; 206 207 static if(useARBVertexType2101010Rev) { 208 private bool _hasARBVertexType2101010Rev; 209 @nogc nothrow bool hasARBVertexType2101010Rev() { return _hasARBVertexType2101010Rev; } 210 211 enum uint GL_INT_2_10_10_10_REV = 0x8D9F; 212 213 extern(System) @nogc nothrow { 214 // A note in derelict says these aren't actually part of the core and doesn't 215 // load them on Mac. Don't remember why I wrote that, so I need to dig into it. 216 /* 217 alias pglVertexP2ui = void function(GLenum, GLuint); 218 alias pglVertexP2uiv = void function(GLenum, const(GLuint)*); 219 alias pglVertexP3ui = void function(GLenum, GLuint); 220 alias pglVertexP3uiv = void function(GLenum, const(GLuint)*); 221 alias pglVertexP4ui = void function(GLenum, GLuint); 222 alias pglVertexP4uiv = void function(GLenum, const(GLuint)*); 223 alias pglTexCoordP1ui = void function(GLenum, GLuint); 224 alias pglTexCoordP1uiv = void function(GLenum, const(GLuint)*); 225 alias pglTexCoordP2ui = void function(GLenum, GLuint); 226 alias pglTexCoordP2uiv = void function(GLenum, const(GLuint)*); 227 alias pglTexCoordP3ui = void function(GLenum, GLuint); 228 alias pglTexCoordP3uiv = void function(GLenum, const(GLuint)*); 229 alias pglTexCoordP4ui = void function(GLenum, GLuint); 230 alias pglTexCoordP4uiv = void function(GLenum, const(GLuint)*); 231 alias pglMultiTexCoordP1ui = void function(GLenum, GLenum, GLuint); 232 alias pglMultiTexCoordP1uiv = void function(GLenum, GLenum, const(GLuint)*); 233 alias pglMultiTexCoordP2ui = void function(GLenum, GLenum, GLuint); 234 alias pglMultiTexCoordP2uiv = void function(GLenum, GLenum, const(GLuint)*); 235 alias pglMultiTexCoordP3ui = void function(GLenum, GLenum, GLuint); 236 alias pglMultiTexCoordP3uiv = void function(GLenum, GLenum, const(GLuint)*); 237 alias pglMultiTexCoordP4ui = void function(GLenum, GLenum, GLuint); 238 alias pglMultiTexCoordP4uiv = void function(GLenum, GLenum, const(GLuint)*); 239 alias pglNormalP3ui = void function(GLenum, GLuint); 240 alias pglNormalP3uiv = void function(GLenum, const(GLuint)*); 241 alias pglColorP3ui = void function(GLenum, GLuint); 242 alias pglColorP3uiv = void function(GLenum, const(GLuint)*); 243 alias pglColorP4ui = void function(GLenum, GLuint); 244 alias pglColorP4uiv = void function(GLenum, const(GLuint)*); 245 alias pglSecondaryColorP3ui = void function(GLenum, GLuint); 246 alias pglSecondaryColorP3uiv = void function(GLenum, const(GLuint)*); 247 */ 248 alias pglVertexAttribP1ui = void function(GLuint, GLenum, GLboolean, GLuint); 249 alias pglVertexAttribP1uiv = void function(GLuint, GLenum, GLboolean, const(GLuint)*); 250 alias pglVertexAttribP2ui = void function(GLuint, GLenum, GLboolean, GLuint); 251 alias pglVertexAttribP2uiv = void function(GLuint, GLenum, GLboolean, const(GLuint)*); 252 alias pglVertexAttribP3ui = void function(GLuint, GLenum, GLboolean, GLuint); 253 alias pglVertexAttribP3uiv = void function(GLuint, GLenum, GLboolean, const(GLuint)*); 254 alias pglVertexAttribP4ui = void function(GLuint, GLenum, GLboolean, GLuint); 255 alias pglVertexAttribP4uiv = void function(GLuint, GLenum, GLboolean, const(GLuint)*); 256 } 257 258 __gshared { 259 /* 260 pglVertexP2ui glVertexP2ui; 261 pglVertexP2uiv glVertexP2uiv; 262 pglVertexP3ui glVertexP3ui; 263 pglVertexP3uiv glVertexP3uiv; 264 pglVertexP4ui glVertexP4ui; 265 pglVertexP4uiv glVertexP4uiv; 266 pglTexCoordP1ui glTexCoordP1ui; 267 pglTexCoordP1uiv glTexCoordP1uiv; 268 pglTexCoordP2ui glTexCoordP2ui; 269 pglTexCoordP2uiv glTexCoordP2uiv; 270 pglTexCoordP3ui glTexCoordP3ui; 271 pglTexCoordP3uiv glTexCoordP3uiv; 272 pglTexCoordP4ui glTexCoordP4ui; 273 pglTexCoordP4uiv glTexCoordP4uiv; 274 pglMultiTexCoordP1ui glMultiTexCoordP1ui; 275 pglMultiTexCoordP1uiv glMultiTexCoordP1uiv; 276 pglMultiTexCoordP2ui glMultiTexCoordP2ui; 277 pglMultiTexCoordP2uiv glMultiTexCoordP2uiv; 278 pglMultiTexCoordP3ui glMultiTexCoordP3ui; 279 pglMultiTexCoordP3uiv glMultiTexCoordP3uiv; 280 pglMultiTexCoordP4ui glMultiTexCoordP4ui; 281 pglMultiTexCoordP4uiv glMultiTexCoordP4uiv; 282 pglNormalP3ui glNormalP3ui; 283 pglNormalP3uiv glNormalP3uiv; 284 pglColorP3ui glColorP3ui; 285 pglColorP3uiv glColorP3uiv; 286 pglColorP4ui glColorP4ui; 287 pglColorP4uiv glColorP4uiv; 288 pglSecondaryColorP3ui glSecondaryColorP3ui; 289 pglSecondaryColorP3uiv glSecondaryColorP3uiv; 290 */ 291 pglVertexAttribP1ui glVertexAttribP1ui; 292 pglVertexAttribP1uiv glVertexAttribP1uiv; 293 pglVertexAttribP2ui glVertexAttribP2ui; 294 pglVertexAttribP2uiv glVertexAttribP2uiv; 295 pglVertexAttribP3ui glVertexAttribP3ui; 296 pglVertexAttribP3uiv glVertexAttribP3uiv; 297 pglVertexAttribP4ui glVertexAttribP4ui; 298 pglVertexAttribP4uiv glVertexAttribP4uiv; 299 } 300 301 private @nogc nothrow 302 bool loadARBVertexType2101010Rev(SharedLib lib, GLSupport contextVersion) 303 { 304 lib.bindGLSymbol(cast(void**)&glVertexAttribP1ui, "glVertexAttribP1ui"); 305 lib.bindGLSymbol(cast(void**)&glVertexAttribP1uiv, "glVertexAttribP1uiv"); 306 lib.bindGLSymbol(cast(void**)&glVertexAttribP2ui, "glVertexAttribP2ui"); 307 lib.bindGLSymbol(cast(void**)&glVertexAttribP2uiv, "glVertexAttribP2uiv"); 308 lib.bindGLSymbol(cast(void**)&glVertexAttribP3ui, "glVertexAttribP3ui"); 309 lib.bindGLSymbol(cast(void**)&glVertexAttribP3uiv, "glVertexAttribP3uiv"); 310 lib.bindGLSymbol(cast(void**)&glVertexAttribP4ui, "glVertexAttribP4ui"); 311 lib.bindGLSymbol(cast(void**)&glVertexAttribP4uiv, "glVertexAttribP4uiv"); 312 return resetErrorCountGL(); 313 } 314 } 315 else enum hasARBVertexType2101010Rev = false; 316 317 package(bindbc.opengl) @nogc nothrow 318 bool loadARB33(SharedLib lib, GLSupport contextVersion) 319 { 320 static if(has33) { 321 if(contextVersion >= GLSupport.gl33) { 322 _hasARBOcclusionQuery2 = true; 323 _hasARBTextureRGB10A2UI = true; 324 _hasARBTextureSwizzle = true; 325 326 bool ret = true; 327 ret = _hasARBBlendFuncExtended = lib.loadARBBlendFuncExtended(contextVersion); 328 ret = _hasARBSamplerObjects = lib.loadARBSamplerObjects(contextVersion); 329 ret = _hasARBTimerQuery = lib.loadARBTimerQuery(contextVersion); 330 ret = _hasARBVertexType2101010Rev = lib.loadARBVertexType2101010Rev(contextVersion); 331 return ret; 332 } 333 } 334 335 static if(useARBOcclusionQuery2) _hasARBOcclusionQuery2 = 336 hasExtension(contextVersion, "GL_ARB_occlusion_query2"); 337 338 static if(useARBTextureRGB10A2UI) _hasARBTextureRGB10A2UI = 339 hasExtension(contextVersion, "GL_ARB_texture_rgb10_a2ui"); 340 341 static if(useARBTextureSwizzle) _hasARBTextureSwizzle = 342 hasExtension(contextVersion, "GL_ARB_texture_swizzle"); 343 344 static if(useARBBlendFuncExtended) _hasARBBlendFuncExtended = 345 hasExtension(contextVersion, "GL_ARB_blend_func_extended") && 346 lib.loadARBBlendFuncExtended(contextVersion); 347 348 static if(useARBSamplerObjects) _hasARBSamplerObjects = 349 hasExtension(contextVersion, "GL_ARB_sampler_objects") && 350 lib.loadARBSamplerObjects(contextVersion); 351 352 static if(useARBTimerQuery) _hasARBTimerQuery = 353 hasExtension(contextVersion, "GL_ARB_timer_query") && 354 lib.loadARBTimerQuery(contextVersion); 355 356 static if(useARBVertexType2101010Rev) _hasARBVertexType2101010Rev = 357 hasExtension(contextVersion, "GL_ARB_vertex_type_2_10_10_10_rev") && 358 lib.loadARBVertexType2101010Rev(contextVersion); 359 360 return true; 361 }