@ -296,12 +296,15 @@ struct EmscriptenApplicationTest: Platform::Application {
void drawEvent ( ) override {
void drawEvent ( ) override {
Debug ( ) < < " draw event " ;
Debug ( ) < < " draw event " ;
/* If the app was initialized contextless, there's no GL context */
if ( GL : : Context : : hasCurrent ( ) ) {
# ifdef CUSTOM_CLEAR_COLOR
# ifdef CUSTOM_CLEAR_COLOR
GL : : Renderer : : setClearColor ( CUSTOM_CLEAR_COLOR ) ;
GL : : Renderer : : setClearColor ( CUSTOM_CLEAR_COLOR ) ;
# endif
# endif
GL : : defaultFramebuffer . clear ( GL : : FramebufferClear : : Color ) ;
GL : : defaultFramebuffer . clear ( GL : : FramebufferClear : : Color ) ;
swapBuffers ( ) ;
swapBuffers ( ) ;
}
if ( _redraw )
if ( _redraw )
redraw ( ) ;
redraw ( ) ;
@ -424,6 +427,7 @@ EmscriptenApplicationTest::EmscriptenApplicationTest(const Arguments& arguments)
. addSkippedPrefix ( " magnum " , " engine-specific options " )
. addSkippedPrefix ( " magnum " , " engine-specific options " )
. addBooleanOption ( " exit-immediately " ) . setHelp ( " exit-immediately " , " exit the application immediately from the constructor, to test that the app doesn't run any event handlers after " )
. addBooleanOption ( " exit-immediately " ) . setHelp ( " exit-immediately " , " exit the application immediately from the constructor, to test that the app doesn't run any event handlers after " )
. addBooleanOption ( " quiet " ) . setHelp ( " quiet " , " like --magnum-log quiet, but specified via a Context::Configuration instead " )
. addBooleanOption ( " quiet " ) . setHelp ( " quiet " , " like --magnum-log quiet, but specified via a Context::Configuration instead " )
. addBooleanOption ( " contextless " ) . setHelp ( " contextless " , " initialize without a WebGL context " )
. parse ( arguments . argc , arguments . argv ) ;
. parse ( arguments . argc , arguments . argv ) ;
/* Useful for bisecting Emscripten regressions, because they happen WAY TOO
/* Useful for bisecting Emscripten regressions, because they happen WAY TOO
@ -442,13 +446,18 @@ EmscriptenApplicationTest::EmscriptenApplicationTest(const Arguments& arguments)
conf . setWindowFlags ( Configuration : : WindowFlag : : Resizable ) ;
conf . setWindowFlags ( Configuration : : WindowFlag : : Resizable ) ;
if ( ! args . value ( " dpi-scaling " ) . empty ( ) )
if ( ! args . value ( " dpi-scaling " ) . empty ( ) )
conf . setSize ( { 640 , 480 } , args . value < Vector2 > ( " dpi-scaling " ) ) ;
conf . setSize ( { 640 , 480 } , args . value < Vector2 > ( " dpi-scaling " ) ) ;
if ( args . isSet ( " contextless " ) ) {
conf . addWindowFlags ( Configuration : : WindowFlag : : Contextless ) ;
create ( conf ) ;
} else {
GLConfiguration glConf ;
GLConfiguration glConf ;
if ( args . isSet ( " quiet " ) )
if ( args . isSet ( " quiet " ) )
glConf . addFlags ( GLConfiguration : : Flag : : QuietLog ) ;
glConf . addFlags ( GLConfiguration : : Flag : : QuietLog ) ;
/* No GL-specific verbose log in EmscriptenApplication that we'd need to
/* No GL-specific verbose log in EmscriptenApplication that we'd need
handle explicitly */
to handle explicitly */
/* No GPU validation on WebGL */
/* No GPU validation on WebGL */
create ( conf , glConf ) ;
create ( conf , glConf ) ;
}
Debug { } < < " window size " < < windowSize ( )
Debug { } < < " window size " < < windowSize ( )
# ifdef MAGNUM_TARGET_GL
# ifdef MAGNUM_TARGET_GL
@ -456,11 +465,18 @@ EmscriptenApplicationTest::EmscriptenApplicationTest(const Arguments& arguments)
# endif
# endif
< < dpiScaling ( ) < < devicePixelRatio ( ) ;
< < dpiScaling ( ) < < devicePixelRatio ( ) ;
if ( ! args . isSet ( " contextless " ) ) {
/* This uses a VAO on WebGL 1, so it will crash in case GL flags are
/* This uses a VAO on WebGL 1, so it will crash in case GL flags are
missing EnableExtensionsByDefault ( uncomment above ) */
missing EnableExtensionsByDefault */
GL : : Mesh mesh ;
GL : : Mesh mesh ;
}
}
/* Uncomment this to verify destructor behavior, such as in case of
Contextless enabled . Note that it might then blow up elsewhere due to
this . */
// delete this;
}
} } } }
} } } }
MAGNUM_APPLICATION_MAIN ( Magnum : : Platform : : Test : : EmscriptenApplicationTest )
MAGNUM_APPLICATION_MAIN ( Magnum : : Platform : : Test : : EmscriptenApplicationTest )