diff --git a/src/Magnum/Platform/EmscriptenApplication.cpp b/src/Magnum/Platform/EmscriptenApplication.cpp index 21d221a34b..63cc6ae162 100644 --- a/src/Magnum/Platform/EmscriptenApplication.cpp +++ b/src/Magnum/Platform/EmscriptenApplication.cpp @@ -50,7 +50,9 @@ EmscriptenApplication::EmscriptenApplication(const Arguments& arguments, const C } #endif -EmscriptenApplication::EmscriptenApplication(const Arguments& arguments, NoCreateT) { +EmscriptenApplication::EmscriptenApplication(const Arguments& arguments, NoCreateT): + _flags{Flag::Redraw} +{ Utility::Arguments args{Implementation::windowScalingArguments()}; #ifdef MAGNUM_TARGET_GL _context.reset(new GLContext{NoCreate, args, arguments.argc, arguments.argv}); @@ -103,6 +105,7 @@ bool EmscriptenApplication::tryCreate(const Configuration& configuration, const if(configuration.windowFlags() & Configuration::WindowFlag::Resizable) { _flags |= Flag::Resizable; } + /* Create emscripten WebGL context */ EmscriptenWebGLContextAttributes attrs; emscripten_webgl_init_context_attributes(&attrs); @@ -505,7 +508,10 @@ void EmscriptenApplication::mainLoopIteration() { } } - drawEvent(); + if(_flags & Flag::Redraw) { + _flags &= ~Flag::Redraw; + drawEvent(); + } } int EmscriptenApplication::exec() { diff --git a/src/Magnum/Platform/EmscriptenApplication.h b/src/Magnum/Platform/EmscriptenApplication.h index 45f554ac99..f282ec8c0b 100644 --- a/src/Magnum/Platform/EmscriptenApplication.h +++ b/src/Magnum/Platform/EmscriptenApplication.h @@ -381,7 +381,7 @@ class EmscriptenApplication { }; typedef Containers::EnumSet Flags; - Vector2 _dpiScaling; + Vector2 _dpiScaling{1.0f, 1.0f}; Vector2i _lastKnownCanvasSize; Flags _flags; diff --git a/src/Magnum/Platform/Test/EmscriptenApplicationTest.cpp b/src/Magnum/Platform/Test/EmscriptenApplicationTest.cpp index cfa10f736b..977ad9a048 100644 --- a/src/Magnum/Platform/Test/EmscriptenApplicationTest.cpp +++ b/src/Magnum/Platform/Test/EmscriptenApplicationTest.cpp @@ -36,14 +36,16 @@ struct EmscriptenApplicationTest: Platform::Application { explicit EmscriptenApplicationTest(const Arguments& arguments): Platform::Application{arguments, Configuration{} .setWindowFlags(Configuration::WindowFlag::Resizable)} { + GL::Renderer::setClearColor(Color3{1.0, 1.0, 1.0}); } virtual void drawEvent() override { - glViewport(0, 0, 640, 480); - GL::Renderer::setClearColor(Color4{1.0, 1.0, 1.0, 1.0}); + GL::Renderer::setClearColor(Color3{1.0, 0.0, 1.0}); + GL::defaultFramebuffer.clear(GL::FramebufferClear::Color); swapBuffers(); + redraw(); } /* For testing HiDPI resize events */ diff --git a/src/Magnum/Platform/Test/EmscriptenApplicationTest.html b/src/Magnum/Platform/Test/EmscriptenApplicationTest.html index 8659b31c6b..f4e616e0a0 100644 --- a/src/Magnum/Platform/Test/EmscriptenApplicationTest.html +++ b/src/Magnum/Platform/Test/EmscriptenApplicationTest.html @@ -10,12 +10,18 @@

Magnum EmscriptenApplication Test

- -

+      
       
Initialization...
+