From 085d96ce2584c70322deff04633bc8bdddb086cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 14 Mar 2014 12:43:42 +0100 Subject: [PATCH] Platform: support for debug context flag in GlutApplication. For some weird reason this doesn't work for me. --- src/Magnum/Platform/GlutApplication.cpp | 3 ++ src/Magnum/Platform/GlutApplication.h | 37 +++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/src/Magnum/Platform/GlutApplication.cpp b/src/Magnum/Platform/GlutApplication.cpp index 58f8bc1ec..8009451b4 100644 --- a/src/Magnum/Platform/GlutApplication.cpp +++ b/src/Magnum/Platform/GlutApplication.cpp @@ -90,6 +90,9 @@ bool GlutApplication::tryCreateContext(const Configuration& configuration) { #endif } + /* Set context flags */ + glutInitContextFlags(int(configuration.flags())); + if(!glutCreateWindow(configuration.title().data())) { Error() << "Platform::GlutApplication::tryCreateContext(): cannot create context"; return false; diff --git a/src/Magnum/Platform/GlutApplication.h b/src/Magnum/Platform/GlutApplication.h index 4947351da..6ab203118 100644 --- a/src/Magnum/Platform/GlutApplication.h +++ b/src/Magnum/Platform/GlutApplication.h @@ -280,6 +280,26 @@ Double-buffered RGBA window with depth and stencil buffers. */ class GlutApplication::Configuration { public: + /** + * @brief Context flag + * + * @see @ref Flags @ref setFlags() + */ + enum class Flag: int { + Debug = GLUT_DEBUG /**< Create debug context */ + }; + + /** + * @brief Context flags + * + * @see @ref setFlags() + */ + #ifndef DOXYGEN_GENERATING_OUTPUT + typedef Containers::EnumSet Flags; + #else + typedef Containers::EnumSet Flags; + #endif + /*implicit*/ Configuration(); ~Configuration(); @@ -311,6 +331,20 @@ class GlutApplication::Configuration { return *this; } + /** @brief Context flags */ + Flags flags() const { return _flags; } + + /** + * @brief Set context flags + * @return Reference to self (for method chaining) + * + * Default is no flag. + */ + Configuration& setFlags(Flags flags) { + _flags = flags; + return *this; + } + /** @brief Context version */ Version version() const { return _version; } @@ -348,8 +382,11 @@ class GlutApplication::Configuration { Vector2i _size; Int _sampleCount; Version _version; + Flags _flags; }; +CORRADE_ENUMSET_OPERATORS(GlutApplication::Configuration::Flags) + /** @brief Base for input events