From c4aa95a5956a9ae8eb633f0cf9fa9c6febf72129 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 18 May 2013 15:46:22 +0200 Subject: [PATCH] Initial support for context flags. --- src/Context.cpp | 10 ++++++++++ src/Context.h | 30 +++++++++++++++++++++++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/src/Context.cpp b/src/Context.cpp index 67818d458..9da905866 100644 --- a/src/Context.cpp +++ b/src/Context.cpp @@ -286,6 +286,16 @@ Context::Context() { #endif _version = static_cast(_majorVersion*100+_minorVersion*10); + /* Context flags are supported since GL 3.0 */ + #ifndef MAGNUM_TARGET_GLES + /** + * @todo According to KHR_debug specs this should be also present in ES2 + * if KHR_debug is available, but in headers it is nowhere to be found + */ + if(isVersionSupported(Version::GL300)) + glGetIntegerv(GL_CONTEXT_FLAGS, reinterpret_cast(&_flags)); + #endif + /* Get first future (not supported) version */ std::vector versions{ #ifndef MAGNUM_TARGET_GLES diff --git a/src/Context.h b/src/Context.h index 814ba770b..4e51c58cf 100644 --- a/src/Context.h +++ b/src/Context.h @@ -30,6 +30,7 @@ #include #include +#include #include "Magnum.h" #include "OpenGL.h" @@ -144,13 +145,36 @@ class MAGNUM_EXPORT Context { Context& operator=(Context&&) = delete; public: + /** + * @brief Context flag + * + * @see Flags, flags() + */ + enum class Flag: GLint { + #ifndef MAGNUM_TARGET_GLES3 + /** + * Debug context + * @requires_gl43 %Extension @es_extension{KHR,debug} + * @requires_es_extension %Extension @es_extension{KHR,debug} + */ + Debug = GL_CONTEXT_FLAG_DEBUG_BIT + #endif + }; + + /** + * @brief Context flags + * + * @see flags() + */ + typedef Corrade::Containers::EnumSet Flags; + /** * @brief Constructor * * Constructed automatically, see class documentation for more * information. * @see @fn_gl{Get} with @def_gl{MAJOR_VERSION}, @def_gl{MINOR_VERSION}, - * @fn_gl{GetString} with @def_gl{EXTENSIONS} + * @def_gl{CONTEXT_FLAGS}, @fn_gl{GetString} with @def_gl{EXTENSIONS} */ explicit Context(); @@ -221,6 +245,9 @@ class MAGNUM_EXPORT Context { return reinterpret_cast(glGetString(GL_SHADING_LANGUAGE_VERSION)); } + /** @brief Context flags */ + inline Flags flags() const { return _flags; } + /** * @brief Supported extensions * @@ -302,6 +329,7 @@ class MAGNUM_EXPORT Context { Version _version; Int _majorVersion; Int _minorVersion; + Flags _flags; std::bitset<128> extensionStatus; std::vector _supportedExtensions;