Gamp v0.0.7-54-gccdc599
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#include <string_view>
29
30namespace gamp::render::gl {
31 using namespace gamp::render;
32
33 /** @defgroup Gamp_GL Gamp GL Rendering
34 * OpenGL managed rendering support, data handling and GLSL functionality.
35 *
36 * @{
37 */
38
39 /**
40 * Specifies the OpenGL profile.
41 */
42 class GLProfile : public RenderProfile {
43 public:
44 /** The desktop OpenGL compatibility profile 4.x, with x >= 0, ie GL2 plus GL4.<br>
45 <code>bc</code> stands for backward compatibility. */
46 constexpr static std::string_view GL4bc = "GL4bc";
47
48 /** The desktop OpenGL core profile 4.x, with x >= 0 */
49 constexpr static std::string_view GL4 = "GL4";
50
51 /** The desktop OpenGL compatibility profile 3.x, with x >= 1, ie GL2 plus GL3.<br>
52 <code>bc</code> stands for backward compatibility. */
53 constexpr static std::string_view GL3bc = "GL3bc";
54
55 /** The desktop OpenGL core profile 3.x, with x >= 1 */
56 constexpr static std::string_view GL3 = "GL3";
57
58 /** The desktop OpenGL profile 1.x up to 3.0 */
59 constexpr static std::string_view GL2 = "GL2";
60
61 /** The embedded OpenGL profile ES 1.x, with x >= 0 */
62 constexpr static std::string_view GLES1 = "GLES1";
63
64 /** The embedded OpenGL profile ES 2.x, with x >= 0 */
65 constexpr static std::string_view GLES2 = "GLES2";
66
67 /** The embedded OpenGL profile ES 3.x, with x >= 0 */
68 constexpr static std::string_view GLES3 = "GLES3";
69
70 /** The default profile, used for the device default profile map */
71 constexpr static std::string_view GL_UNDEF = "undef";
72
73 constexpr static bool isValidTag(std::string_view tag) noexcept {
74 return GL4 == tag ||
75 GL4bc == tag ||
76 GL3 == tag ||
77 GL3bc == tag ||
78 GL2 == tag ||
79 GLES3 == tag ||
80 GLES2 == tag ||
81 GLES1 == tag;
82 }
83
84 private:
85 constexpr static std::string_view mapProfile2Tag(const jau::util::VersionNumber& version, GLProfileMask mask) noexcept {
86 if( 1 != jau::ct_bit_count( number(mask) ) ) {
87 ERR_PRINT("GLProfileMask %s invalid, should have exactly 1 bit set", to_string(mask).c_str());
88 }
89 if ( has_any(mask, GLProfileMask::es) ) {
90 if( version.major() < 2 ) {
91 return GLES1;
92 } else if( version.major() < 3 ) {
93 return GLES2;
94 } else {
95 return GLES3;
96 }
97 }
98 if( version.major() < 3 || ( version.major() == 3 && version.minor() < 1 ) ) {
99 return GL2;
100 } else if( version.major() < 4 ) {
101 if ( has_any(mask, GLProfileMask::compat) ) {
102 return GL3bc;
103 } else { // if ( has_any(mask, GLProfileMask::core) )
104 return GL3;
105 }
106 }
107 // else if( version.major() < 4 )
108 if ( has_any(mask, GLProfileMask::compat) ) {
109 return GL4bc;
110 }
111 // else if ( has_any(mask, GLProfileMask::core) )
112 return GL4;
113 }
114 constexpr jau::util::VersionNumber mapTag2Version(std::string_view tag) noexcept {
115 if( GL4 == tag || GL4bc == tag ) {
116 return Version4_0;
117 } else if( GL3 == tag || GL3bc == tag ) {
118 return Version3_1;
119 } else if( GL2 == tag ) {
120 return Version2_0;
121 } else if( GLES3 == tag ) {
122 return Version3_0;
123 } else if( GLES2 == tag ) {
124 return Version2_0;
125 } else if( GLES1 == tag ) {
126 return Version1_0;
127 }
128 return Version0_0;
129 }
130 constexpr GLProfileMask mapTag2Mask(std::string_view tag) noexcept {
131 if( GL4 == tag ) {
132 return GLProfileMask::core;
133 } else if( GL4bc == tag ) {
135 } else if( GL3 == tag ) {
136 return GLProfileMask::core;
137 } else if( GL3bc == tag ) {
139 } else if( GL2 == tag ) {
141 } else if( GLES3 == tag ) {
142 return GLProfileMask::es;
143 } else if( GLES2 == tag ) {
144 return GLProfileMask::es;
145 } else if( GLES1 == tag ) {
146 return GLProfileMask::es;
147 }
148 return GLProfileMask::none;
149 }
150 GLProfileMask m_profileMask;
151 jau::util::VersionNumber m_glslVersion;
152
153 protected:
154 void clear() noexcept override {
156 m_profileMask = GLProfileMask::none;
157 m_glslVersion = jau::util::VersionNumber();
158 }
159
160 public:
161 constexpr GLProfile() noexcept : RenderProfile(), m_profileMask(GLProfileMask::none), m_glslVersion() {}
162
163 /** Create a new instance.*/
165 : RenderProfile(mapProfile2Tag(version, profileMask), version),
166 m_profileMask(profileMask),
168 {}
169
170 /** Create a new instance, merely deriving from given tag.*/
171 constexpr GLProfile(std::string_view tag) noexcept
172 : RenderProfile(tag, mapTag2Version(tag)),
173 m_profileMask(mapTag2Mask(tag)),
174 m_glslVersion(getGLSLVersionNumber(RenderProfile::version(), m_profileMask))
175 {}
176
177 static const jau::type_info& GLSignature() noexcept { return jau::static_ctti<GLProfile>(); }
178 const jau::type_info& signature() const noexcept override { return GLSignature(); }
179
180 constexpr bool isValid() const noexcept { return GLProfile::isValidTag(name()); }
181
182 /// Downcast dereferenced given `const RenderProfile&` to `const GLProfile&`, throws exception if signature doesn't match GLSignature()
183 static const GLProfile& downcast(const RenderProfile& rp) {
184 if( rp.signature() == GLSignature() ) {
185 return static_cast<const GLProfile&>(rp);
186 }
187 throw jau::IllegalArgumentError("Not a GLProfile: "+rp.toString(), E_FILE_LINE);
188 }
189
190 constexpr const jau::util::VersionNumber& glslVersion() const noexcept { return m_glslVersion; }
191 constexpr GLProfileMask profileMask() const noexcept { return m_profileMask; }
192
193 /** Indicates whether this profile is capable of GL4bc. <p>Includes [ GL4bc ].</p> */
194 constexpr bool isGL4bc() const noexcept {
195 return GL4bc == name();
196 }
197
198 /** Indicates whether this profile is capable of GL4 core (only). <p>Includes [ GL4 ].</p> */
199 constexpr bool isGL4core() const noexcept {
200 return GL4 == name();
201 }
202
203 /** Indicates whether this profile is capable of GL4. <p>Includes [ GL4bc, GL4 ].</p> */
204 constexpr bool isGL4() const noexcept {
205 return isGL4bc() || isGL4core();
206 }
207
208 /** Indicates whether this profile is capable of GL3bc. <p>Includes [ GL4bc, GL3bc ].</p> */
209 constexpr bool isGL3bc() const noexcept {
210 return isGL4bc() || GL3bc == name();
211 }
212
213 /** Indicates whether this profile is capable of GL3 core (only). <p>Includes [ GL4, GL3 ].</p> */
214 constexpr bool isGL3core() const noexcept {
215 return isGL4core() || GL3 == name();
216 }
217
218 /** Indicates whether this profile is capable of GL3. <p>Includes [ GL4bc, GL4, GL3bc, GL3 ].</p> */
219 constexpr bool isGL3() const noexcept {
220 return isGL4() || isGL3bc() || GL3 == name();
221 }
222
223 /** Indicates whether this profile is capable of GL2 . <p>Includes [ GL4bc, GL3bc, GL2 ].</p> */
224 constexpr bool isGL2() const noexcept {
225 return isGL3bc() || GL2 == name();
226 }
227
228 /** Indicates whether this profile is capable of GLES1. <p>Includes [ GLES1 ].</p> */
229 constexpr bool isGLES1() const noexcept {
230 return GLES1 == name();
231 }
232
233 /** Indicates whether this profile is capable of GLES2. <p>Includes [ GLES2, GLES3 ].</p> */
234 constexpr bool isGLES2() const noexcept {
235 return isGLES3() || GLES2 == name();
236 }
237
238 /** Indicates whether this profile is capable of GLES3. <p>Includes [ GLES3 ].</p> */
239 constexpr bool isGLES3() const noexcept {
240 return GLES3 == name();
241 }
242
243 /** Indicates whether this profile is capable of GLES. <p>Includes [ GLES1, GLES2, GLES3 ].</p> */
244 constexpr bool isGLES() const noexcept {
245 return GLES3 == name() || GLES2 == name() || GLES1 == name();
246 }
247
248 /**
249 * Indicates whether this profile is capable of GL2ES1.
250 *
251 * Includes [ GL4bc, GL3bc, GL2, GLES1, GL2ES1 ].
252 *
253 * GL2ES1 is the intersection of the desktop GL2 and embedded ES1 profile.
254 */
255 constexpr bool isGL2ES1() const noexcept {
256 return isGLES1() || isGL2();
257 }
258
259 /**
260 * Indicates whether this profile is capable of GL2GL3.
261 *
262 * Includes [ GL4bc, GL4, GL3bc, GL3, GL2, GL2GL3 ].
263 *
264 * GL2GL3 is the intersection of the desktop GL2 and GL3 profile.
265 */
266 constexpr bool isGL2GL3() const noexcept {
267 return isGL3() || isGL2();
268 }
269
270 /**
271 * Indicates whether this profile is capable of GL2ES2.
272 *
273 * Includes [ GL4bc, GL4, GL3bc, GL3, GLES3, GL2, GL2GL3, GL2ES2, GLES2 ].
274 *
275 * GL2ES2 is the intersection of the desktop GL2 and embedded ES2 profile.
276 */
277 constexpr bool isGL2ES2() const noexcept {
278 return isGLES2() || isGL2GL3();
279 }
280
281 /**
282 * Indicates whether this profile is capable of GL2ES3.
283 *
284 * Includes [ GL4bc, GL4, GL3bc, GL3, GLES3, GL3ES3, GL2, GL2GL3 ].
285 *
286 * GL2ES3 is the intersection of the desktop GL2 and embedded ES3 profile.
287 * @see #isGL3ES3()
288 * @see #isGL2GL3()
289 */
290 constexpr bool isGL2ES3() const noexcept {
291 return isGL3ES3() || isGL2GL3();
292 }
293
294 /**
295 * Indicates whether this GL object uses a GL core profile. <p>Includes [ GL4, GL3, GLES3, GL2ES2 ].</p>
296 * @see #isGLES3()
297 * @see #isGLES2()
298 * @see #isGL3core()
299 */
300 constexpr bool isGLcore() const noexcept {
301 return isGLES3() || isGLES2() || isGL3core();
302 }
303
304 /**
305 * Indicates whether this profile is capable of GL3ES3.
306 *
307 * Includes [ GL4bc, GL4, GL3bc, GL3, GLES3 ].
308 *
309 * GL3ES3 is the intersection of the desktop GL3 and embedded ES3 profile.
310 */
311 constexpr bool isGL3ES3() const noexcept {
312 return isGL4ES3() || isGL3();
313 }
314
315 /** Indicates whether this profile is capable of GL4ES3. <p>Includes [ GL4bc, GL4, GLES3 ].</p> */
316 constexpr bool isGL4ES3() const noexcept {
317 return isGLES3() || isGL4();
318 }
319
320 /** Indicates whether this profile supports GLSL, i.e. `nativeGLES2() || ( !nativeGLES() && m_version.major()>1 )`. */
321 constexpr bool hasGLSL() const noexcept {
322 return nativeGLES2() ||
323 ( !nativeGLES() && version().major()>1 );
324 }
325
326 /**
327 * Indicates whether the native OpenGL ES1 profile is in use.
328 * This requires an EGL interface.
329 */
330 constexpr bool nativeGLES1() const noexcept {
331 return nativeGLES() && version().major() < 2;
332 }
333
334 /**
335 * Indicates whether the native OpenGL ES3 or ES2 profile is in use.
336 * This requires an EGL, ES3 or ES2 compatible interface.
337 */
338 constexpr bool nativeGLES2() const noexcept {
339 return nativeGLES() && version().major() > 1;
340 }
341
342 /**
343 * Indicates whether the native OpenGL ES2 profile is in use.
344 * This requires an EGL, ES3 compatible interface.
345 */
346 constexpr bool nativeGLES3() const noexcept {
347 return nativeGLES() && version().major() > 2;
348 }
349
350 /** Indicates whether either of the native OpenGL ES profiles are in use. */
351 constexpr bool nativeGLES() const noexcept {
353 }
354
355 /** Indicates whether either of the native OpenGL core profiles are in use. */
356 constexpr bool nativeGLCore() const noexcept {
358 }
359
360 /** Indicates whether either of the native OpenGL compatibility profiles are in use. */
361 constexpr bool nativeGLCompat() const noexcept {
363 }
364
365 /**
366 * General validation if type is a valid GL data type for the current profile.
367 * <p>
368 * Disclaimer: The validation might not satisfy updated OpenGL specifications.
369 * </p>
370 */
371 constexpr bool isValidDataType(GLenum type) const noexcept {
372 switch(type) {
373 case GL_UNSIGNED_BYTE:
374 case GL_BYTE:
375 case GL_UNSIGNED_SHORT:
376 case GL_SHORT:
377 case GL_FLOAT:
378 case GL_FIXED:
379 return true;
380 case GL_INT:
381 case GL_UNSIGNED_INT:
382 if( isGL2ES2() ) {
383 return true;
384 }
385 case GL_DOUBLE:
386 if( isGL3() ) {
387 return true;
388 }
389 case GL_2_BYTES:
390 case GL_3_BYTES:
391 case GL_4_BYTES:
392 if( isGL2() ) {
393 return true;
394 }
395 default: break;
396 }
397 return false;
398 }
399
400 /**
401 * General validation if index, comps and type are valid for the current profile.
402 * <p>
403 * Disclaimer: The validation might not satisfy updated OpenGL specifications.
404 * </p>
405 */
406 bool isValidArrayDataType(GLenum index, GLsizei comps, GLenum type,
407 bool isVertexAttribPointer, bool throwException) const;
408
409 /**
410 * Returns the GLSL version string as to be used in a shader program, including a terminating newline '\n',
411 * i.e. for desktop
412 * <pre>
413 * #version 110
414 * ..
415 * #version 150 core
416 * #version 330 compatibility
417 * ...
418 * </pre>
419 * And for ES:
420 * <pre>
421 * #version 100
422 * #version 300 es
423 * ..
424 * </pre>
425 * <p>
426 * If context has not been made current yet, a string of zero length is returned.
427 * </p>
428 * @see #getGLSLVersionNumber()
429 */
430 std::string getGLSLVersionString() const {
431
432 if( m_glslVersion.isZero() ) {
433 return "";
434 }
435 const int minor = m_glslVersion.minor();
436 std::string profileOpt;
437 if( has_any(m_profileMask, GLProfileMask::es) ) {
438 profileOpt = m_glslVersion >= Version3_0 ? " es" : "";
439 } else if( has_any(m_profileMask, GLProfileMask::core) ) {
440 profileOpt = m_glslVersion >= Version1_50 ? " core" : "";
441 } else if( has_any(m_profileMask, GLProfileMask::compat) ) {
442 profileOpt = m_glslVersion >= Version1_50 ? " compatibility" : "";
443 } else {
444 profileOpt = ""; // unreachable, pre-validate
445 }
446 return "#version " + std::to_string(m_glslVersion.major()) + (minor < 10 ? "0" + std::to_string(minor) : std::to_string(minor)) + profileOpt + "\n";
447 }
448
449 std::string toString() const override {
450 return std::string("GLProfile[")
451 .append(name()).append(" ").append(version().toString()).append(", ")
452 .append(to_string(profileMask())).append(", glsl ").append(m_glslVersion.toString()).append("]");
453 }
454 };
455
456 /** OpenGL Rendering Context */
457 class GLContext : public RenderContext {
458 protected:
459 struct Private { explicit Private() = default; };
460
461 private:
462 static thread_local GLContext* m_current;
463 GLProfile m_glprofile;
464 GLVersionNumber m_glversion;
465
466 static bool makeCurrentImpl(const gamp::wt::SurfaceRef& s, gamp::handle_t context) noexcept;
467 static void releaseContextImpl(const gamp::wt::SurfaceRef& s) noexcept;
468
469 public:
470 /** Private: Create an invalid instance.*/
472
473 /** Private: Create a new instance of a non-current context. Given profile tag must be one of this class' constant `GL` profiles. */
477 m_glprofile(std::move(profile)), m_glversion(std::move(glVersion)) {}
478
479 /** Private: Create a new instance of a current context. Given profile tag must be one of this class' constant `GL` profiles. */
483 m_glprofile(std::move(profile)), m_glversion(std::move(glVersion))
484 {
485 RenderContext::makeCurrent(surface); // -> m_surface
486 m_current = this;
487 }
488
489 ~GLContext() noexcept override {
490 if( isCurrent() ) {
491 m_current = nullptr;
492 }
493 }
494
495 /** Create a new instance of a non-current context. Given profile tag must be one of this class' constant `GL` profiles. */
497 RenderContextFlags contextFlags, const char* gl_version_cstr) noexcept
498 {
499 return std::make_unique<GLContext>(Private(), context, std::move(profile), contextFlags, GLVersionNumber::create(gl_version_cstr));
500 }
501 /** Create a new instance of a current. Given profile tag must be one of this class' constant `GL` profiles. */
503 RenderContextFlags contextFlags, const char* gl_version_cstr) noexcept
504 {
505 return std::make_unique<GLContext>(Private(), surface, context, std::move(profile), contextFlags, GLVersionNumber::create(gl_version_cstr));
506 }
507
508 const jau::type_info& signature() const noexcept override { return GLSignature(); }
509 static const jau::type_info& GLSignature() noexcept { return jau::static_ctti<GLContext>(); }
510
511 constexpr const RenderProfile& renderProfile() const noexcept override { return m_glprofile; }
512 constexpr const GLProfile& glProfile() const noexcept { return m_glprofile; }
513
514 constexpr const GLVersionNumber& glVersion() const { return m_glversion; }
515
516 /// Returns an invalid GLContext reference
517 static GLContext& getInvalid() noexcept {
518 static GLContext a( (Private()) );
519 return a;
520 }
521 /// Downcast dereferenced given `RenderContext*` to `GLContext&`, throws exception if signature doesn't match GLSignature()
523 if( rc ) {
524 if( rc->signature() == GLSignature() ) {
525 return static_cast<GLContext&>(*rc);
526 }
527 throw jau::IllegalArgumentError("Not a GLContext: "+rc->toString(), E_FILE_LINE);
528 }
529 throw jau::IllegalArgumentError("Null context", E_FILE_LINE);
530 }
531
532 /// Return thread local GLContext or an invalid GLContext, see isValid()
533 static GLContext& getCurrent() noexcept {
534 if( nullptr != m_current ) {
535 return *m_current;
536 }
537 return getInvalid();
538 }
539 bool makeCurrent(const gamp::wt::SurfaceRef& s) noexcept override {
540 if( makeCurrentImpl(s, context()) ) {
541 RenderContext::makeCurrent(s); // -> m_surface
542 m_current = this;
543 return true;
544 }
545 return false;
546 }
547 void releaseContext() noexcept override {
548 releaseContextImpl(m_surface);
549 RenderContext::releaseContext(); // -> m_surface
550 m_current = nullptr;
551 }
552 bool isCurrent() const noexcept { return this == m_current; }
553
554 bool isExtensionAvailable(GLenum name) const noexcept {
555 (void)name; // FIXME
556 return false;
557 }
558 bool isExtensionAvailable(std::string_view name) const noexcept {
559 (void)name; // FIXME
560 return false;
561 }
562 bool isExtensionAvailable(const char* name) const noexcept {
563 (void)name; // FIXME
564 return false;
565 }
566
567 bool isNPOTTextureAvailable() const noexcept { return true; }
568
569 void dispose() noexcept override;
570
571 void disposedNotify() override {
573 if( isCurrent() ) {
574 m_current = nullptr;
575 }
576 }
577
578 std::string toString() const override {
579 return std::string("GL[")
580 .append(jau::toHexString(context())).append(", ")
581 .append(to_string(contextFlags())).append(", ")
582 .append(glProfile().toString()).append(", ")
583 .append(glVersion().toString()).append(" -> surface ")
584 .append(m_surface?jau::toHexString(m_surface->surfaceHandle()):"nil").append("]");
585 }
586
587 };
588 typedef GLContext GL;
589
590 /**@}*/
591
592} // namespace gamp::render::gl
593
594
595#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.
constexpr const std::string_view name() const noexcept
virtual std::string toString() const
constexpr const jau::util::VersionNumber & version() 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(Private, gamp::handle_t context, GLProfile &&profile, RenderContextFlags contextFlags, GLVersionNumber &&glVersion) noexcept
Private: Create a new instance of a non-current context.
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.
~GLContext() noexcept override
bool isExtensionAvailable(std::string_view name) const noexcept
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.
bool makeCurrent(const gamp::wt::SurfaceRef &s) noexcept override
Make this context current (used for OpenGL, but a NOP on Vulkan)
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.
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.
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
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
std::string toString() const override
constexpr const GLVersionNumber & glVersion() const
bool isNPOTTextureAvailable() const noexcept
constexpr const RenderProfile & renderProfile() const noexcept override
static const jau::type_info & GLSignature() noexcept
Specifies the OpenGL profile.
Definition GLContext.hpp:42
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:62
constexpr GLProfileMask profileMask() const noexcept
static constexpr std::string_view GL3
The desktop OpenGL core profile 3.x, with x >= 1.
Definition GLContext.hpp:56
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:59
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:68
static constexpr std::string_view GL4
The desktop OpenGL core profile 4.x, with x >= 0.
Definition GLContext.hpp:49
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 isGL3core() const noexcept
Indicates whether this profile is capable of GL3 core (only).
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 isGLcore() const noexcept
Indicates whether this GL object uses a GL core profile.
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:71
static constexpr bool isValidTag(std::string_view tag) noexcept
Definition GLContext.hpp:73
static constexpr std::string_view GLES2
The embedded OpenGL profile ES 2.x, with x >= 0.
Definition GLContext.hpp:65
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:53
constexpr bool isValid() const noexcept
constexpr bool isGL4core() const noexcept
Indicates whether this profile is capable of GL4 core (only).
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:46
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:122
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 toHexString(const void *data, const nsize_t length, const lb_endian_t byteOrder=lb_endian_t::big, const LoUpCase capitalization=LoUpCase::lower, const PrefixOpt prefix=PrefixOpt::prefix) noexcept
Produce a hexadecimal string representation of the given lsb-first byte values.