Browse Source

Platform: ability to specify context flags in Sdl2Application.

Finally proper support for debug contexts :-)
pull/51/head
Vladimír Vondruš 12 years ago
parent
commit
c275640ee0
  1. 2
      src/Magnum/Context.h
  2. 3
      src/Magnum/Platform/Sdl2Application.cpp
  3. 40
      src/Magnum/Platform/Sdl2Application.h

2
src/Magnum/Context.h

@ -103,7 +103,7 @@ class MAGNUM_EXPORT Context {
/**
* @brief Context flag
*
* @see @ref Flags, @ref flags()
* @see @ref Flags, @ref flags(), @ref Platform::Sdl2Application::Configuration::setFlags() "Platform::*Application::Configuration::setFlags()"
*/
enum class Flag: GLint {
/**

3
src/Magnum/Platform/Sdl2Application.cpp

@ -109,6 +109,9 @@ bool Sdl2Application::tryCreateContext(const Configuration& configuration) {
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, configuration.sampleCount() > 1 ? 1 : 0);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, configuration.sampleCount());
/* Context flags */
SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, int(configuration.flags()));
/* Flags: if not hidden, set as shown */
Uint32 windowFlags(configuration.windowFlags());
if(!(configuration.windowFlags() & Configuration::WindowFlag::Hidden)) windowFlags |= SDL_WINDOW_SHOWN;

40
src/Magnum/Platform/Sdl2Application.h

@ -423,6 +423,30 @@ depth buffer.
*/
class Sdl2Application::Configuration {
public:
/**
* @brief Context flag
*
* @see @ref Flags @ref setFlags()
*/
enum class Flag: int {
Debug = SDL_GL_CONTEXT_DEBUG_FLAG, /**< Create debug context */
/** Create context with robust access */
RobustAccess = SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG
};
/**
* @brief Context flags
*
* @see @ref setFlags()
*/
#ifndef DOXYGEN_GENERATING_OUTPUT
typedef Containers::EnumSet<Flag, int, SDL_GL_CONTEXT_DEBUG_FLAG|
SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG> Flags;
#else
typedef Containers::EnumSet<Flag, int> Flags;
#endif
/**
* @brief Window flag
*
@ -508,6 +532,20 @@ class Sdl2Application::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;
}
#ifndef CORRADE_TARGET_EMSCRIPTEN
/**
* @brief Context version
@ -561,8 +599,10 @@ class Sdl2Application::Configuration {
#ifndef CORRADE_TARGET_EMSCRIPTEN
Version _version;
#endif
Flags _flags;
};
CORRADE_ENUMSET_OPERATORS(Sdl2Application::Configuration::Flags)
CORRADE_ENUMSET_OPERATORS(Sdl2Application::Configuration::WindowFlags)
/**

Loading…
Cancel
Save