Gamp v0.0.7-36-g24b1eb6
Gamp: Graphics, Audio, Multimedia and Processing
Loading...
Searching...
No Matches
GLContext.hpp
Go to the documentation of this file.
1/*
2 * Author: Sven Gothel <sgothel@jausoft.com>
3 * Copyright Gothel Software e.K.
4 *
5 * SPDX-License-Identifier: MIT
6 *
7 * This Source Code Form is subject to the terms of the MIT License
8 * If a copy of the MIT was not distributed with this file,
9 * you can obtain one at https://opensource.org/license/mit/.
10 */
11
12#ifndef GAMP_GLPROFILE_HPP_
13#define GAMP_GLPROFILE_HPP_
14
15#include <jau/basic_types.hpp>
16#include <jau/int_math_ct.hpp>
17#include <jau/int_types.hpp>
18#include <jau/float_types.hpp>
19#include <jau/string_util.hpp>
21
22#include <gamp/GampTypes.hpp>
27#include <gamp/wt/Surface.hpp>
28
29namespace gamp::render::gl {
30 using namespace gamp::render;
31
32 /** @defgroup Gamp_GL Gamp GL Rendering
33 * OpenGL managed rendering support, data handling and GLSL functionality.
34 *
35 * @{
36 */
37
38 /**
39 * Specifies the OpenGL profile.
40 */
41 class GLProfile : public RenderProfile {
42 public:
43 /** The desktop OpenGL compatibility profile 4.x, with x >= 0, ie GL2 plus GL4.<br>
44 <code>bc</code> stands for backward compatibility. */
45 constexpr static std::string_view GL4bc = "GL4bc";
46
47 /** The desktop OpenGL core profile 4.x, with x >= 0 */
48 constexpr static std::string_view GL4 = "GL4";
49
50 /** The desktop OpenGL compatibility profile 3.x, with x >= 1, ie GL2 plus GL3.<br>
51 <code>bc</code> stands for backward compatibility. */
52 constexpr static std::string_view GL3bc = "GL3bc";
53
54 /** The desktop OpenGL core profile 3.x, with x >= 1 */
55 constexpr static std::string_view GL3 = "GL3";
56
57 /** The desktop OpenGL profile 1.x up to 3.0 */
58 constexpr static std::string_view GL2 = "GL2";
59
60 /** The embedded OpenGL profile ES 1.x, with x >= 0 */
61 constexpr static std::string_view GLES1 = "GLES1";
62
63 /** The embedded OpenGL profile ES 2.x, with x >= 0 */
64 constexpr static std::string_view GLES2 = "GLES2";
65
66 /** The embedded OpenGL profile ES 3.x, with x >= 0 */
67 constexpr static std::string_view GLES3 = "GLES3";
68
69 /** The default profile, used for the device default profile map */
70 constexpr static std::string_view GL_UNDEF = "undef";
71
72 private:
73 constexpr static std::string_view mapProfile2Tag(const jau::util::VersionNumber& version, GLProfileMask mask) noexcept {
74 if( 1 != jau::ct_bit_count( number(mask) ) ) {
75 ERR_PRINT("GLProfileMask %s invalid, should have exactly 1 bit set", to_string(mask).c_str());
76 }
77 if ( has_any(mask, GLProfileMask::es) ) {
78 if( version.major() < 2 ) {
79 return GLES1;
80 } else if( version.major() < 3 ) {
81 return GLES2;
82 } else {
83 return GLES3;
84 }
85 }
86 if( version.major() < 3 || ( version.major() == 3 && version.minor() < 1 ) ) {
87 return GL2;
88 } else if( version.major() < 4 ) {
89 if ( has_any(mask, GLProfileMask::compat) ) {
90 return GL3bc;
91 } else { // if ( has_any(mask, GLProfileMask::core) )
92 return GL3;
93 }
94 }
95 // else if( version.major() < 4 )
96 if ( has_any(mask, GLProfileMask::compat) ) {
97 return GL4bc;
98 }
99 // else if ( has_any(mask, GLProfileMask::core) )
100 return GL4;
101 }
102 constexpr jau::util::VersionNumber mapTag2Version(std::string_view tag) noexcept {
103 if( GL4 == tag || GL4bc == tag ) {
104 return Version4_0;
105 } else if( GL3 == tag || GL3bc == tag ) {
106 return Version3_1;
107 } else if( GL2 == tag ) {
108 return Version2_0;
109 } else if( GLES3 == tag ) {
110 return Version3_0;
111 } else if( GLES2 == tag ) {
112 return Version2_0;
113 } else if( GLES1 == tag ) {
114 return Version1_0;
115 }
116 return Version0_0;
117 }
118 constexpr GLProfileMask mapTag2Mask(std::string_view tag) noexcept {
119 if( GL4 == tag ) {
120 return GLProfileMask::core;
121 } else if( GL4bc == tag ) {
123 } else if( GL3 == tag ) {
124 return GLProfileMask::core;
125 } else if( GL3bc == tag ) {
127 } else if( GL2 == tag ) {
129 } else if( GLES3 == tag ) {
130 return GLProfileMask::es;
131 } else if( GLES2 == tag ) {
132 return GLProfileMask::es;
133 } else if( GLES1 == tag ) {
134 return GLProfileMask::es;
135 }
136 return GLProfileMask::none;
137 }
138 GLProfileMask m_profileMask;
139 jau::util::VersionNumber m_glslVersion;
140
141 protected:
142 void clear() noexcept override {
144 m_profileMask = GLProfileMask::none;
145 m_glslVersion = jau::util::VersionNumber();
146 }
147
148 public:
149 constexpr GLProfile() noexcept : RenderProfile(), m_profileMask(GLProfileMask::none), m_glslVersion() {}
150
151 /** Create a new instance.*/
153 : RenderProfile(mapProfile2Tag(version, profileMask), version),
154 m_profileMask(profileMask),
156 {}
157
158 /** Create a new instance, merely deriving from given tag.*/
159 constexpr GLProfile(std::string_view tag) noexcept
160 : RenderProfile(tag, mapTag2Version(tag)),
161 m_profileMask(mapTag2Mask(tag)),
162 m_glslVersion(getGLSLVersionNumber(RenderProfile::version(), m_profileMask))
163 {}
164
165 static const jau::type_info& GLSignature() noexcept { return jau::static_ctti<GLProfile>(); }
166 const jau::type_info& signature() const noexcept override { return GLSignature(); }
167
168 /// Downcast dereferenced given `const RenderProfile&` to `const GLProfile&`, throws exception if signature doesn't match GLSignature()
169 static const GLProfile& downcast(const RenderProfile& rp) {
170 if( rp.signature() == GLSignature() ) {
171 return static_cast<const GLProfile&>(rp);
172 }
173 throw jau::IllegalArgumentError("Not a GLProfile: "+rp.toString(), E_FILE_LINE);
174 }
175
176 constexpr const jau::util::VersionNumber& glslVersion() const noexcept { return m_glslVersion; }
177 constexpr GLProfileMask profileMask() const noexcept { return m_profileMask; }
178
179 /** Indicates whether this profile is capable of GL4bc. <p>Includes [ GL4bc ].</p> */
180 constexpr bool isGL4bc() const noexcept {
181 return GL4bc == name();
182 }
183
184 /** Indicates whether this profile is capable of GL4. <p>Includes [ GL4bc, GL4 ].</p> */
185 constexpr bool isGL4() const noexcept {
186 return isGL4bc() || GL4 == name();
187 }
188
189 /** Indicates whether this profile is capable of GL3bc. <p>Includes [ GL4bc, GL3bc ].</p> */
190 constexpr bool isGL3bc() const noexcept {
191 return isGL4bc() || GL3bc == name();
192 }
193
194 /** Indicates whether this profile is capable of GL3. <p>Includes [ GL4bc, GL4, GL3bc, GL3 ].</p> */
195 constexpr bool isGL3() const noexcept {
196 return isGL4() || isGL3bc() || GL3 == name();
197 }
198
199 /** Indicates whether this profile is capable of GL2 . <p>Includes [ GL4bc, GL3bc, GL2 ].</p> */
200 constexpr bool isGL2() const noexcept {
201 return isGL3bc() || GL2 == name();
202 }
203
204 /** Indicates whether this profile is capable of GLES1. <p>Includes [ GLES1 ].</p> */
205 constexpr bool isGLES1() const noexcept {
206 return GLES1 == name();
207 }
208
209 /** Indicates whether this profile is capable of GLES2. <p>Includes [ GLES2, GLES3 ].</p> */
210 constexpr bool isGLES2() const noexcept {
211 return isGLES3() || GLES2 == name();
212 }
213
214 /** Indicates whether this profile is capable of GLES3. <p>Includes [ GLES3 ].</p> */
215 constexpr bool isGLES3() const noexcept {
216 return GLES3 == name();
217 }
218
219 /** Indicates whether this profile is capable of GLES. <p>Includes [ GLES1, GLES2, GLES3 ].</p> */
220 constexpr bool isGLES() const noexcept {
221 return GLES3 == name() || GLES2 == name() || GLES1 == name();
222 }
223
224 /**
225 * Indicates whether this profile is capable of GL2ES1.
226 *
227 * Includes [ GL4bc, GL3bc, GL2, GLES1, GL2ES1 ].
228 *
229 * GL2ES1 is the intersection of the desktop GL2 and embedded ES1 profile.
230 */
231 constexpr bool isGL2ES1() const noexcept {
232 return isGLES1() || isGL2();
233 }
234
235 /**
236 * Indicates whether this profile is capable of GL2GL3.
237 *
238 * Includes [ GL4bc, GL4, GL3bc, GL3, GL2, GL2GL3 ].
239 *
240 * GL2GL3 is the intersection of the desktop GL2 and GL3 profile.
241 */
242 constexpr bool isGL2GL3() const noexcept {
243 return isGL3() || isGL2();
244 }
245
246 /**
247 * Indicates whether this profile is capable of GL2ES2.
248 *
249 * Includes [ GL4bc, GL4, GL3bc, GL3, GLES3, GL2, GL2GL3, GL2ES2, GLES2 ].
250 *
251 * GL2ES2 is the intersection of the desktop GL2 and embedded ES2 profile.
252 */
253 constexpr bool isGL2ES2() const noexcept {
254 return isGLES2() || isGL2GL3();
255 }
256
257 /**
258 * Indicates whether this profile is capable of GL2ES3.
259 *
260 * Includes [ GL4bc, GL4, GL3bc, GL3, GLES3, GL3ES3, GL2, GL2GL3 ].
261 *
262 * GL2ES3 is the intersection of the desktop GL2 and embedded ES3 profile.
263 * @see #isGL3ES3()
264 * @see #isGL2GL3()
265 */
266 constexpr bool isGL2ES3() const noexcept {
267 return isGL3ES3() || isGL2GL3();
268 }
269
270 /**
271 * Indicates whether this profile is capable of GL3ES3.
272 *
273 * Includes [ GL4bc, GL4, GL3bc, GL3, GLES3 ].
274 *
275 * GL3ES3 is the intersection of the desktop GL3 and embedded ES3 profile.
276 */
277 constexpr bool isGL3ES3() const noexcept {
278 return isGL4ES3() || isGL3();
279 }
280
281 /** Indicates whether this profile is capable of GL4ES3. <p>Includes [ GL4bc, GL4, GLES3 ].</p> */
282 constexpr bool isGL4ES3() const noexcept {
283 return isGLES3() || isGL4();
284 }
285
286 /** Indicates whether this profile supports GLSL, i.e. `nativeGLES2() || ( !nativeGLES() && m_version.major()>1 )`. */
287 constexpr bool hasGLSL() const noexcept {
288 return nativeGLES2() ||
289 ( !nativeGLES() && version().major()>1 );
290 }
291
292 /**
293 * Indicates whether the native OpenGL ES1 profile is in use.
294 * This requires an EGL interface.
295 */
296 constexpr bool nativeGLES1() const noexcept {
297 return nativeGLES() && version().major() < 2;
298 }
299
300 /**
301 * Indicates whether the native OpenGL ES3 or ES2 profile is in use.
302 * This requires an EGL, ES3 or ES2 compatible interface.
303 */
304 constexpr bool nativeGLES2() const noexcept {
305 return nativeGLES() && version().major() > 1;
306 }
307
308 /**
309 * Indicates whether the native OpenGL ES2 profile is in use.
310 * This requires an EGL, ES3 compatible interface.
311 */
312 constexpr bool nativeGLES3() const noexcept {
313 return nativeGLES() && version().major() > 2;
314 }
315
316 /** Indicates whether either of the native OpenGL ES profiles are in use. */
317 constexpr bool nativeGLES() const noexcept {
319 }
320
321 /** Indicates whether either of the native OpenGL core profiles are in use. */
322 constexpr bool nativeGLCore() const noexcept {
324 }
325
326 /** Indicates whether either of the native OpenGL compatibility profiles are in use. */
327 constexpr bool nativeGLCompat() const noexcept {
329 }
330
331 /**
332 * General validation if type is a valid GL data type for the current profile.
333 * <p>
334 * Disclaimer: The validation might not satisfy updated OpenGL specifications.
335 * </p>
336 */
337 constexpr bool isValidDataType(GLenum type) const noexcept {
338 switch(type) {
339 case GL_UNSIGNED_BYTE:
340 case GL_BYTE:
341 case GL_UNSIGNED_SHORT:
342 case GL_SHORT:
343 case GL_FLOAT:
344 case GL_FIXED:
345 return true;
346 case GL_INT:
347 case GL_UNSIGNED_INT:
348 if( isGL2ES2() ) {
349 return true;
350 }
351 case GL_DOUBLE:
352 if( isGL3() ) {
353 return true;
354 }
355 case GL_2_BYTES:
356 case GL_3_BYTES:
357 case GL_4_BYTES:
358 if( isGL2() ) {
359 return true;
360 }
361 default: break;
362 }
363 return false;
364 }
365
366 /**
367 * General validation if index, comps and type are valid for the current profile.
368 * <p>
369 * Disclaimer: The validation might not satisfy updated OpenGL specifications.
370 * </p>
371 */
372 bool isValidArrayDataType(GLenum index, GLsizei comps, GLenum type,
373 bool isVertexAttribPointer, bool throwException) const;
374
375 /**
376 * Returns the GLSL version string as to be used in a shader program, including a terminating newline '\n',
377 * i.e. for desktop
378 * <pre>
379 * #version 110
380 * ..
381 * #version 150 core
382 * #version 330 compatibility
383 * ...
384 * </pre>
385 * And for ES:
386 * <pre>
387 * #version 100
388 * #version 300 es
389 * ..
390 * </pre>
391 * <p>
392 * If context has not been made current yet, a string of zero length is returned.
393 * </p>
394 * @see #getGLSLVersionNumber()
395 */
396 std::string getGLSLVersionString() const {
397
398 if( m_glslVersion.isZero() ) {
399 return "";
400 }
401 const int minor = m_glslVersion.minor();
402 std::string profileOpt;
403 if( has_any(m_profileMask, GLProfileMask::es) ) {
404 profileOpt = m_glslVersion >= Version3_0 ? " es" : "";
405 } else if( has_any(m_profileMask, GLProfileMask::core) ) {
406 profileOpt = m_glslVersion >= Version1_50 ? " core" : "";
407 } else if( has_any(m_profileMask, GLProfileMask::compat) ) {
408 profileOpt = m_glslVersion >= Version1_50 ? " compatibility" : "";
409 } else {
410 profileOpt = ""; // unreachable, pre-validate
411 }
412 return "#version " + std::to_string(m_glslVersion.major()) + (minor < 10 ? "0" + std::to_string(minor) : std::to_string(minor)) + profileOpt + "\n";
413 }
414
415 std::string toString() const override {
416 return std::string("GLProfile[")
417 .append(name()).append(" ").append(version().toString()).append(", ")
418 .append(to_string(profileMask())).append(", glsl ").append(m_glslVersion.toString()).append("]");
419 }
420 };
421
422 /** OpenGL Rendering Context */
423 class GLContext : public RenderContext {
424 protected:
425 struct Private { explicit Private() = default; };
426
427 private:
428 static thread_local GLContext* m_current;
429 GLProfile m_glprofile;
430 GLVersionNumber m_glversion;
431
432 static bool makeCurrentImpl(const gamp::wt::SurfaceRef& s, gamp::handle_t context) noexcept;
433 static void releaseContextImpl(const gamp::wt::SurfaceRef& s) noexcept;
434
435 public:
436 /** Private: Create an invalid instance.*/
438
439 /** Private: Create a new instance of a non-current context. Given profile tag must be one of this class' constant `GL` profiles. */
443 m_glprofile(std::move(profile)), m_glversion(std::move(glVersion)) {}
444
445 /** Private: Create a new instance of a current context. Given profile tag must be one of this class' constant `GL` profiles. */
449 m_glprofile(std::move(profile)), m_glversion(std::move(glVersion))
450 {
451 RenderContext::makeCurrent(surface); // -> m_surface
452 m_current = this;
453 }
454
455 ~GLContext() noexcept override {
456 if( isCurrent() ) {
457 m_current = nullptr;
458 }
459 }
460
461 /** Create a new instance of a non-current context. Given profile tag must be one of this class' constant `GL` profiles. */
463 RenderContextFlags contextFlags, const char* gl_version_cstr) noexcept
464 {
465 return std::make_unique<GLContext>(Private(), context, std::move(profile), contextFlags, GLVersionNumber::create(gl_version_cstr));
466 }
467 /** Create a new instance of a current. Given profile tag must be one of this class' constant `GL` profiles. */
469 RenderContextFlags contextFlags, const char* gl_version_cstr) noexcept
470 {
471 return std::make_unique<GLContext>(Private(), surface, context, std::move(profile), contextFlags, GLVersionNumber::create(gl_version_cstr));
472 }
473
474 const jau::type_info& signature() const noexcept override { return GLSignature(); }
475 static const jau::type_info& GLSignature() noexcept { return jau::static_ctti<GLContext>(); }
476
477 constexpr const RenderProfile& renderProfile() const noexcept override { return m_glprofile; }
478 constexpr const GLProfile& glProfile() const noexcept { return m_glprofile; }
479
480 constexpr const GLVersionNumber& glVersion() const { return m_glversion; }
481
482 /// Returns an invalid GLContext reference
483 static GLContext& getInvalid() noexcept {
484 static GLContext a( (Private()) );
485 return a;
486 }
487 /// Downcast dereferenced given `RenderContext*` to `GLContext&`, throws exception if signature doesn't match GLSignature()
489 if( rc ) {
490 if( rc->signature() == GLSignature() ) {
491 return static_cast<GLContext&>(*rc);
492 }
493 throw jau::IllegalArgumentError("Not a GLContext: "+rc->toString(), E_FILE_LINE);
494 }
495 throw jau::IllegalArgumentError("Null context", E_FILE_LINE);
496 }
497
498 /// Return thread local GLContext or an invalid GLContext, see isValid()
499 static GLContext& getCurrent() noexcept {
500 if( nullptr != m_current ) {
501 return *m_current;
502 }
503 return getInvalid();
504 }
505 bool makeCurrent(const gamp::wt::SurfaceRef& s) noexcept override {
506 if( makeCurrentImpl(s, context()) ) {
507 RenderContext::makeCurrent(s); // -> m_surface
508 m_current = this;
509 return true;
510 }
511 return false;
512 }
513 void releaseContext() noexcept override {
514 releaseContextImpl(m_surface);
515 RenderContext::releaseContext(); // -> m_surface
516 m_current = nullptr;
517 }
518 bool isCurrent() const noexcept { return this == m_current; }
519
520 bool isExtensionAvailable(GLenum name) const noexcept {
521 (void)name; // FIXME
522 return false;
523 }
524 bool isExtensionAvailable(const char* name) const noexcept {
525 (void)name; // FIXME
526 return false;
527 }
528
529 void dispose() noexcept override;
530
531 void disposedNotify() override {
533 if( isCurrent() ) {
534 m_current = nullptr;
535 }
536 }
537
538 std::string toString() const override {
539 return std::string("GL[")
540 .append(jau::to_hexstring(context())).append(", ")
541 .append(to_string(contextFlags())).append(", ")
542 .append(glProfile().toString()).append(", ")
543 .append(glVersion().toString()).append(" -> surface ")
544 .append(m_surface?jau::to_hexstring(m_surface->surfaceHandle()):"nil").append("]");
545 }
546
547 };
548 typedef GLContext GL;
549
550 /**@}*/
551
552} // namespace gamp::render::gl
553
554
555#endif /* GAMP_GLPROFILE_HPP_ */
#define E_FILE_LINE
RenderContext(Private) noexcept
Private: Create an invalid instance.
virtual std::string toString() const
Definition gamp.cpp:62
gamp::wt::SurfaceRef m_surface
virtual const jau::type_info & signature() const noexcept
constexpr gamp::handle_t context() const noexcept
virtual void releaseContext() noexcept
Release this context (used for OpenGL, but a NOP on Vulkan)
constexpr RenderContextFlags contextFlags() const noexcept
virtual bool makeCurrent(const gamp::wt::SurfaceRef &s) noexcept
Make this context current (used for OpenGL, but a NOP on Vulkan)
Specifies the render profile.
virtual std::string toString() const
constexpr const jau::util::VersionNumber & version() const noexcept
constexpr const std::string_view & name() const noexcept
virtual void clear() noexcept
virtual const jau::type_info & signature() const noexcept
constexpr RenderProfile() noexcept
Create an undefined instance.
OpenGL Rendering Context.
~GLContext() noexcept override
GLContext(Private, const wt::SurfaceRef &surface, gamp::handle_t context, GLProfile profile, RenderContextFlags contextFlags, GLVersionNumber glVersion) noexcept
Private: Create a new instance of a current context.
bool makeCurrent(const gamp::wt::SurfaceRef &s) noexcept override
Make this context current (used for OpenGL, but a NOP on Vulkan)
const jau::type_info & signature() const noexcept override
bool isExtensionAvailable(GLenum name) const noexcept
bool isCurrent() const noexcept
static GLContext & getInvalid() noexcept
Returns an invalid GLContext reference.
GLContext(Private, gamp::handle_t context, GLProfile profile, RenderContextFlags contextFlags, GLVersionNumber glVersion) noexcept
Private: Create a new instance of a non-current context.
bool isExtensionAvailable(const char *name) const noexcept
GLContext(Private) noexcept
Private: Create an invalid instance.
void dispose() noexcept override
static GLContext & downcast(RenderContext *rc)
Downcast dereferenced given RenderContext* to GLContext&, throws exception if signature doesn't match...
void disposedNotify() override
static RenderContextPtr create(const wt::SurfaceRef &surface, gamp::handle_t context, GLProfile profile, RenderContextFlags contextFlags, const char *gl_version_cstr) noexcept
Create a new instance of a current.
void releaseContext() noexcept override
Release this context (used for OpenGL, but a NOP on Vulkan)
static GLContext & getCurrent() noexcept
Return thread local GLContext or an invalid GLContext, see isValid()
constexpr const GLProfile & glProfile() const noexcept
static RenderContextPtr create(gamp::handle_t context, GLProfile profile, RenderContextFlags contextFlags, const char *gl_version_cstr) noexcept
Create a new instance of a non-current context.
std::string toString() const override
constexpr const GLVersionNumber & glVersion() const
constexpr const RenderProfile & renderProfile() const noexcept override
static const jau::type_info & GLSignature() noexcept
Specifies the OpenGL profile.
Definition GLContext.hpp:41
constexpr bool isGLES1() const noexcept
Indicates whether this profile is capable of GLES1.
constexpr GLProfile() noexcept
constexpr bool nativeGLES2() const noexcept
Indicates whether the native OpenGL ES3 or ES2 profile is in use.
static constexpr std::string_view GLES1
The embedded OpenGL profile ES 1.x, with x >= 0.
Definition GLContext.hpp:61
constexpr GLProfileMask profileMask() const noexcept
static constexpr std::string_view GL3
The desktop OpenGL core profile 3.x, with x >= 1.
Definition GLContext.hpp:55
constexpr bool isGL2ES1() const noexcept
Indicates whether this profile is capable of GL2ES1.
std::string toString() const override
constexpr bool nativeGLCore() const noexcept
Indicates whether either of the native OpenGL core profiles are in use.
static constexpr std::string_view GL2
The desktop OpenGL profile 1.x up to 3.0.
Definition GLContext.hpp:58
bool isValidArrayDataType(GLenum index, GLsizei comps, GLenum type, bool isVertexAttribPointer, bool throwException) const
General validation if index, comps and type are valid for the current profile.
Definition gamp_gl.cpp:25
constexpr bool isGLES() const noexcept
Indicates whether this profile is capable of GLES.
constexpr bool isGL4() const noexcept
Indicates whether this profile is capable of GL4.
constexpr bool isGL2ES3() const noexcept
Indicates whether this profile is capable of GL2ES3.
constexpr bool nativeGLES1() const noexcept
Indicates whether the native OpenGL ES1 profile is in use.
void clear() noexcept override
constexpr bool isGL4ES3() const noexcept
Indicates whether this profile is capable of GL4ES3.
static constexpr std::string_view GLES3
The embedded OpenGL profile ES 3.x, with x >= 0.
Definition GLContext.hpp:67
static constexpr std::string_view GL4
The desktop OpenGL core profile 4.x, with x >= 0.
Definition GLContext.hpp:48
constexpr bool hasGLSL() const noexcept
Indicates whether this profile supports GLSL, i.e.
constexpr bool isGL3bc() const noexcept
Indicates whether this profile is capable of GL3bc.
const jau::type_info & signature() const noexcept override
constexpr const jau::util::VersionNumber & glslVersion() const noexcept
constexpr bool isGL2() const noexcept
Indicates whether this profile is capable of GL2 .
constexpr GLProfile(const jau::util::VersionNumber &version, GLProfileMask profileMask) noexcept
Create a new instance.
constexpr bool isGLES2() const noexcept
Indicates whether this profile is capable of GLES2.
std::string getGLSLVersionString() const
Returns the GLSL version string as to be used in a shader program, including a terminating newline ' ...
constexpr bool nativeGLES3() const noexcept
Indicates whether the native OpenGL ES2 profile is in use.
constexpr bool nativeGLCompat() const noexcept
Indicates whether either of the native OpenGL compatibility profiles are in use.
constexpr GLProfile(std::string_view tag) noexcept
Create a new instance, merely deriving from given tag.
constexpr bool isGL2GL3() const noexcept
Indicates whether this profile is capable of GL2GL3.
constexpr bool isValidDataType(GLenum type) const noexcept
General validation if type is a valid GL data type for the current profile.
constexpr bool isGL4bc() const noexcept
Indicates whether this profile is capable of GL4bc.
constexpr bool isGL3() const noexcept
Indicates whether this profile is capable of GL3.
static constexpr std::string_view GL_UNDEF
The default profile, used for the device default profile map.
Definition GLContext.hpp:70
static constexpr std::string_view GLES2
The embedded OpenGL profile ES 2.x, with x >= 0.
Definition GLContext.hpp:64
static const GLProfile & downcast(const RenderProfile &rp)
Downcast dereferenced given const RenderProfile& to const GLProfile&, throws exception if signature d...
static const jau::type_info & GLSignature() noexcept
constexpr bool isGL3ES3() const noexcept
Indicates whether this profile is capable of GL3ES3.
constexpr bool isGLES3() const noexcept
Indicates whether this profile is capable of GLES3.
static constexpr std::string_view GL3bc
The desktop OpenGL compatibility profile 3.x, with x >= 1, ie GL2 plus GL3.
Definition GLContext.hpp:52
constexpr bool nativeGLES() const noexcept
Indicates whether either of the native OpenGL ES profiles are in use.
constexpr bool isGL2ES2() const noexcept
Indicates whether this profile is capable of GL2ES2.
static constexpr std::string_view GL4bc
The desktop OpenGL compatibility profile 4.x, with x >= 0, ie GL2 plus GL4.
Definition GLContext.hpp:45
A class for storing and comparing OpenGL version numbers.
static GLVersionNumber create(const std::string &versionString) noexcept
Generic type information using either Runtime type information (RTTI) or Compile time type informatio...
Simple version number class containing a version number either being defined explicit or derived from...
constexpr int major() const noexcept
#define ERR_PRINT(...)
Use for unconditional error messages, prefix '[elapsed_time] Error @ FILE:LINE FUNC: '.
Definition debug.hpp:112
constexpr uint32_t ct_bit_count(uint32_t n) noexcept
Returns the number of set bits within given 32bit integer (w/o branching) in O(1) and constant time (...
consteval_cxx20 std::string_view name() noexcept
constexpr bool has_any(const E mask, const E bits) noexcept
constexpr std::underlying_type_t< E > number(const E v) noexcept
const jau::type_info & static_ctti() noexcept
Returns a static global reference of make_ctti<T>(true) w/ identity instance.
GLProfileMask
OpenGL profile-mask bits.
static constexpr jau::util::VersionNumber Version4_0
Version 4.0.
static constexpr jau::util::VersionNumber Version2_0
Version 2.0.
static constexpr jau::util::VersionNumber Version1_0
Version 1.00, i.e.
static constexpr jau::util::VersionNumber Version1_50
Version 1.50, i.e.
constexpr jau::util::VersionNumber getGLSLVersionNumber(const jau::util::VersionNumber &glVersion, GLProfileMask mask)
static constexpr jau::util::VersionNumber Version3_1
Version 3.1.
static constexpr jau::util::VersionNumber Version0_0
Version 0.00, i.e.
static constexpr jau::util::VersionNumber Version3_0
Version 3.0.
@ compat
Desktop compatibility profile.
@ core
Desktop core profile.
std::unique_ptr< RenderContext > RenderContextPtr
RenderContextFlags
OpenGL context flags.
std::shared_ptr< Surface > SurfaceRef
uintptr_t handle_t
A native handle type, big enough to store a pointer.
Definition GampTypes.hpp:47
std::string to_string(const math_error_t v) noexcept
Returns std::string representation of math_error_t.
std::string to_hexstring(value_type const &v, const bool skipLeading0x=false) noexcept
Produce a lower-case hexadecimal string representation with leading 0x in MSB of the given pointer.