Browse Source

Platform: test constant redraw in both SDL2 and GLFW applications.

pull/419/merge
Vladimír Vondruš 2 years ago
parent
commit
734ddd0d75
  1. 15
      src/Magnum/Platform/Test/GlfwApplicationTest.cpp
  2. 25
      src/Magnum/Platform/Test/Sdl2ApplicationTest.cpp

15
src/Magnum/Platform/Test/GlfwApplicationTest.cpp

@ -180,6 +180,9 @@ struct GlfwApplicationTest: Platform::Application {
void drawEvent() override {
Debug{} << "draw event";
swapBuffers();
if(_redraw)
redraw();
}
void keyPressEvent(KeyEvent& event) override {
@ -192,6 +195,14 @@ struct GlfwApplicationTest: Platform::Application {
if(event.key() == KeyEvent::Key::F1) {
Debug{} << "starting text input";
startTextInput();
} else if(event.key() == KeyEvent::Key::F2) {
_redraw = !_redraw;
Debug{} << "redrawing" << (_redraw ? "enabled" : "disabled");
if(_redraw) redraw();
} else if(event.key() == KeyEvent::Key::V) {
_vsync = !_vsync;
Debug{} << "vsync" << (_vsync? "on" : "off");
setSwapInterval(_vsync ? 1 : 0);
} else if(event.key() == KeyEvent::Key::Esc) {
Debug{} << "stopping text input";
stopTextInput();
@ -235,6 +246,10 @@ struct GlfwApplicationTest: Platform::Application {
void textInputEvent(TextInputEvent& event) override {
Debug{} << "text input event:" << event.text();
}
private:
bool _redraw = false;
bool _vsync = false;
};
GlfwApplicationTest::GlfwApplicationTest(const Arguments& arguments): Platform::Application{arguments, NoCreate} {

25
src/Magnum/Platform/Test/Sdl2ApplicationTest.cpp

@ -199,6 +199,9 @@ struct Sdl2ApplicationTest: Platform::Application {
#endif
swapBuffers();
if(_redraw)
redraw();
}
/* For testing event coordinates */
@ -228,7 +231,19 @@ struct Sdl2ApplicationTest: Platform::Application {
if(event.key() == KeyEvent::Key::F1) {
Debug{} << "starting text input";
startTextInput();
} else if(event.key() == KeyEvent::Key::Esc) {
} else if(event.key() == KeyEvent::Key::F2) {
_redraw = !_redraw;
Debug{} << "redrawing" << (_redraw ? "enabled" : "disabled");
if(_redraw) redraw();
}
#ifndef CORRADE_TARGET_EMSCRIPTEN
else if(event.key() == KeyEvent::Key::V) {
_vsync = !_vsync;
Debug{} << "vsync" << (_vsync? "on" : "off");
setSwapInterval(_vsync ? 1 : 0);
}
#endif
else if(event.key() == KeyEvent::Key::Esc) {
Debug{} << "stopping text input";
stopTextInput();
} else if(event.key() == KeyEvent::Key::T) {
@ -304,10 +319,14 @@ struct Sdl2ApplicationTest: Platform::Application {
if(event.type == SDL_WINDOWEVENT) d << event.window.event;
}
#ifdef CORRADE_TARGET_EMSCRIPTEN
private:
#ifdef CORRADE_TARGET_EMSCRIPTEN
bool _fullscreen = false;
#endif
#endif
bool _redraw = false;
#ifndef CORRADE_TARGET_EMSCRIPTEN
bool _vsync = false;
#endif
};
Sdl2ApplicationTest::Sdl2ApplicationTest(const Arguments& arguments): Platform::Application{arguments, NoCreate} {

Loading…
Cancel
Save