Browse Source

Platform: fix iOS display orientation events in Sdl2Application.

pull/136/head
Vladimír Vondruš 10 years ago
parent
commit
18bb3fccfc
  1. 12
      src/Magnum/Platform/Sdl2Application.cpp
  2. 7
      src/Magnum/Platform/Sdl2Application.h

12
src/Magnum/Platform/Sdl2Application.cpp

@ -321,10 +321,18 @@ void Sdl2Application::mainLoop() {
switch(event.type) { switch(event.type) {
case SDL_WINDOWEVENT: case SDL_WINDOWEVENT:
switch(event.window.event) { switch(event.window.event) {
case SDL_WINDOWEVENT_RESIZED: case SDL_WINDOWEVENT_RESIZED: {
#ifndef CORRADE_TARGET_IOS
viewportEvent({event.window.data1, event.window.data2}); viewportEvent({event.window.data1, event.window.data2});
#else
/* On iOS the window event is in points and not pixels,
but we need pixels to call glViewport() properly */
Vector2i drawableSize;
SDL_GL_GetDrawableSize(_window, &drawableSize.x(), &drawableSize.y());
viewportEvent(drawableSize);
#endif
_flags |= Flag::Redraw; _flags |= Flag::Redraw;
break; } break;
case SDL_WINDOWEVENT_EXPOSED: case SDL_WINDOWEVENT_EXPOSED:
_flags |= Flag::Redraw; _flags |= Flag::Redraw;
break; break;

7
src/Magnum/Platform/Sdl2Application.h

@ -576,7 +576,12 @@ class Sdl2Application::Configuration {
* @see @ref WindowFlags, @ref setWindowFlags() * @see @ref WindowFlags, @ref setWindowFlags()
*/ */
enum class WindowFlag: Uint32 { enum class WindowFlag: Uint32 {
Resizable = SDL_WINDOW_RESIZABLE, /**< Resizable window */ /**
* Resizable window. On iOS this allows the application to respond
* to display orientation changes.
*/
Resizable = SDL_WINDOW_RESIZABLE,
Fullscreen = SDL_WINDOW_FULLSCREEN, /**< Fullscreen window */ Fullscreen = SDL_WINDOW_FULLSCREEN, /**< Fullscreen window */
/** No window decoration. On iOS this hides the menu bar. */ /** No window decoration. On iOS this hides the menu bar. */

Loading…
Cancel
Save