Browse Source

Platform: use Flag::Redraw instead of a boolean in GlfwApplication.

Also properly reset it before drawEvent() so the users can control the
amount of redrawing themselves.
pull/193/head
Vladimír Vondruš 9 years ago
parent
commit
f64ebc6219
  1. 5
      src/Magnum/Platform/GlfwApplication.cpp
  2. 13
      src/Magnum/Platform/GlfwApplication.h

5
src/Magnum/Platform/GlfwApplication.cpp

@ -52,7 +52,7 @@ GlfwApplication::GlfwApplication(const Arguments& arguments, const Configuration
GlfwApplication::GlfwApplication(const Arguments& arguments, std::nullptr_t):
_context{new Context{NoCreate, arguments.argc, arguments.argv}},
_needsRedraw(true)
_flags{Flag::Redraw}
{
/* Save global instance */
_instance = this;
@ -154,7 +154,8 @@ void GlfwApplication::setSwapInterval(const Int interval) {
int GlfwApplication::exec() {
while(!glfwWindowShouldClose(_window)) {
if(_needsRedraw) {
if(_flags & Flag::Redraw) {
_flags &= ~Flag::Redraw;
drawEvent();
}
glfwPollEvents();

13
src/Magnum/Platform/GlfwApplication.h

@ -183,7 +183,7 @@ class GlfwApplication {
void setSwapInterval(Int interval);
/** @copydoc Sdl2Application::redraw() */
void redraw() { _needsRedraw = true; }
void redraw() { _flags |= Flag::Redraw; }
#ifdef DOXYGEN_GENERATING_OUTPUT
protected:
@ -241,6 +241,13 @@ class GlfwApplication {
/*@}*/
private:
enum class Flag: UnsignedByte {
Redraw = 1 << 0
};
typedef Containers::EnumSet<Flag> Flags;
CORRADE_ENUMSET_FRIEND_OPERATORS(Flags)
static void staticViewportEvent(GLFWwindow*, int w, int h) {
_instance->viewportEvent({w, h});
}
@ -259,9 +266,11 @@ class GlfwApplication {
GLFWwindow* _window;
std::unique_ptr<Platform::Context> _context;
bool _needsRedraw;
Flags _flags;
};
CORRADE_ENUMSET_OPERATORS(GlfwApplication::Flags)
/**
@brief Configuration

Loading…
Cancel
Save