0032465: Visualization, TKOpenGles - invalid enum on GL_RGBA16F initialization in...
[occt.git] / src / OpenGl / OpenGl_GlFunctions.cxx
CommitLineData
e44b849d 1// Copyright (c) 2021 OPEN CASCADE SAS
2//
3// This file is part of Open CASCADE Technology software library.
4//
5// This library is free software; you can redistribute it and/or modify it under
6// the terms of the GNU Lesser General Public License version 2.1 as published
7// by the Free Software Foundation, with special exception defined in the file
8// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9// distribution for complete text of the license and disclaimer of any warranty.
10//
11// Alternatively, this file may be used under the terms of Open CASCADE
12// commercial license or contractual agreement.
13
14#if defined(_WIN32)
15 #include <windows.h>
16#endif
17
18#include <OpenGl_Context.hxx>
19
20#include <OpenGl_ArbTBO.hxx>
21#include <OpenGl_ArbIns.hxx>
22#include <OpenGl_ArbDbg.hxx>
23#include <OpenGl_ArbFBO.hxx>
24#include <OpenGl_ExtGS.hxx>
25#include <OpenGl_ArbSamplerObject.hxx>
26#include <OpenGl_ArbTexBindless.hxx>
952a0565 27#include <OpenGl_GlCore46.hxx>
e44b849d 28
b69e576a 29#if !defined(HAVE_EGL) && defined(HAVE_XLIB)
30 #include <GL/glx.h>
31#endif
32
e44b849d 33// =======================================================================
34// function : init
35// purpose :
36// =======================================================================
37void OpenGl_GlFunctions::load (OpenGl_Context& theCtx,
38 Standard_Boolean theIsCoreProfile)
39{
92996979 40#if defined(GL_ES_VERSION_2_0)
41 (void )theIsCoreProfile;
43eddb47 42 theCtx.core11ffp = NULL;
92996979 43#else
43eddb47 44 theCtx.core11ffp = !theIsCoreProfile ? (OpenGl_GlCore11* )this : NULL;
92996979 45#endif
e44b849d 46 theCtx.core11fwd = (OpenGl_GlCore11Fwd* )this;
47 theCtx.core15 = NULL;
48 theCtx.core15fwd = NULL;
49 theCtx.core20 = NULL;
50 theCtx.core20fwd = NULL;
51 theCtx.core30 = NULL;
e44b849d 52 theCtx.core32 = NULL;
e44b849d 53 theCtx.core33 = NULL;
e44b849d 54 theCtx.core41 = NULL;
e44b849d 55 theCtx.core42 = NULL;
e44b849d 56 theCtx.core43 = NULL;
e44b849d 57 theCtx.core44 = NULL;
e44b849d 58 theCtx.core45 = NULL;
952a0565 59 theCtx.core46 = NULL;
e44b849d 60 theCtx.arbTBO = NULL;
61 theCtx.arbTboRGB32 = false;
e70625d6 62 theCtx.arbClipControl = false;
e44b849d 63 theCtx.arbIns = NULL;
64 theCtx.arbDbg = NULL;
65 theCtx.arbFBO = NULL;
66 theCtx.arbFBOBlit = NULL;
67 theCtx.extGS = NULL;
68
69 //! Make record shorter to retrieve function pointer using variable with same name
70 const char* aLastFailedProc = NULL;
71 #define FindProcShort(theFunc) theCtx.FindProcVerbose(aLastFailedProc, #theFunc, this->theFunc)
72 #define checkExtensionShort theCtx.CheckExtension
73 #define isGlGreaterEqualShort(theMaj,theMin) theCtx.IsGlGreaterEqual(theMaj,theMin)
74
75#if defined(GL_ES_VERSION_2_0)
76
77 theCtx.hasTexRGBA8 = isGlGreaterEqualShort (3, 0)
78 || checkExtensionShort ("GL_OES_rgb8_rgba8");
79 theCtx.hasTexSRGB = isGlGreaterEqualShort (3, 0);
80 theCtx.hasFboSRGB = isGlGreaterEqualShort (3, 0);
81 theCtx.hasFboRenderMipmap = isGlGreaterEqualShort (3, 0)
82 || checkExtensionShort ("GL_OES_fbo_render_mipmap");
83 theCtx.hasSRGBControl = checkExtensionShort ("GL_EXT_sRGB_write_control");
84 theCtx.hasPackRowLength = isGlGreaterEqualShort (3, 0);
85 theCtx.hasUnpackRowLength = isGlGreaterEqualShort (3, 0); // || checkExtensionShort ("GL_EXT_unpack_subimage");
86 // NPOT textures has limited support within OpenGL ES 2.0
87 // which are relaxed by OpenGL ES 3.0 or some extensions
88 //theCtx.arbNPTW = isGlGreaterEqualShort (3, 0)
89 // || checkExtensionShort ("GL_OES_texture_npot")
90 // || checkExtensionShort ("GL_NV_texture_npot_2D_mipmap");
91 theCtx.arbNPTW = true;
92 theCtx.arbTexRG = isGlGreaterEqualShort (3, 0)
93 || checkExtensionShort ("GL_EXT_texture_rg");
94 theCtx.extBgra = checkExtensionShort ("GL_EXT_texture_format_BGRA8888");
95 theCtx.extAnis = checkExtensionShort ("GL_EXT_texture_filter_anisotropic");
96 theCtx.extPDS = isGlGreaterEqualShort (3, 0)
97 || checkExtensionShort ("GL_OES_packed_depth_stencil");
98
99 theCtx.core11fwd = (OpenGl_GlCore11Fwd* )this;
100 if (isGlGreaterEqualShort (2, 0))
101 {
102 // enable compatible functions
43eddb47 103 theCtx.core20 = (OpenGl_GlCore20* )this;
104 theCtx.core20fwd = (OpenGl_GlCore20* )this;
105 theCtx.core15 = (OpenGl_GlCore15* )this;
106 theCtx.core15fwd = (OpenGl_GlCore15* )this;
107 theCtx.arbFBO = (OpenGl_ArbFBO* )this;
e44b849d 108 }
109 if (isGlGreaterEqualShort (3, 0)
110 && FindProcShort (glBlitFramebuffer))
111 {
112 theCtx.arbFBOBlit = (OpenGl_ArbFBOBlit* )this;
113 }
114 if (isGlGreaterEqualShort (3, 0)
115 && FindProcShort (glGenSamplers)
116 && FindProcShort (glDeleteSamplers)
117 && FindProcShort (glIsSampler)
118 && FindProcShort (glBindSampler)
119 && FindProcShort (glSamplerParameteri)
120 && FindProcShort (glSamplerParameteriv)
121 && FindProcShort (glSamplerParameterf)
122 && FindProcShort (glSamplerParameterfv)
123 && FindProcShort (glGetSamplerParameteriv)
124 && FindProcShort (glGetSamplerParameterfv))
125 //&& FindProcShort (glSamplerParameterIiv) // only on Desktop or with extensions GL_OES_texture_border_clamp/GL_EXT_texture_border_clamp
126 //&& FindProcShort (glSamplerParameterIuiv)
127 //&& FindProcShort (glGetSamplerParameterIiv)
128 //&& FindProcShort (glGetSamplerParameterIuiv))
129 {
130 theCtx.arbSamplerObject = (OpenGl_ArbSamplerObject* )this;
131 }
132 theCtx.extFragDepth = !isGlGreaterEqualShort(3, 0)
133 && checkExtensionShort ("GL_EXT_frag_depth");
134 if (isGlGreaterEqualShort (3, 1)
135 && FindProcShort (glTexStorage2DMultisample))
136 {
137 //
138 }
139
140 theCtx.hasUintIndex = isGlGreaterEqualShort (3, 0)
141 || checkExtensionShort ("GL_OES_element_index_uint");
142 theCtx.hasHighp = checkExtensionShort ("GL_OES_fragment_precision_high");
143 GLint aRange[2] = {0, 0};
144 GLint aPrec = 0;
145 ::glGetShaderPrecisionFormat (GL_FRAGMENT_SHADER, GL_HIGH_FLOAT, aRange, &aPrec);
146 if (aPrec != 0)
147 {
148 theCtx.hasHighp = Standard_True;
149 }
150
151 theCtx.arbTexFloat = (isGlGreaterEqualShort (3, 0)
152 && FindProcShort (glTexImage3D))
153 || checkExtensionShort ("GL_OES_texture_float");
154 theCtx.hasTexFloatLinear = theCtx.arbTexFloat
155 && checkExtensionShort ("GL_OES_texture_float_linear");
156
157 const bool hasTexBuffer32 = isGlGreaterEqualShort (3, 2) && FindProcShort (glTexBuffer);
158 const bool hasExtTexBuffer = checkExtensionShort ("GL_EXT_texture_buffer") && theCtx.FindProc ("glTexBufferEXT", this->glTexBuffer);
159 if (hasTexBuffer32 || hasExtTexBuffer)
160 {
161 theCtx.arbTBO = reinterpret_cast<OpenGl_ArbTBO*> (this);
162 }
163
164 bool hasInstanced = isGlGreaterEqualShort (3, 0)
165 && FindProcShort (glVertexAttribDivisor)
166 && FindProcShort (glDrawArraysInstanced)
167 && FindProcShort (glDrawElementsInstanced);
168 if (!hasInstanced)
169 {
170 hasInstanced = checkExtensionShort ("GL_ANGLE_instanced_arrays")
171 && theCtx.FindProc ("glVertexAttribDivisorANGLE", this->glVertexAttribDivisor)
172 && theCtx.FindProc ("glDrawArraysInstancedANGLE", this->glDrawArraysInstanced)
173 && theCtx.FindProc ("glDrawElementsInstancedANGLE", this->glDrawElementsInstanced);
174 }
175 if (hasInstanced)
176 {
177 theCtx.arbIns = (OpenGl_ArbIns* )this;
178 }
179
180 const bool hasVAO = isGlGreaterEqualShort (3, 0)
181 && FindProcShort (glBindVertexArray)
182 && FindProcShort (glDeleteVertexArrays)
183 && FindProcShort (glGenVertexArrays)
184 && FindProcShort (glIsVertexArray);
185#ifndef __EMSCRIPTEN__ // latest Emscripten does not pretend having / simulating mapping buffer functions
186 const bool hasMapBufferRange = isGlGreaterEqualShort (3, 0)
187 && FindProcShort (glMapBufferRange)
188 && FindProcShort (glUnmapBuffer)
189 && FindProcShort (glGetBufferPointerv)
190 && FindProcShort (glFlushMappedBufferRange);
191#endif
192
193 // load OpenGL ES 3.0 new functions
194 const bool has30es = isGlGreaterEqualShort (3, 0)
195 && hasVAO
196 #ifndef __EMSCRIPTEN__
197 && hasMapBufferRange
198 #endif
199 && hasInstanced
200 && theCtx.arbSamplerObject != NULL
201 && theCtx.arbFBOBlit != NULL
202 && FindProcShort (glReadBuffer)
203 && FindProcShort (glDrawRangeElements)
204 && FindProcShort (glTexImage3D)
205 && FindProcShort (glTexSubImage3D)
206 && FindProcShort (glCopyTexSubImage3D)
207 && FindProcShort (glCompressedTexImage3D)
208 && FindProcShort (glCompressedTexSubImage3D)
209 && FindProcShort (glGenQueries)
210 && FindProcShort (glDeleteQueries)
211 && FindProcShort (glIsQuery)
212 && FindProcShort (glBeginQuery)
213 && FindProcShort (glEndQuery)
214 && FindProcShort (glGetQueryiv)
215 && FindProcShort (glGetQueryObjectuiv)
216 && FindProcShort (glDrawBuffers)
217 && FindProcShort (glUniformMatrix2x3fv)
218 && FindProcShort (glUniformMatrix3x2fv)
219 && FindProcShort (glUniformMatrix2x4fv)
220 && FindProcShort (glUniformMatrix4x2fv)
221 && FindProcShort (glUniformMatrix3x4fv)
222 && FindProcShort (glUniformMatrix4x3fv)
223 && FindProcShort (glRenderbufferStorageMultisample)
224 && FindProcShort (glFramebufferTextureLayer)
225 && FindProcShort (glGetIntegeri_v)
226 && FindProcShort (glBeginTransformFeedback)
227 && FindProcShort (glEndTransformFeedback)
228 && FindProcShort (glBindBufferRange)
229 && FindProcShort (glBindBufferBase)
230 && FindProcShort (glTransformFeedbackVaryings)
231 && FindProcShort (glGetTransformFeedbackVarying)
232 && FindProcShort (glVertexAttribIPointer)
233 && FindProcShort (glGetVertexAttribIiv)
234 && FindProcShort (glGetVertexAttribIuiv)
235 && FindProcShort (glVertexAttribI4i)
236 && FindProcShort (glVertexAttribI4ui)
237 && FindProcShort (glVertexAttribI4iv)
238 && FindProcShort (glVertexAttribI4uiv)
239 && FindProcShort (glGetUniformuiv)
240 && FindProcShort (glGetFragDataLocation)
241 && FindProcShort (glUniform1ui)
242 && FindProcShort (glUniform2ui)
243 && FindProcShort (glUniform3ui)
244 && FindProcShort (glUniform4ui)
245 && FindProcShort (glUniform1uiv)
246 && FindProcShort (glUniform2uiv)
247 && FindProcShort (glUniform3uiv)
248 && FindProcShort (glUniform4uiv)
249 && FindProcShort (glClearBufferiv)
250 && FindProcShort (glClearBufferuiv)
251 && FindProcShort (glClearBufferfv)
252 && FindProcShort (glClearBufferfi)
253 && FindProcShort (glGetStringi)
254 && FindProcShort (glCopyBufferSubData)
255 && FindProcShort (glGetUniformIndices)
256 && FindProcShort (glGetActiveUniformsiv)
257 && FindProcShort (glGetUniformBlockIndex)
258 && FindProcShort (glGetActiveUniformBlockiv)
259 && FindProcShort (glGetActiveUniformBlockName)
260 && FindProcShort (glUniformBlockBinding)
261 && FindProcShort (glFenceSync)
262 && FindProcShort (glIsSync)
263 && FindProcShort (glDeleteSync)
264 && FindProcShort (glClientWaitSync)
265 && FindProcShort (glWaitSync)
266 && FindProcShort (glGetInteger64v)
267 && FindProcShort (glGetSynciv)
268 && FindProcShort (glGetInteger64i_v)
269 && FindProcShort (glGetBufferParameteri64v)
270 && FindProcShort (glBindTransformFeedback)
271 && FindProcShort (glDeleteTransformFeedbacks)
272 && FindProcShort (glGenTransformFeedbacks)
273 && FindProcShort (glIsTransformFeedback)
274 && FindProcShort (glPauseTransformFeedback)
275 && FindProcShort (glResumeTransformFeedback)
276 && FindProcShort (glGetProgramBinary)
277 && FindProcShort (glProgramBinary)
278 && FindProcShort (glProgramParameteri)
279 && FindProcShort (glInvalidateFramebuffer)
280 && FindProcShort (glInvalidateSubFramebuffer)
281 && FindProcShort (glTexStorage2D)
282 && FindProcShort (glTexStorage3D)
283 && FindProcShort (glGetInternalformativ);
284 if (!has30es)
285 {
286 theCtx.checkWrongVersion (3, 0, aLastFailedProc);
287 }
288 else
289 {
43eddb47 290 theCtx.core30 = (OpenGl_GlCore30* )this;
e44b849d 291 theCtx.hasGetBufferData = true;
292 }
293
294 // load OpenGL ES 3.1 new functions
295 const bool has31es = isGlGreaterEqualShort (3, 1)
296 && has30es
297 && FindProcShort (glDispatchCompute)
298 && FindProcShort (glDispatchComputeIndirect)
299 && FindProcShort (glDrawArraysIndirect)
300 && FindProcShort (glDrawElementsIndirect)
301 && FindProcShort (glFramebufferParameteri)
302 && FindProcShort (glGetFramebufferParameteriv)
303 && FindProcShort (glGetProgramInterfaceiv)
304 && FindProcShort (glGetProgramResourceIndex)
305 && FindProcShort (glGetProgramResourceName)
306 && FindProcShort (glGetProgramResourceiv)
307 && FindProcShort (glGetProgramResourceLocation)
308 && FindProcShort (glUseProgramStages)
309 && FindProcShort (glActiveShaderProgram)
310 && FindProcShort (glCreateShaderProgramv)
311 && FindProcShort (glBindProgramPipeline)
312 && FindProcShort (glDeleteProgramPipelines)
313 && FindProcShort (glGenProgramPipelines)
314 && FindProcShort (glIsProgramPipeline)
315 && FindProcShort (glGetProgramPipelineiv)
316 && FindProcShort (glProgramUniform1i)
317 && FindProcShort (glProgramUniform2i)
318 && FindProcShort (glProgramUniform3i)
319 && FindProcShort (glProgramUniform4i)
320 && FindProcShort (glProgramUniform1ui)
321 && FindProcShort (glProgramUniform2ui)
322 && FindProcShort (glProgramUniform3ui)
323 && FindProcShort (glProgramUniform4ui)
324 && FindProcShort (glProgramUniform1f)
325 && FindProcShort (glProgramUniform2f)
326 && FindProcShort (glProgramUniform3f)
327 && FindProcShort (glProgramUniform4f)
328 && FindProcShort (glProgramUniform1iv)
329 && FindProcShort (glProgramUniform2iv)
330 && FindProcShort (glProgramUniform3iv)
331 && FindProcShort (glProgramUniform4iv)
332 && FindProcShort (glProgramUniform1uiv)
333 && FindProcShort (glProgramUniform2uiv)
334 && FindProcShort (glProgramUniform3uiv)
335 && FindProcShort (glProgramUniform4uiv)
336 && FindProcShort (glProgramUniform1fv)
337 && FindProcShort (glProgramUniform2fv)
338 && FindProcShort (glProgramUniform3fv)
339 && FindProcShort (glProgramUniform4fv)
340 && FindProcShort (glProgramUniformMatrix2fv)
341 && FindProcShort (glProgramUniformMatrix3fv)
342 && FindProcShort (glProgramUniformMatrix4fv)
343 && FindProcShort (glProgramUniformMatrix2x3fv)
344 && FindProcShort (glProgramUniformMatrix3x2fv)
345 && FindProcShort (glProgramUniformMatrix2x4fv)
346 && FindProcShort (glProgramUniformMatrix4x2fv)
347 && FindProcShort (glProgramUniformMatrix3x4fv)
348 && FindProcShort (glProgramUniformMatrix4x3fv)
349 && FindProcShort (glValidateProgramPipeline)
350 && FindProcShort (glGetProgramPipelineInfoLog)
351 && FindProcShort (glBindImageTexture)
352 && FindProcShort (glGetBooleani_v)
353 && FindProcShort (glMemoryBarrier)
354 && FindProcShort (glMemoryBarrierByRegion)
355 && FindProcShort (glTexStorage2DMultisample)
356 && FindProcShort (glGetMultisamplefv)
357 && FindProcShort (glSampleMaski)
358 && FindProcShort (glGetTexLevelParameteriv)
359 && FindProcShort (glGetTexLevelParameterfv)
360 && FindProcShort (glBindVertexBuffer)
361 && FindProcShort (glVertexAttribFormat)
362 && FindProcShort (glVertexAttribIFormat)
363 && FindProcShort (glVertexAttribBinding)
364 && FindProcShort (glVertexBindingDivisor);
365 if (!has31es)
366 {
367 theCtx.checkWrongVersion (3, 1, aLastFailedProc);
368 }
369
370 // initialize debug context extension
371 if (isGlGreaterEqualShort (3, 2)
372 || checkExtensionShort ("GL_KHR_debug"))
373 {
374 // this functionality become a part of OpenGL ES 3.2
375 theCtx.arbDbg = NULL;
376 if (isGlGreaterEqualShort (3, 2)
377 && FindProcShort (glDebugMessageControl)
378 && FindProcShort (glDebugMessageInsert)
379 && FindProcShort (glDebugMessageCallback)
380 && FindProcShort (glGetDebugMessageLog))
381 {
382 theCtx.arbDbg = (OpenGl_ArbDbg* )this;
383 }
384 // According to GL_KHR_debug spec, all functions should have KHR suffix.
385 // However, some implementations can export these functions without suffix.
386 else if (!isGlGreaterEqualShort (3, 2)
387 && theCtx.FindProc ("glDebugMessageControlKHR", this->glDebugMessageControl)
388 && theCtx.FindProc ("glDebugMessageInsertKHR", this->glDebugMessageInsert)
389 && theCtx.FindProc ("glDebugMessageCallbackKHR", this->glDebugMessageCallback)
390 && theCtx.FindProc ("glGetDebugMessageLogKHR", this->glGetDebugMessageLog))
391 {
392 theCtx.arbDbg = (OpenGl_ArbDbg* )this;
393 }
394 }
395
396 // load OpenGL ES 3.2 new functions
397 const bool has32es = isGlGreaterEqualShort (3, 2)
398 && has31es
399 && hasTexBuffer32
400 && theCtx.arbDbg != NULL
401 && FindProcShort (glBlendBarrier)
402 && FindProcShort (glCopyImageSubData)
403 && FindProcShort (glPushDebugGroup)
404 && FindProcShort (glPopDebugGroup)
405 && FindProcShort (glObjectLabel)
406 && FindProcShort (glGetObjectLabel)
407 && FindProcShort (glObjectPtrLabel)
408 && FindProcShort (glGetObjectPtrLabel)
409 && FindProcShort (glGetPointerv)
410 && FindProcShort (glEnablei)
411 && FindProcShort (glDisablei)
412 && FindProcShort (glBlendEquationi)
413 && FindProcShort (glBlendEquationSeparatei)
414 && FindProcShort (glBlendFunci)
415 && FindProcShort (glBlendFuncSeparatei)
416 && FindProcShort (glColorMaski)
417 && FindProcShort (glIsEnabledi)
418 && FindProcShort (glDrawElementsBaseVertex)
419 && FindProcShort (glDrawRangeElementsBaseVertex)
420 && FindProcShort (glDrawElementsInstancedBaseVertex)
421 && FindProcShort (glFramebufferTexture)
422 && FindProcShort (glPrimitiveBoundingBox)
423 && FindProcShort (glGetGraphicsResetStatus)
424 && FindProcShort (glReadnPixels)
425 && FindProcShort (glGetnUniformfv)
426 && FindProcShort (glGetnUniformiv)
427 && FindProcShort (glGetnUniformuiv)
428 && FindProcShort (glMinSampleShading)
429 && FindProcShort (glPatchParameteri)
430 && FindProcShort (glTexParameterIiv)
431 && FindProcShort (glTexParameterIuiv)
432 && FindProcShort (glGetTexParameterIiv)
433 && FindProcShort (glGetTexParameterIuiv)
434 && FindProcShort (glSamplerParameterIiv)
435 && FindProcShort (glSamplerParameterIuiv)
436 && FindProcShort (glGetSamplerParameterIiv)
437 && FindProcShort (glGetSamplerParameterIuiv)
438 && FindProcShort (glTexBufferRange)
439 && FindProcShort (glTexStorage3DMultisample);
440 if (!has32es)
441 {
442 theCtx.checkWrongVersion (3, 2, aLastFailedProc);
443 }
444
93cdaa76 445 theCtx.arbTboRGB32 = isGlGreaterEqualShort (3, 2); // OpenGL ES 3.2 introduces TBO already supporting RGB32 format
e44b849d 446 theCtx.extDrawBuffers = checkExtensionShort ("GL_EXT_draw_buffers") && theCtx.FindProc ("glDrawBuffersEXT", this->glDrawBuffers);
447 theCtx.arbDrawBuffers = checkExtensionShort ("GL_ARB_draw_buffers") && theCtx.FindProc ("glDrawBuffersARB", this->glDrawBuffers);
448
449 if (isGlGreaterEqualShort (3, 0) && FindProcShort (glDrawBuffers))
450 {
451 theCtx.hasDrawBuffers = OpenGl_FeatureInCore;
452 }
453 else if (theCtx.extDrawBuffers || theCtx.arbDrawBuffers)
454 {
455 theCtx.hasDrawBuffers = OpenGl_FeatureInExtensions;
456 }
457
0770d850 458 // float textures available since OpenGL ES 3.0+,
459 // but renderable only since 3.2+ or with extension
460 theCtx.hasFloatBuffer = theCtx.hasHalfFloatBuffer = OpenGl_FeatureNotAvailable;
461 if (isGlGreaterEqualShort (3, 2))
462 {
463 theCtx.hasFloatBuffer = theCtx.hasHalfFloatBuffer = OpenGl_FeatureInCore;
464 }
465 else
466 {
467 if (checkExtensionShort ("GL_EXT_color_buffer_float"))
468 {
469 theCtx.hasFloatBuffer = isGlGreaterEqualShort (3, 0) ? OpenGl_FeatureInCore : OpenGl_FeatureInExtensions;
470 }
471 if (checkExtensionShort ("GL_EXT_color_buffer_half_float"))
472 {
473 // GL_HALF_FLOAT_OES for OpenGL ES 2.0 and GL_HALF_FLOAT for OpenGL ES 3.0+
474 theCtx.hasHalfFloatBuffer = isGlGreaterEqualShort (3, 0) ? OpenGl_FeatureInCore : OpenGl_FeatureInExtensions;
475 }
476 }
e44b849d 477
478 theCtx.oesSampleVariables = checkExtensionShort ("GL_OES_sample_variables");
479 theCtx.oesStdDerivatives = checkExtensionShort ("GL_OES_standard_derivatives");
480 theCtx.hasSampleVariables = isGlGreaterEqualShort (3, 2) ? OpenGl_FeatureInCore :
481 theCtx.oesSampleVariables ? OpenGl_FeatureInExtensions
482 : OpenGl_FeatureNotAvailable;
483 theCtx.hasGlslBitwiseOps = isGlGreaterEqualShort (3, 0)
484 ? OpenGl_FeatureInCore
485 : OpenGl_FeatureNotAvailable;
486 // without hasHighp, dFdx/dFdy precision is considered too low for flat shading (visual artifacts)
487 theCtx.hasFlatShading = isGlGreaterEqualShort (3, 0)
488 ? OpenGl_FeatureInCore
489 : (theCtx.oesStdDerivatives && theCtx.hasHighp
490 ? OpenGl_FeatureInExtensions
491 : OpenGl_FeatureNotAvailable);
492 if (!isGlGreaterEqualShort (3, 1)
493 && theCtx.Vendor().Search("qualcomm") != -1)
494 {
495 // dFdx/dFdy are completely broken on tested Adreno devices with versions below OpenGl ES 3.1
496 theCtx.hasFlatShading = OpenGl_FeatureNotAvailable;
497 }
498
499 theCtx.hasGeometryStage = isGlGreaterEqualShort (3, 2)
500 ? OpenGl_FeatureInCore
501 : (checkExtensionShort ("GL_EXT_geometry_shader") && checkExtensionShort ("GL_EXT_shader_io_blocks")
502 ? OpenGl_FeatureInExtensions
503 : OpenGl_FeatureNotAvailable);
504#else
505
506 theCtx.hasTexRGBA8 = true;
507 theCtx.hasTexSRGB = isGlGreaterEqualShort (2, 1);
508 theCtx.hasFboSRGB = isGlGreaterEqualShort (2, 1);
509 theCtx.hasSRGBControl = theCtx.hasFboSRGB;
510 theCtx.hasFboRenderMipmap = true;
511 theCtx.arbDrawBuffers = checkExtensionShort ("GL_ARB_draw_buffers");
512 theCtx.arbNPTW = checkExtensionShort ("GL_ARB_texture_non_power_of_two");
513 theCtx.arbTexFloat = isGlGreaterEqualShort (3, 0)
514 || checkExtensionShort ("GL_ARB_texture_float");
515 theCtx.hasTexFloatLinear = theCtx.arbTexFloat;
516 theCtx.arbSampleShading = checkExtensionShort ("GL_ARB_sample_shading");
517 theCtx.arbDepthClamp = isGlGreaterEqualShort (3, 2)
518 || checkExtensionShort ("GL_ARB_depth_clamp")
519 || checkExtensionShort ("NV_depth_clamp");
520 theCtx.extBgra = isGlGreaterEqualShort (1, 2)
521 || checkExtensionShort ("GL_EXT_bgra");
522 theCtx.extAnis = checkExtensionShort ("GL_EXT_texture_filter_anisotropic");
523 theCtx.extPDS = checkExtensionShort ("GL_EXT_packed_depth_stencil");
524 theCtx.atiMem = checkExtensionShort ("GL_ATI_meminfo");
525 theCtx.nvxMem = checkExtensionShort ("GL_NVX_gpu_memory_info");
526
527 theCtx.hasDrawBuffers = isGlGreaterEqualShort (2, 0) ? OpenGl_FeatureInCore :
528 theCtx.arbDrawBuffers ? OpenGl_FeatureInExtensions
529 : OpenGl_FeatureNotAvailable;
530
531 theCtx.hasGlslBitwiseOps = isGlGreaterEqualShort (3, 0)
532 ? OpenGl_FeatureInCore
533 : checkExtensionShort ("GL_EXT_gpu_shader4")
534 ? OpenGl_FeatureInExtensions
535 : OpenGl_FeatureNotAvailable;
536
537 theCtx.hasFloatBuffer = theCtx.hasHalfFloatBuffer =
538 isGlGreaterEqualShort (3, 0) ? OpenGl_FeatureInCore :
539 checkExtensionShort ("GL_ARB_color_buffer_float") ? OpenGl_FeatureInExtensions
540 : OpenGl_FeatureNotAvailable;
541
542 theCtx.hasGeometryStage = isGlGreaterEqualShort (3, 2)
543 ? OpenGl_FeatureInCore
544 : OpenGl_FeatureNotAvailable;
545
546 theCtx.hasSampleVariables = isGlGreaterEqualShort (4, 0) ? OpenGl_FeatureInCore :
547 theCtx.arbSampleShading ? OpenGl_FeatureInExtensions
548 : OpenGl_FeatureNotAvailable;
549
550 bool has12 = false, has13 = false, has14 = false, has15 = false;
551 bool has20 = false, has21 = false;
552 bool has30 = false, has31 = false, has32 = false, has33 = false;
952a0565 553 bool has40 = false, has41 = false, has42 = false, has43 = false, has44 = false, has45 = false, has46 = false;
e44b849d 554
555 // retrieve platform-dependent extensions
556#if defined(HAVE_EGL)
557 //
558#elif defined(_WIN32)
559 if (FindProcShort (wglGetExtensionsStringARB))
560 {
561 const char* aWglExts = this->wglGetExtensionsStringARB (wglGetCurrentDC());
562 if (checkExtensionShort (aWglExts, "WGL_EXT_swap_control"))
563 {
564 FindProcShort (wglSwapIntervalEXT);
565 }
566 if (checkExtensionShort (aWglExts, "WGL_ARB_pixel_format"))
567 {
568 FindProcShort (wglChoosePixelFormatARB);
569 }
570 if (checkExtensionShort (aWglExts, "WGL_ARB_create_context_profile"))
571 {
572 FindProcShort (wglCreateContextAttribsARB);
573 }
574 if (checkExtensionShort (aWglExts, "WGL_NV_DX_interop"))
575 {
576 FindProcShort (wglDXSetResourceShareHandleNV);
577 FindProcShort (wglDXOpenDeviceNV);
578 FindProcShort (wglDXCloseDeviceNV);
579 FindProcShort (wglDXRegisterObjectNV);
580 FindProcShort (wglDXUnregisterObjectNV);
581 FindProcShort (wglDXObjectAccessNV);
582 FindProcShort (wglDXLockObjectsNV);
583 FindProcShort (wglDXUnlockObjectsNV);
584 }
585 if (checkExtensionShort (aWglExts, "WGL_AMD_gpu_association"))
586 {
587 FindProcShort (wglGetGPUIDsAMD);
588 FindProcShort (wglGetGPUInfoAMD);
589 FindProcShort (wglGetContextGPUIDAMD);
590 }
591 }
b69e576a 592#elif defined(HAVE_XLIB)
e44b849d 593 const char* aGlxExts = ::glXQueryExtensionsString ((Display* )theCtx.myDisplay, DefaultScreen ((Display* )theCtx.myDisplay));
594 if (checkExtensionShort (aGlxExts, "GLX_EXT_swap_control"))
595 {
596 FindProcShort (glXSwapIntervalEXT);
597 }
598 if (checkExtensionShort (aGlxExts, "GLX_SGI_swap_control"))
599 {
600 FindProcShort (glXSwapIntervalSGI);
601 }
602 if (checkExtensionShort (aGlxExts, "GLX_MESA_query_renderer"))
603 {
604 FindProcShort (glXQueryRendererIntegerMESA);
605 FindProcShort (glXQueryCurrentRendererIntegerMESA);
606 FindProcShort (glXQueryRendererStringMESA);
607 FindProcShort (glXQueryCurrentRendererStringMESA);
608 }
609 //extSwapTear = checkExtensionShort (aGlxExts, "GLX_EXT_swap_control_tear");
610#endif
611
612 // load OpenGL 1.2 new functions
613 has12 = isGlGreaterEqualShort (1, 2)
614 && FindProcShort (glBlendColor)
615 && FindProcShort (glBlendEquation)
616 && FindProcShort (glDrawRangeElements)
617 && FindProcShort (glTexImage3D)
618 && FindProcShort (glTexSubImage3D)
619 && FindProcShort (glCopyTexSubImage3D);
620 if (!has12)
621 {
622 theCtx.checkWrongVersion (1, 2, aLastFailedProc);
623 }
624
625 // load OpenGL 1.3 new functions
626 has13 = isGlGreaterEqualShort (1, 3)
627 && FindProcShort (glActiveTexture)
628 && FindProcShort (glSampleCoverage)
629 && FindProcShort (glCompressedTexImage3D)
630 && FindProcShort (glCompressedTexImage2D)
631 && FindProcShort (glCompressedTexImage1D)
632 && FindProcShort (glCompressedTexSubImage3D)
633 && FindProcShort (glCompressedTexSubImage2D)
634 && FindProcShort (glCompressedTexSubImage1D)
635 && FindProcShort (glGetCompressedTexImage);
e44b849d 636 if (!has13)
637 {
638 theCtx.checkWrongVersion (1, 3, aLastFailedProc);
639 }
640
641 // load OpenGL 1.4 new functions
642 has14 = isGlGreaterEqualShort (1, 4)
643 && FindProcShort (glBlendFuncSeparate)
644 && FindProcShort (glMultiDrawArrays)
645 && FindProcShort (glMultiDrawElements)
646 && FindProcShort (glPointParameterf)
647 && FindProcShort (glPointParameterfv)
648 && FindProcShort (glPointParameteri)
649 && FindProcShort (glPointParameteriv);
650 if (!has14)
651 {
652 theCtx.checkWrongVersion (1, 4, aLastFailedProc);
653 }
654
655 // load OpenGL 1.5 new functions
656 has15 = isGlGreaterEqualShort (1, 5)
657 && FindProcShort (glGenQueries)
658 && FindProcShort (glDeleteQueries)
659 && FindProcShort (glIsQuery)
660 && FindProcShort (glBeginQuery)
661 && FindProcShort (glEndQuery)
662 && FindProcShort (glGetQueryiv)
663 && FindProcShort (glGetQueryObjectiv)
664 && FindProcShort (glGetQueryObjectuiv)
665 && FindProcShort (glBindBuffer)
666 && FindProcShort (glDeleteBuffers)
667 && FindProcShort (glGenBuffers)
668 && FindProcShort (glIsBuffer)
669 && FindProcShort (glBufferData)
670 && FindProcShort (glBufferSubData)
671 && FindProcShort (glGetBufferSubData)
672 && FindProcShort (glMapBuffer)
673 && FindProcShort (glUnmapBuffer)
674 && FindProcShort (glGetBufferParameteriv)
675 && FindProcShort (glGetBufferPointerv);
676 if (has15)
677 {
43eddb47 678 theCtx.core15 = (OpenGl_GlCore15* )this;
679 theCtx.core15fwd = (OpenGl_GlCore15* )this;
e44b849d 680 theCtx.hasGetBufferData = true;
681 }
682 else
683 {
684 theCtx.checkWrongVersion (1, 5, aLastFailedProc);
685 }
686
687 // load OpenGL 2.0 new functions
688 has20 = isGlGreaterEqualShort (2, 0)
689 && FindProcShort (glBlendEquationSeparate)
690 && FindProcShort (glDrawBuffers)
691 && FindProcShort (glStencilOpSeparate)
692 && FindProcShort (glStencilFuncSeparate)
693 && FindProcShort (glStencilMaskSeparate)
694 && FindProcShort (glAttachShader)
695 && FindProcShort (glBindAttribLocation)
696 && FindProcShort (glCompileShader)
697 && FindProcShort (glCreateProgram)
698 && FindProcShort (glCreateShader)
699 && FindProcShort (glDeleteProgram)
700 && FindProcShort (glDeleteShader)
701 && FindProcShort (glDetachShader)
702 && FindProcShort (glDisableVertexAttribArray)
703 && FindProcShort (glEnableVertexAttribArray)
704 && FindProcShort (glGetActiveAttrib)
705 && FindProcShort (glGetActiveUniform)
706 && FindProcShort (glGetAttachedShaders)
707 && FindProcShort (glGetAttribLocation)
708 && FindProcShort (glGetProgramiv)
709 && FindProcShort (glGetProgramInfoLog)
710 && FindProcShort (glGetShaderiv)
711 && FindProcShort (glGetShaderInfoLog)
712 && FindProcShort (glGetShaderSource)
713 && FindProcShort (glGetUniformLocation)
714 && FindProcShort (glGetUniformfv)
715 && FindProcShort (glGetUniformiv)
716 && FindProcShort (glGetVertexAttribdv)
717 && FindProcShort (glGetVertexAttribfv)
718 && FindProcShort (glGetVertexAttribiv)
719 && FindProcShort (glGetVertexAttribPointerv)
720 && FindProcShort (glIsProgram)
721 && FindProcShort (glIsShader)
722 && FindProcShort (glLinkProgram)
723 && FindProcShort (glShaderSource)
724 && FindProcShort (glUseProgram)
725 && FindProcShort (glUniform1f)
726 && FindProcShort (glUniform2f)
727 && FindProcShort (glUniform3f)
728 && FindProcShort (glUniform4f)
729 && FindProcShort (glUniform1i)
730 && FindProcShort (glUniform2i)
731 && FindProcShort (glUniform3i)
732 && FindProcShort (glUniform4i)
733 && FindProcShort (glUniform1fv)
734 && FindProcShort (glUniform2fv)
735 && FindProcShort (glUniform3fv)
736 && FindProcShort (glUniform4fv)
737 && FindProcShort (glUniform1iv)
738 && FindProcShort (glUniform2iv)
739 && FindProcShort (glUniform3iv)
740 && FindProcShort (glUniform4iv)
741 && FindProcShort (glUniformMatrix2fv)
742 && FindProcShort (glUniformMatrix3fv)
743 && FindProcShort (glUniformMatrix4fv)
744 && FindProcShort (glValidateProgram)
745 && FindProcShort (glVertexAttrib1d)
746 && FindProcShort (glVertexAttrib1dv)
747 && FindProcShort (glVertexAttrib1f)
748 && FindProcShort (glVertexAttrib1fv)
749 && FindProcShort (glVertexAttrib1s)
750 && FindProcShort (glVertexAttrib1sv)
751 && FindProcShort (glVertexAttrib2d)
752 && FindProcShort (glVertexAttrib2dv)
753 && FindProcShort (glVertexAttrib2f)
754 && FindProcShort (glVertexAttrib2fv)
755 && FindProcShort (glVertexAttrib2s)
756 && FindProcShort (glVertexAttrib2sv)
757 && FindProcShort (glVertexAttrib3d)
758 && FindProcShort (glVertexAttrib3dv)
759 && FindProcShort (glVertexAttrib3f)
760 && FindProcShort (glVertexAttrib3fv)
761 && FindProcShort (glVertexAttrib3s)
762 && FindProcShort (glVertexAttrib3sv)
763 && FindProcShort (glVertexAttrib4Nbv)
764 && FindProcShort (glVertexAttrib4Niv)
765 && FindProcShort (glVertexAttrib4Nsv)
766 && FindProcShort (glVertexAttrib4Nub)
767 && FindProcShort (glVertexAttrib4Nubv)
768 && FindProcShort (glVertexAttrib4Nuiv)
769 && FindProcShort (glVertexAttrib4Nusv)
770 && FindProcShort (glVertexAttrib4bv)
771 && FindProcShort (glVertexAttrib4d)
772 && FindProcShort (glVertexAttrib4dv)
773 && FindProcShort (glVertexAttrib4f)
774 && FindProcShort (glVertexAttrib4fv)
775 && FindProcShort (glVertexAttrib4iv)
776 && FindProcShort (glVertexAttrib4s)
777 && FindProcShort (glVertexAttrib4sv)
778 && FindProcShort (glVertexAttrib4ubv)
779 && FindProcShort (glVertexAttrib4uiv)
780 && FindProcShort (glVertexAttrib4usv)
781 && FindProcShort (glVertexAttribPointer);
782 if (has20)
783 {
784 const char* aGlslVer = (const char* )::glGetString (GL_SHADING_LANGUAGE_VERSION);
785 if (aGlslVer == NULL
786 || *aGlslVer == '\0')
787 {
788 // broken context has been detected
789 theCtx.checkWrongVersion (2, 0, "GLSL 1.1");
790 }
791 else
792 {
43eddb47 793 theCtx.core20 = (OpenGl_GlCore20* )this;
794 theCtx.core20fwd = (OpenGl_GlCore20* )this;
e44b849d 795 }
796 }
797 else
798 {
799 theCtx.checkWrongVersion (2, 0, aLastFailedProc);
800 }
801
802 // load OpenGL 2.1 new functions
803 has21 = isGlGreaterEqualShort (2, 1)
804 && FindProcShort (glUniformMatrix2x3fv)
805 && FindProcShort (glUniformMatrix3x2fv)
806 && FindProcShort (glUniformMatrix2x4fv)
807 && FindProcShort (glUniformMatrix4x2fv)
808 && FindProcShort (glUniformMatrix3x4fv)
809 && FindProcShort (glUniformMatrix4x3fv);
810 if (!has21)
811 {
812 theCtx.checkWrongVersion (2, 1, aLastFailedProc);
813 }
814
815 // load GL_ARB_framebuffer_object (added to OpenGL 3.0 core)
816 const bool hasFBO = (isGlGreaterEqualShort (3, 0) || checkExtensionShort ("GL_ARB_framebuffer_object"))
817 && FindProcShort (glIsRenderbuffer)
818 && FindProcShort (glBindRenderbuffer)
819 && FindProcShort (glDeleteRenderbuffers)
820 && FindProcShort (glGenRenderbuffers)
821 && FindProcShort (glRenderbufferStorage)
822 && FindProcShort (glGetRenderbufferParameteriv)
823 && FindProcShort (glIsFramebuffer)
824 && FindProcShort (glBindFramebuffer)
825 && FindProcShort (glDeleteFramebuffers)
826 && FindProcShort (glGenFramebuffers)
827 && FindProcShort (glCheckFramebufferStatus)
828 && FindProcShort (glFramebufferTexture1D)
829 && FindProcShort (glFramebufferTexture2D)
830 && FindProcShort (glFramebufferTexture3D)
831 && FindProcShort (glFramebufferRenderbuffer)
832 && FindProcShort (glGetFramebufferAttachmentParameteriv)
833 && FindProcShort (glGenerateMipmap)
834 && FindProcShort (glBlitFramebuffer)
835 && FindProcShort (glRenderbufferStorageMultisample)
836 && FindProcShort (glFramebufferTextureLayer);
837
838 // load GL_ARB_vertex_array_object (added to OpenGL 3.0 core)
839 const bool hasVAO = (isGlGreaterEqualShort (3, 0) || checkExtensionShort ("GL_ARB_vertex_array_object"))
840 && FindProcShort (glBindVertexArray)
841 && FindProcShort (glDeleteVertexArrays)
842 && FindProcShort (glGenVertexArrays)
843 && FindProcShort (glIsVertexArray);
844
845 // load GL_ARB_map_buffer_range (added to OpenGL 3.0 core)
846 const bool hasMapBufferRange = (isGlGreaterEqualShort (3, 0) || checkExtensionShort ("GL_ARB_map_buffer_range"))
847 && FindProcShort (glMapBufferRange)
848 && FindProcShort (glFlushMappedBufferRange);
849
850 // load OpenGL 3.0 new functions
851 has30 = isGlGreaterEqualShort (3, 0)
852 && hasFBO
853 && hasVAO
854 && hasMapBufferRange
855 && FindProcShort (glColorMaski)
856 && FindProcShort (glGetBooleani_v)
857 && FindProcShort (glGetIntegeri_v)
858 && FindProcShort (glEnablei)
859 && FindProcShort (glDisablei)
860 && FindProcShort (glIsEnabledi)
861 && FindProcShort (glBeginTransformFeedback)
862 && FindProcShort (glEndTransformFeedback)
863 && FindProcShort (glBindBufferRange)
864 && FindProcShort (glBindBufferBase)
865 && FindProcShort (glTransformFeedbackVaryings)
866 && FindProcShort (glGetTransformFeedbackVarying)
867 && FindProcShort (glClampColor)
868 && FindProcShort (glBeginConditionalRender)
869 && FindProcShort (glEndConditionalRender)
870 && FindProcShort (glVertexAttribIPointer)
871 && FindProcShort (glGetVertexAttribIiv)
872 && FindProcShort (glGetVertexAttribIuiv)
873 && FindProcShort (glVertexAttribI1i)
874 && FindProcShort (glVertexAttribI2i)
875 && FindProcShort (glVertexAttribI3i)
876 && FindProcShort (glVertexAttribI4i)
877 && FindProcShort (glVertexAttribI1ui)
878 && FindProcShort (glVertexAttribI2ui)
879 && FindProcShort (glVertexAttribI3ui)
880 && FindProcShort (glVertexAttribI4ui)
881 && FindProcShort (glVertexAttribI1iv)
882 && FindProcShort (glVertexAttribI2iv)
883 && FindProcShort (glVertexAttribI3iv)
884 && FindProcShort (glVertexAttribI4iv)
885 && FindProcShort (glVertexAttribI1uiv)
886 && FindProcShort (glVertexAttribI2uiv)
887 && FindProcShort (glVertexAttribI3uiv)
888 && FindProcShort (glVertexAttribI4uiv)
889 && FindProcShort (glVertexAttribI4bv)
890 && FindProcShort (glVertexAttribI4sv)
891 && FindProcShort (glVertexAttribI4ubv)
892 && FindProcShort (glVertexAttribI4usv)
893 && FindProcShort (glGetUniformuiv)
894 && FindProcShort (glBindFragDataLocation)
895 && FindProcShort (glGetFragDataLocation)
896 && FindProcShort (glUniform1ui)
897 && FindProcShort (glUniform2ui)
898 && FindProcShort (glUniform3ui)
899 && FindProcShort (glUniform4ui)
900 && FindProcShort (glUniform1uiv)
901 && FindProcShort (glUniform2uiv)
902 && FindProcShort (glUniform3uiv)
903 && FindProcShort (glUniform4uiv)
904 && FindProcShort (glTexParameterIiv)
905 && FindProcShort (glTexParameterIuiv)
906 && FindProcShort (glGetTexParameterIiv)
907 && FindProcShort (glGetTexParameterIuiv)
908 && FindProcShort (glClearBufferiv)
909 && FindProcShort (glClearBufferuiv)
910 && FindProcShort (glClearBufferfv)
911 && FindProcShort (glClearBufferfi)
912 && FindProcShort (glGetStringi);
913 if (!has30)
914 {
915 theCtx.checkWrongVersion (3, 0, aLastFailedProc);
916 }
917
918 // load GL_ARB_uniform_buffer_object (added to OpenGL 3.1 core)
919 const bool hasUBO = (isGlGreaterEqualShort (3, 1) || checkExtensionShort ("GL_ARB_uniform_buffer_object"))
920 && FindProcShort (glGetUniformIndices)
921 && FindProcShort (glGetActiveUniformsiv)
922 && FindProcShort (glGetActiveUniformName)
923 && FindProcShort (glGetUniformBlockIndex)
924 && FindProcShort (glGetActiveUniformBlockiv)
925 && FindProcShort (glGetActiveUniformBlockName)
926 && FindProcShort (glUniformBlockBinding);
927
928 // load GL_ARB_copy_buffer (added to OpenGL 3.1 core)
929 const bool hasCopyBufSubData = (isGlGreaterEqualShort (3, 1) || checkExtensionShort ("GL_ARB_copy_buffer"))
930 && FindProcShort (glCopyBufferSubData);
931
932 if (has30)
933 {
934 // NPOT textures are required by OpenGL 2.0 specifications
935 // but doesn't hardware accelerated by some ancient OpenGL 2.1 hardware (GeForce FX, RadeOn 9700 etc.)
936 theCtx.arbNPTW = true;
937 theCtx.arbTexRG = true;
938
43eddb47 939 theCtx.core30 = (OpenGl_GlCore30* )this;
e44b849d 940 }
941
942 // load OpenGL 3.1 new functions
943 has31 = isGlGreaterEqualShort (3, 1)
944 && hasUBO
945 && hasCopyBufSubData
946 && FindProcShort (glDrawArraysInstanced)
947 && FindProcShort (glDrawElementsInstanced)
948 && FindProcShort (glTexBuffer)
949 && FindProcShort (glPrimitiveRestartIndex);
950 if (has31)
951 {
952 theCtx.arbTBO = (OpenGl_ArbTBO* )this;
953 theCtx.arbIns = (OpenGl_ArbIns* )this;
954 }
955 else
956 {
957 theCtx.checkWrongVersion (3, 1, aLastFailedProc);
958
959 // initialize TBO extension (ARB)
960 if (checkExtensionShort ("GL_ARB_texture_buffer_object")
961 && theCtx.FindProc ("glTexBufferARB", this->glTexBuffer))
962 {
963 theCtx.arbTBO = (OpenGl_ArbTBO* )this;
964 }
965
966 // initialize hardware instancing extension (ARB)
967 if (checkExtensionShort ("GL_ARB_draw_instanced")
968 && theCtx.FindProc ("glDrawArraysInstancedARB", this->glDrawArraysInstanced)
969 && theCtx.FindProc ("glDrawElementsInstancedARB", this->glDrawElementsInstanced))
970 {
971 theCtx.arbIns = (OpenGl_ArbIns* )this;
972 }
973 }
974
975 theCtx.arbTboRGB32 = checkExtensionShort ("GL_ARB_texture_buffer_object_rgb32");
976
977 // load GL_ARB_draw_elements_base_vertex (added to OpenGL 3.2 core)
978 const bool hasDrawElemsBaseVert = (isGlGreaterEqualShort (3, 2) || checkExtensionShort ("GL_ARB_draw_elements_base_vertex"))
979 && FindProcShort (glDrawElementsBaseVertex)
980 && FindProcShort (glDrawRangeElementsBaseVertex)
981 && FindProcShort (glDrawElementsInstancedBaseVertex)
982 && FindProcShort (glMultiDrawElementsBaseVertex);
983
984 // load GL_ARB_provoking_vertex (added to OpenGL 3.2 core)
985 const bool hasProvokingVert = (isGlGreaterEqualShort (3, 2) || checkExtensionShort ("GL_ARB_provoking_vertex"))
986 && FindProcShort (glProvokingVertex);
987
988 // load GL_ARB_sync (added to OpenGL 3.2 core)
989 const bool hasSync = (isGlGreaterEqualShort (3, 2) || checkExtensionShort ("GL_ARB_sync"))
990 && FindProcShort (glFenceSync)
991 && FindProcShort (glIsSync)
992 && FindProcShort (glDeleteSync)
993 && FindProcShort (glClientWaitSync)
994 && FindProcShort (glWaitSync)
995 && FindProcShort (glGetInteger64v)
996 && FindProcShort (glGetSynciv);
997
998 // load GL_ARB_texture_multisample (added to OpenGL 3.2 core)
999 const bool hasTextureMultisample = (isGlGreaterEqualShort (3, 2) || checkExtensionShort ("GL_ARB_texture_multisample"))
1000 && FindProcShort (glTexImage2DMultisample)
1001 && FindProcShort (glTexImage3DMultisample)
1002 && FindProcShort (glGetMultisamplefv)
1003 && FindProcShort (glSampleMaski);
1004
1005 // load OpenGL 3.2 new functions
1006 has32 = isGlGreaterEqualShort (3, 2)
1007 && hasDrawElemsBaseVert
1008 && hasProvokingVert
1009 && hasSync
1010 && hasTextureMultisample
1011 && FindProcShort (glGetInteger64i_v)
1012 && FindProcShort (glGetBufferParameteri64v)
1013 && FindProcShort (glFramebufferTexture);
1014 if (has32)
1015 {
1016 theCtx.core32 = (OpenGl_GlCore32* )this;
e44b849d 1017 }
1018 else
1019 {
1020 theCtx.checkWrongVersion (3, 2, aLastFailedProc);
1021 }
1022
1023 // load GL_ARB_blend_func_extended (added to OpenGL 3.3 core)
1024 const bool hasBlendFuncExtended = (isGlGreaterEqualShort (3, 3) || checkExtensionShort ("GL_ARB_blend_func_extended"))
1025 && FindProcShort (glBindFragDataLocationIndexed)
1026 && FindProcShort (glGetFragDataIndex);
1027
1028 // load GL_ARB_sampler_objects (added to OpenGL 3.3 core)
1029 const bool hasSamplerObjects = (isGlGreaterEqualShort (3, 3) || checkExtensionShort ("GL_ARB_sampler_objects"))
1030 && FindProcShort (glGenSamplers)
1031 && FindProcShort (glDeleteSamplers)
1032 && FindProcShort (glIsSampler)
1033 && FindProcShort (glBindSampler)
1034 && FindProcShort (glSamplerParameteri)
1035 && FindProcShort (glSamplerParameteriv)
1036 && FindProcShort (glSamplerParameterf)
1037 && FindProcShort (glSamplerParameterfv)
1038 && FindProcShort (glSamplerParameterIiv)
1039 && FindProcShort (glSamplerParameterIuiv)
1040 && FindProcShort (glGetSamplerParameteriv)
1041 && FindProcShort (glGetSamplerParameterIiv)
1042 && FindProcShort (glGetSamplerParameterfv)
1043 && FindProcShort (glGetSamplerParameterIuiv);
1044 if (hasSamplerObjects)
1045 {
1046 theCtx.arbSamplerObject = (OpenGl_ArbSamplerObject* )this;
1047 }
1048
1049 // load GL_ARB_timer_query (added to OpenGL 3.3 core)
1050 const bool hasTimerQuery = (isGlGreaterEqualShort (3, 3) || checkExtensionShort ("GL_ARB_timer_query"))
1051 && FindProcShort (glQueryCounter)
1052 && FindProcShort (glGetQueryObjecti64v)
1053 && FindProcShort (glGetQueryObjectui64v);
1054
1055 // load GL_ARB_vertex_type_2_10_10_10_rev (added to OpenGL 3.3 core)
1056 const bool hasVertType21010101rev = (isGlGreaterEqualShort (3, 3) || checkExtensionShort ("GL_ARB_vertex_type_2_10_10_10_rev"))
1057 && FindProcShort (glVertexAttribP1ui)
1058 && FindProcShort (glVertexAttribP1uiv)
1059 && FindProcShort (glVertexAttribP2ui)
1060 && FindProcShort (glVertexAttribP2uiv)
1061 && FindProcShort (glVertexAttribP3ui)
1062 && FindProcShort (glVertexAttribP3uiv)
1063 && FindProcShort (glVertexAttribP4ui)
1064 && FindProcShort (glVertexAttribP4uiv);
1065
e44b849d 1066 // load OpenGL 3.3 extra functions
1067 has33 = isGlGreaterEqualShort (3, 3)
1068 && hasBlendFuncExtended
1069 && hasSamplerObjects
1070 && hasTimerQuery
1071 && hasVertType21010101rev
1072 && FindProcShort (glVertexAttribDivisor);
1073 if (has33)
1074 {
1075 theCtx.core33 = (OpenGl_GlCore33* )this;
e44b849d 1076 }
1077 else
1078 {
1079 theCtx.checkWrongVersion (3, 3, aLastFailedProc);
1080 }
1081
1082 // load GL_ARB_draw_indirect (added to OpenGL 4.0 core)
1083 const bool hasDrawIndirect = (isGlGreaterEqualShort (4, 0) || checkExtensionShort ("GL_ARB_draw_indirect"))
1084 && FindProcShort (glDrawArraysIndirect)
1085 && FindProcShort (glDrawElementsIndirect);
1086
1087 // load GL_ARB_gpu_shader_fp64 (added to OpenGL 4.0 core)
1088 const bool hasShaderFP64 = (isGlGreaterEqualShort (4, 0) || checkExtensionShort ("GL_ARB_gpu_shader_fp64"))
1089 && FindProcShort (glUniform1d)
1090 && FindProcShort (glUniform2d)
1091 && FindProcShort (glUniform3d)
1092 && FindProcShort (glUniform4d)
1093 && FindProcShort (glUniform1dv)
1094 && FindProcShort (glUniform2dv)
1095 && FindProcShort (glUniform3dv)
1096 && FindProcShort (glUniform4dv)
1097 && FindProcShort (glUniformMatrix2dv)
1098 && FindProcShort (glUniformMatrix3dv)
1099 && FindProcShort (glUniformMatrix4dv)
1100 && FindProcShort (glUniformMatrix2x3dv)
1101 && FindProcShort (glUniformMatrix2x4dv)
1102 && FindProcShort (glUniformMatrix3x2dv)
1103 && FindProcShort (glUniformMatrix3x4dv)
1104 && FindProcShort (glUniformMatrix4x2dv)
1105 && FindProcShort (glUniformMatrix4x3dv)
1106 && FindProcShort (glGetUniformdv);
1107
1108 // load GL_ARB_shader_subroutine (added to OpenGL 4.0 core)
1109 const bool hasShaderSubroutine = (isGlGreaterEqualShort (4, 0) || checkExtensionShort ("GL_ARB_shader_subroutine"))
1110 && FindProcShort (glGetSubroutineUniformLocation)
1111 && FindProcShort (glGetSubroutineIndex)
1112 && FindProcShort (glGetActiveSubroutineUniformiv)
1113 && FindProcShort (glGetActiveSubroutineUniformName)
1114 && FindProcShort (glGetActiveSubroutineName)
1115 && FindProcShort (glUniformSubroutinesuiv)
1116 && FindProcShort (glGetUniformSubroutineuiv)
1117 && FindProcShort (glGetProgramStageiv);
1118
1119 // load GL_ARB_tessellation_shader (added to OpenGL 4.0 core)
1120 const bool hasTessellationShader = (isGlGreaterEqualShort (4, 0) || checkExtensionShort ("GL_ARB_tessellation_shader"))
1121 && FindProcShort (glPatchParameteri)
1122 && FindProcShort (glPatchParameterfv);
1123
1124 // load GL_ARB_transform_feedback2 (added to OpenGL 4.0 core)
1125 const bool hasTrsfFeedback2 = (isGlGreaterEqualShort (4, 0) || checkExtensionShort ("GL_ARB_transform_feedback2"))
1126 && FindProcShort (glBindTransformFeedback)
1127 && FindProcShort (glDeleteTransformFeedbacks)
1128 && FindProcShort (glGenTransformFeedbacks)
1129 && FindProcShort (glIsTransformFeedback)
1130 && FindProcShort (glPauseTransformFeedback)
1131 && FindProcShort (glResumeTransformFeedback)
1132 && FindProcShort (glDrawTransformFeedback);
1133
1134 // load GL_ARB_transform_feedback3 (added to OpenGL 4.0 core)
1135 const bool hasTrsfFeedback3 = (isGlGreaterEqualShort (4, 0) || checkExtensionShort ("GL_ARB_transform_feedback3"))
1136 && FindProcShort (glDrawTransformFeedbackStream)
1137 && FindProcShort (glBeginQueryIndexed)
1138 && FindProcShort (glEndQueryIndexed)
1139 && FindProcShort (glGetQueryIndexediv);
1140
1141 // load OpenGL 4.0 new functions
1142 has40 = isGlGreaterEqualShort (4, 0)
1143 && hasDrawIndirect
1144 && hasShaderFP64
1145 && hasShaderSubroutine
1146 && hasTessellationShader
1147 && hasTrsfFeedback2
1148 && hasTrsfFeedback3
1149 && FindProcShort (glMinSampleShading)
1150 && FindProcShort (glBlendEquationi)
1151 && FindProcShort (glBlendEquationSeparatei)
1152 && FindProcShort (glBlendFunci)
1153 && FindProcShort (glBlendFuncSeparatei);
1154 if (has40)
1155 {
1156 theCtx.arbTboRGB32 = true; // in core since OpenGL 4.0
1157 }
1158 else
1159 {
1160 theCtx.checkWrongVersion (4, 0, aLastFailedProc);
1161 }
1162
1163 // load GL_ARB_ES2_compatibility (added to OpenGL 4.1 core)
1164 const bool hasES2Compatibility = (isGlGreaterEqualShort (4, 1) || checkExtensionShort ("GL_ARB_ES2_compatibility"))
1165 && FindProcShort (glReleaseShaderCompiler)
1166 && FindProcShort (glShaderBinary)
1167 && FindProcShort (glGetShaderPrecisionFormat)
1168 && FindProcShort (glDepthRangef)
1169 && FindProcShort (glClearDepthf);
1170
1171 // load GL_ARB_get_program_binary (added to OpenGL 4.1 core)
1172 const bool hasGetProgramBinary = (isGlGreaterEqualShort (4, 1) || checkExtensionShort ("GL_ARB_get_program_binary"))
1173 && FindProcShort (glGetProgramBinary)
1174 && FindProcShort (glProgramBinary)
1175 && FindProcShort (glProgramParameteri);
1176
1177
1178 // load GL_ARB_separate_shader_objects (added to OpenGL 4.1 core)
1179 const bool hasSeparateShaderObjects = (isGlGreaterEqualShort (4, 1) || checkExtensionShort ("GL_ARB_separate_shader_objects"))
1180 && FindProcShort (glUseProgramStages)
1181 && FindProcShort (glActiveShaderProgram)
1182 && FindProcShort (glCreateShaderProgramv)
1183 && FindProcShort (glBindProgramPipeline)
1184 && FindProcShort (glDeleteProgramPipelines)
1185 && FindProcShort (glGenProgramPipelines)
1186 && FindProcShort (glIsProgramPipeline)
1187 && FindProcShort (glGetProgramPipelineiv)
1188 && FindProcShort (glProgramUniform1i)
1189 && FindProcShort (glProgramUniform1iv)
1190 && FindProcShort (glProgramUniform1f)
1191 && FindProcShort (glProgramUniform1fv)
1192 && FindProcShort (glProgramUniform1d)
1193 && FindProcShort (glProgramUniform1dv)
1194 && FindProcShort (glProgramUniform1ui)
1195 && FindProcShort (glProgramUniform1uiv)
1196 && FindProcShort (glProgramUniform2i)
1197 && FindProcShort (glProgramUniform2iv)
1198 && FindProcShort (glProgramUniform2f)
1199 && FindProcShort (glProgramUniform2fv)
1200 && FindProcShort (glProgramUniform2d)
1201 && FindProcShort (glProgramUniform2dv)
1202 && FindProcShort (glProgramUniform2ui)
1203 && FindProcShort (glProgramUniform2uiv)
1204 && FindProcShort (glProgramUniform3i)
1205 && FindProcShort (glProgramUniform3iv)
1206 && FindProcShort (glProgramUniform3f)
1207 && FindProcShort (glProgramUniform3fv)
1208 && FindProcShort (glProgramUniform3d)
1209 && FindProcShort (glProgramUniform3dv)
1210 && FindProcShort (glProgramUniform3ui)
1211 && FindProcShort (glProgramUniform3uiv)
1212 && FindProcShort (glProgramUniform4i)
1213 && FindProcShort (glProgramUniform4iv)
1214 && FindProcShort (glProgramUniform4f)
1215 && FindProcShort (glProgramUniform4fv)
1216 && FindProcShort (glProgramUniform4d)
1217 && FindProcShort (glProgramUniform4dv)
1218 && FindProcShort (glProgramUniform4ui)
1219 && FindProcShort (glProgramUniform4uiv)
1220 && FindProcShort (glProgramUniformMatrix2fv)
1221 && FindProcShort (glProgramUniformMatrix3fv)
1222 && FindProcShort (glProgramUniformMatrix4fv)
1223 && FindProcShort (glProgramUniformMatrix2dv)
1224 && FindProcShort (glProgramUniformMatrix3dv)
1225 && FindProcShort (glProgramUniformMatrix4dv)
1226 && FindProcShort (glProgramUniformMatrix2x3fv)
1227 && FindProcShort (glProgramUniformMatrix3x2fv)
1228 && FindProcShort (glProgramUniformMatrix2x4fv)
1229 && FindProcShort (glProgramUniformMatrix4x2fv)
1230 && FindProcShort (glProgramUniformMatrix3x4fv)
1231 && FindProcShort (glProgramUniformMatrix4x3fv)
1232 && FindProcShort (glProgramUniformMatrix2x3dv)
1233 && FindProcShort (glProgramUniformMatrix3x2dv)
1234 && FindProcShort (glProgramUniformMatrix2x4dv)
1235 && FindProcShort (glProgramUniformMatrix4x2dv)
1236 && FindProcShort (glProgramUniformMatrix3x4dv)
1237 && FindProcShort (glProgramUniformMatrix4x3dv)
1238 && FindProcShort (glValidateProgramPipeline)
1239 && FindProcShort (glGetProgramPipelineInfoLog);
1240
1241 // load GL_ARB_vertex_attrib_64bit (added to OpenGL 4.1 core)
1242 const bool hasVertAttrib64bit = (isGlGreaterEqualShort (4, 1) || checkExtensionShort ("GL_ARB_vertex_attrib_64bit"))
1243 && FindProcShort (glVertexAttribL1d)
1244 && FindProcShort (glVertexAttribL2d)
1245 && FindProcShort (glVertexAttribL3d)
1246 && FindProcShort (glVertexAttribL4d)
1247 && FindProcShort (glVertexAttribL1dv)
1248 && FindProcShort (glVertexAttribL2dv)
1249 && FindProcShort (glVertexAttribL3dv)
1250 && FindProcShort (glVertexAttribL4dv)
1251 && FindProcShort (glVertexAttribLPointer)
1252 && FindProcShort (glGetVertexAttribLdv);
1253
1254 // load GL_ARB_viewport_array (added to OpenGL 4.1 core)
1255 const bool hasViewportArray = (isGlGreaterEqualShort (4, 1) || checkExtensionShort ("GL_ARB_viewport_array"))
1256 && FindProcShort (glViewportArrayv)
1257 && FindProcShort (glViewportIndexedf)
1258 && FindProcShort (glViewportIndexedfv)
1259 && FindProcShort (glScissorArrayv)
1260 && FindProcShort (glScissorIndexed)
1261 && FindProcShort (glScissorIndexedv)
1262 && FindProcShort (glDepthRangeArrayv)
1263 && FindProcShort (glDepthRangeIndexed)
1264 && FindProcShort (glGetFloati_v)
1265 && FindProcShort (glGetDoublei_v);
1266
1267 has41 = isGlGreaterEqualShort (4, 1)
1268 && hasES2Compatibility
1269 && hasGetProgramBinary
1270 && hasSeparateShaderObjects
1271 && hasVertAttrib64bit
1272 && hasViewportArray;
1273 if (has41)
1274 {
1275 theCtx.core41 = (OpenGl_GlCore41* )this;
e44b849d 1276 }
1277 else
1278 {
1279 theCtx.checkWrongVersion (4, 1, aLastFailedProc);
1280 }
1281
1282 // load GL_ARB_base_instance (added to OpenGL 4.2 core)
1283 const bool hasBaseInstance = (isGlGreaterEqualShort (4, 2) || checkExtensionShort ("GL_ARB_base_instance"))
1284 && FindProcShort (glDrawArraysInstancedBaseInstance)
1285 && FindProcShort (glDrawElementsInstancedBaseInstance)
1286 && FindProcShort (glDrawElementsInstancedBaseVertexBaseInstance);
1287
1288 // load GL_ARB_transform_feedback_instanced (added to OpenGL 4.2 core)
1289 const bool hasTrsfFeedbackInstanced = (isGlGreaterEqualShort (4, 2) || checkExtensionShort ("GL_ARB_transform_feedback_instanced"))
1290 && FindProcShort (glDrawTransformFeedbackInstanced)
1291 && FindProcShort (glDrawTransformFeedbackStreamInstanced);
1292
1293 // load GL_ARB_internalformat_query (added to OpenGL 4.2 core)
1294 const bool hasInternalFormatQuery = (isGlGreaterEqualShort (4, 2) || checkExtensionShort ("GL_ARB_internalformat_query"))
1295 && FindProcShort (glGetInternalformativ);
1296
1297 // load GL_ARB_shader_atomic_counters (added to OpenGL 4.2 core)
1298 const bool hasShaderAtomicCounters = (isGlGreaterEqualShort (4, 2) || checkExtensionShort ("GL_ARB_shader_atomic_counters"))
1299 && FindProcShort (glGetActiveAtomicCounterBufferiv);
1300
1301 // load GL_ARB_shader_image_load_store (added to OpenGL 4.2 core)
1302 const bool hasShaderImgLoadStore = (isGlGreaterEqualShort (4, 2) || checkExtensionShort ("GL_ARB_shader_image_load_store"))
1303 && FindProcShort (glBindImageTexture)
1304 && FindProcShort (glMemoryBarrier);
1305
1306 // load GL_ARB_texture_storage (added to OpenGL 4.2 core)
1307 const bool hasTextureStorage = (isGlGreaterEqualShort (4, 2) || checkExtensionShort ("GL_ARB_texture_storage"))
1308 && FindProcShort (glTexStorage1D)
1309 && FindProcShort (glTexStorage2D)
1310 && FindProcShort (glTexStorage3D);
1311
1312 has42 = isGlGreaterEqualShort (4, 2)
1313 && hasBaseInstance
1314 && hasTrsfFeedbackInstanced
1315 && hasInternalFormatQuery
1316 && hasShaderAtomicCounters
1317 && hasShaderImgLoadStore
1318 && hasTextureStorage;
1319 if (has42)
1320 {
1321 theCtx.core42 = (OpenGl_GlCore42* )this;
e44b849d 1322 }
1323 else
1324 {
1325 theCtx.checkWrongVersion (4, 2, aLastFailedProc);
1326 }
1327
1328 has43 = isGlGreaterEqualShort (4, 3)
1329 && FindProcShort (glClearBufferData)
1330 && FindProcShort (glClearBufferSubData)
1331 && FindProcShort (glDispatchCompute)
1332 && FindProcShort (glDispatchComputeIndirect)
1333 && FindProcShort (glCopyImageSubData)
1334 && FindProcShort (glFramebufferParameteri)
1335 && FindProcShort (glGetFramebufferParameteriv)
1336 && FindProcShort (glGetInternalformati64v)
1337 && FindProcShort (glInvalidateTexSubImage)
1338 && FindProcShort (glInvalidateTexImage)
1339 && FindProcShort (glInvalidateBufferSubData)
1340 && FindProcShort (glInvalidateBufferData)
1341 && FindProcShort (glInvalidateFramebuffer)
1342 && FindProcShort (glInvalidateSubFramebuffer)
1343 && FindProcShort (glMultiDrawArraysIndirect)
1344 && FindProcShort (glMultiDrawElementsIndirect)
1345 && FindProcShort (glGetProgramInterfaceiv)
1346 && FindProcShort (glGetProgramResourceIndex)
1347 && FindProcShort (glGetProgramResourceName)
1348 && FindProcShort (glGetProgramResourceiv)
1349 && FindProcShort (glGetProgramResourceLocation)
1350 && FindProcShort (glGetProgramResourceLocationIndex)
1351 && FindProcShort (glShaderStorageBlockBinding)
1352 && FindProcShort (glTexBufferRange)
1353 && FindProcShort (glTexStorage2DMultisample)
1354 && FindProcShort (glTexStorage3DMultisample)
1355 && FindProcShort (glTextureView)
1356 && FindProcShort (glBindVertexBuffer)
1357 && FindProcShort (glVertexAttribFormat)
1358 && FindProcShort (glVertexAttribIFormat)
1359 && FindProcShort (glVertexAttribLFormat)
1360 && FindProcShort (glVertexAttribBinding)
1361 && FindProcShort (glVertexBindingDivisor)
1362 && FindProcShort (glDebugMessageControl)
1363 && FindProcShort (glDebugMessageInsert)
1364 && FindProcShort (glDebugMessageCallback)
1365 && FindProcShort (glGetDebugMessageLog)
1366 && FindProcShort (glPushDebugGroup)
1367 && FindProcShort (glPopDebugGroup)
1368 && FindProcShort (glObjectLabel)
1369 && FindProcShort (glGetObjectLabel)
1370 && FindProcShort (glObjectPtrLabel)
1371 && FindProcShort (glGetObjectPtrLabel);
1372 if (has43)
1373 {
1374 theCtx.core43 = (OpenGl_GlCore43* )this;
e44b849d 1375 }
1376 else
1377 {
1378 theCtx.checkWrongVersion (4, 3, aLastFailedProc);
1379 }
1380
1381 // load GL_ARB_clear_texture (added to OpenGL 4.4 core)
1382 bool arbTexClear = (isGlGreaterEqualShort (4, 4) || checkExtensionShort ("GL_ARB_clear_texture"))
1383 && FindProcShort (glClearTexImage)
1384 && FindProcShort (glClearTexSubImage);
1385
1386 has44 = isGlGreaterEqualShort (4, 4)
1387 && arbTexClear
1388 && FindProcShort (glBufferStorage)
1389 && FindProcShort (glBindBuffersBase)
1390 && FindProcShort (glBindBuffersRange)
1391 && FindProcShort (glBindTextures)
1392 && FindProcShort (glBindSamplers)
1393 && FindProcShort (glBindImageTextures)
1394 && FindProcShort (glBindVertexBuffers);
1395 if (has44)
1396 {
1397 theCtx.core44 = (OpenGl_GlCore44* )this;
e44b849d 1398 }
1399 else
1400 {
1401 theCtx.checkWrongVersion (4, 4, aLastFailedProc);
1402 }
1403
1404 has45 = isGlGreaterEqualShort (4, 5)
1405 && FindProcShort (glBindVertexBuffers)
1406 && FindProcShort (glClipControl)
1407 && FindProcShort (glCreateTransformFeedbacks)
1408 && FindProcShort (glTransformFeedbackBufferBase)
1409 && FindProcShort (glTransformFeedbackBufferRange)
1410 && FindProcShort (glGetTransformFeedbackiv)
1411 && FindProcShort (glGetTransformFeedbacki_v)
1412 && FindProcShort (glGetTransformFeedbacki64_v)
1413 && FindProcShort (glCreateBuffers)
1414 && FindProcShort (glNamedBufferStorage)
1415 && FindProcShort (glNamedBufferData)
1416 && FindProcShort (glNamedBufferSubData)
1417 && FindProcShort (glCopyNamedBufferSubData)
1418 && FindProcShort (glClearNamedBufferData)
1419 && FindProcShort (glClearNamedBufferSubData)
1420 && FindProcShort (glMapNamedBuffer)
1421 && FindProcShort (glMapNamedBufferRange)
1422 && FindProcShort (glUnmapNamedBuffer)
1423 && FindProcShort (glFlushMappedNamedBufferRange)
1424 && FindProcShort (glGetNamedBufferParameteriv)
1425 && FindProcShort (glGetNamedBufferParameteri64v)
1426 && FindProcShort (glGetNamedBufferPointerv)
1427 && FindProcShort (glGetNamedBufferSubData)
1428 && FindProcShort (glCreateFramebuffers)
1429 && FindProcShort (glNamedFramebufferRenderbuffer)
1430 && FindProcShort (glNamedFramebufferParameteri)
1431 && FindProcShort (glNamedFramebufferTexture)
1432 && FindProcShort (glNamedFramebufferTextureLayer)
1433 && FindProcShort (glNamedFramebufferDrawBuffer)
1434 && FindProcShort (glNamedFramebufferDrawBuffers)
1435 && FindProcShort (glNamedFramebufferReadBuffer)
1436 && FindProcShort (glInvalidateNamedFramebufferData)
1437 && FindProcShort (glInvalidateNamedFramebufferSubData)
1438 && FindProcShort (glClearNamedFramebufferiv)
1439 && FindProcShort (glClearNamedFramebufferuiv)
1440 && FindProcShort (glClearNamedFramebufferfv)
1441 && FindProcShort (glClearNamedFramebufferfi)
1442 && FindProcShort (glBlitNamedFramebuffer)
1443 && FindProcShort (glCheckNamedFramebufferStatus)
1444 && FindProcShort (glGetNamedFramebufferParameteriv)
1445 && FindProcShort (glGetNamedFramebufferAttachmentParameteriv)
1446 && FindProcShort (glCreateRenderbuffers)
1447 && FindProcShort (glNamedRenderbufferStorage)
1448 && FindProcShort (glNamedRenderbufferStorageMultisample)
1449 && FindProcShort (glGetNamedRenderbufferParameteriv)
1450 && FindProcShort (glCreateTextures)
1451 && FindProcShort (glTextureBuffer)
1452 && FindProcShort (glTextureBufferRange)
1453 && FindProcShort (glTextureStorage1D)
1454 && FindProcShort (glTextureStorage2D)
1455 && FindProcShort (glTextureStorage3D)
1456 && FindProcShort (glTextureStorage2DMultisample)
1457 && FindProcShort (glTextureStorage3DMultisample)
1458 && FindProcShort (glTextureSubImage1D)
1459 && FindProcShort (glTextureSubImage2D)
1460 && FindProcShort (glTextureSubImage3D)
1461 && FindProcShort (glCompressedTextureSubImage1D)
1462 && FindProcShort (glCompressedTextureSubImage2D)
1463 && FindProcShort (glCompressedTextureSubImage3D)
1464 && FindProcShort (glCopyTextureSubImage1D)
1465 && FindProcShort (glCopyTextureSubImage2D)
1466 && FindProcShort (glCopyTextureSubImage3D)
1467 && FindProcShort (glTextureParameterf)
1468 && FindProcShort (glTextureParameterfv)
1469 && FindProcShort (glTextureParameteri)
1470 && FindProcShort (glTextureParameterIiv)
1471 && FindProcShort (glTextureParameterIuiv)
1472 && FindProcShort (glTextureParameteriv)
1473 && FindProcShort (glGenerateTextureMipmap)
1474 && FindProcShort (glBindTextureUnit)
1475 && FindProcShort (glGetTextureImage)
1476 && FindProcShort (glGetCompressedTextureImage)
1477 && FindProcShort (glGetTextureLevelParameterfv)
1478 && FindProcShort (glGetTextureLevelParameteriv)
1479 && FindProcShort (glGetTextureParameterfv)
1480 && FindProcShort (glGetTextureParameterIiv)
1481 && FindProcShort (glGetTextureParameterIuiv)
1482 && FindProcShort (glGetTextureParameteriv)
1483 && FindProcShort (glCreateVertexArrays)
1484 && FindProcShort (glDisableVertexArrayAttrib)
1485 && FindProcShort (glEnableVertexArrayAttrib)
1486 && FindProcShort (glVertexArrayElementBuffer)
1487 && FindProcShort (glVertexArrayVertexBuffer)
1488 && FindProcShort (glVertexArrayVertexBuffers)
1489 && FindProcShort (glVertexArrayAttribBinding)
1490 && FindProcShort (glVertexArrayAttribFormat)
1491 && FindProcShort (glVertexArrayAttribIFormat)
1492 && FindProcShort (glVertexArrayAttribLFormat)
1493 && FindProcShort (glVertexArrayBindingDivisor)
1494 && FindProcShort (glGetVertexArrayiv)
1495 && FindProcShort (glGetVertexArrayIndexediv)
1496 && FindProcShort (glGetVertexArrayIndexed64iv)
1497 && FindProcShort (glCreateSamplers)
1498 && FindProcShort (glCreateProgramPipelines)
1499 && FindProcShort (glCreateQueries)
1500 && FindProcShort (glGetQueryBufferObjecti64v)
1501 && FindProcShort (glGetQueryBufferObjectiv)
1502 && FindProcShort (glGetQueryBufferObjectui64v)
1503 && FindProcShort (glGetQueryBufferObjectuiv)
1504 && FindProcShort (glMemoryBarrierByRegion)
1505 && FindProcShort (glGetTextureSubImage)
1506 && FindProcShort (glGetCompressedTextureSubImage)
1507 && FindProcShort (glGetGraphicsResetStatus)
1508 && FindProcShort (glGetnCompressedTexImage)
1509 && FindProcShort (glGetnTexImage)
1510 && FindProcShort (glGetnUniformdv)
1511 && FindProcShort (glGetnUniformfv)
1512 && FindProcShort (glGetnUniformiv)
1513 && FindProcShort (glGetnUniformuiv)
1514 && FindProcShort (glReadnPixels)
1515 && FindProcShort (glGetnMapdv)
1516 && FindProcShort (glGetnMapfv)
1517 && FindProcShort (glGetnMapiv)
1518 && FindProcShort (glGetnPixelMapfv)
1519 && FindProcShort (glGetnPixelMapuiv)
1520 && FindProcShort (glGetnPixelMapusv)
1521 && FindProcShort (glGetnPolygonStipple)
1522 && FindProcShort (glGetnColorTable)
1523 && FindProcShort (glGetnConvolutionFilter)
1524 && FindProcShort (glGetnSeparableFilter)
1525 && FindProcShort (glGetnHistogram)
1526 && FindProcShort (glGetnMinmax)
1527 && FindProcShort (glTextureBarrier);
1528 if (has45)
1529 {
1530 theCtx.core45 = (OpenGl_GlCore45* )this;
e70625d6 1531 theCtx.arbClipControl = true;
e44b849d 1532 }
1533 else
1534 {
1535 theCtx.checkWrongVersion (4, 5, aLastFailedProc);
1536 }
1537
952a0565 1538 has46 = isGlGreaterEqualShort (4, 6)
1539 && FindProcShort (glSpecializeShader)
1540 && FindProcShort (glMultiDrawArraysIndirectCount)
1541 && FindProcShort (glMultiDrawElementsIndirectCount)
1542 && FindProcShort (glPolygonOffsetClamp);
1543 if (has46)
1544 {
1545 theCtx.core46 = (OpenGl_GlCore46* )this;
952a0565 1546 }
1547 else
1548 {
1549 theCtx.checkWrongVersion (4, 6, aLastFailedProc);
1550 }
1551
e44b849d 1552 // initialize debug context extension
1553 if (checkExtensionShort ("GL_ARB_debug_output"))
1554 {
1555 theCtx.arbDbg = NULL;
1556 if (has43)
1557 {
1558 theCtx.arbDbg = (OpenGl_ArbDbg* )this;
1559 }
1560 else if (theCtx.FindProc ("glDebugMessageControlARB", this->glDebugMessageControl)
1561 && theCtx.FindProc ("glDebugMessageInsertARB", this->glDebugMessageInsert)
1562 && theCtx.FindProc ("glDebugMessageCallbackARB", this->glDebugMessageCallback)
1563 && theCtx.FindProc ("glGetDebugMessageLogARB", this->glGetDebugMessageLog))
1564 {
1565 theCtx.arbDbg = (OpenGl_ArbDbg* )this;
1566 }
1567 }
1568
1569 // initialize FBO extension (ARB)
1570 if (hasFBO)
1571 {
1572 theCtx.arbFBO = (OpenGl_ArbFBO* )this;
1573 theCtx.arbFBOBlit = (OpenGl_ArbFBOBlit* )this;
1574 theCtx.extPDS = Standard_True; // extension for EXT, but part of ARB
1575 }
1576
1577 // initialize GS extension (EXT)
1578 if (checkExtensionShort ("GL_EXT_geometry_shader4")
1579 && FindProcShort (glProgramParameteriEXT))
1580 {
1581 theCtx.extGS = (OpenGl_ExtGS* )this;
1582 }
1583
1584 // initialize bindless texture extension (ARB)
1585 if (checkExtensionShort ("GL_ARB_bindless_texture")
1586 && FindProcShort (glGetTextureHandleARB)
1587 && FindProcShort (glGetTextureSamplerHandleARB)
1588 && FindProcShort (glMakeTextureHandleResidentARB)
1589 && FindProcShort (glMakeTextureHandleNonResidentARB)
1590 && FindProcShort (glGetImageHandleARB)
1591 && FindProcShort (glMakeImageHandleResidentARB)
1592 && FindProcShort (glMakeImageHandleNonResidentARB)
1593 && FindProcShort (glUniformHandleui64ARB)
1594 && FindProcShort (glUniformHandleui64vARB)
1595 && FindProcShort (glProgramUniformHandleui64ARB)
1596 && FindProcShort (glProgramUniformHandleui64vARB)
1597 && FindProcShort (glIsTextureHandleResidentARB)
1598 && FindProcShort (glIsImageHandleResidentARB)
1599 && FindProcShort (glVertexAttribL1ui64ARB)
1600 && FindProcShort (glVertexAttribL1ui64vARB)
1601 && FindProcShort (glGetVertexAttribLui64vARB))
1602 {
1603 theCtx.arbTexBindless = (OpenGl_ArbTexBindless* )this;
1604 }
1605
e70625d6 1606 if (!has45
1607 && checkExtensionShort ("GL_ARB_clip_control")
1608 && FindProcShort (glClipControl))
1609 {
1610 theCtx.arbClipControl = true;
1611 }
1612
e44b849d 1613 if (has30)
1614 {
1615 if (!has32
1616 && checkExtensionShort ("GL_ARB_texture_multisample")
1617 && FindProcShort (glTexImage2DMultisample))
1618 {
1619 //
1620 }
1621 if (!has43
1622 && checkExtensionShort ("GL_ARB_texture_storage_multisample")
1623 && FindProcShort (glTexStorage2DMultisample))
1624 {
1625 //
1626 }
1627 }
1628#endif
1629}