Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added missing loop cancel for Emscripten in test programs.
  • Loading branch information
philippwiesemann committed May 18, 2015
1 parent ac10a2f commit 2c4ad51
Show file tree
Hide file tree
Showing 18 changed files with 97 additions and 0 deletions.
5 changes: 5 additions & 0 deletions test/checkkeys.c
Expand Up @@ -162,6 +162,11 @@ loop()
break;
}
}
#ifdef __EMSCRIPTEN__
if (done) {
emscripten_cancel_main_loop();
}
#endif
}

int
Expand Down
5 changes: 5 additions & 0 deletions test/testdraw2.c
Expand Up @@ -198,6 +198,11 @@ loop()

SDL_RenderPresent(renderer);
}
#ifdef __EMSCRIPTEN__
if (done) {
emscripten_cancel_main_loop();
}
#endif
}

int
Expand Down
6 changes: 6 additions & 0 deletions test/testdrawchessboard.c
Expand Up @@ -62,11 +62,17 @@ loop()
while (SDL_PollEvent(&e)) {
if (e.type == SDL_QUIT) {
done = 1;
#ifdef __EMSCRIPTEN__
emscripten_cancel_main_loop();
#endif
return;
}

if(e.key.keysym.sym == SDLK_ESCAPE) {
done = 1;
#ifdef __EMSCRIPTEN__
emscripten_cancel_main_loop();
#endif
return;
}
}
Expand Down
6 changes: 6 additions & 0 deletions test/testgamecontroller.c
Expand Up @@ -153,6 +153,12 @@ loop(void *arg)
done = SDL_TRUE;
retval = SDL_TRUE; /* keep going, wait for reattach. */
}

#ifdef __EMSCRIPTEN__
if (done) {
emscripten_cancel_main_loop();
}
#endif
}

SDL_bool
Expand Down
6 changes: 6 additions & 0 deletions test/testgesture.c
Expand Up @@ -266,6 +266,12 @@ void loop()
}
}
DrawScreen(screen, window);

#ifdef __EMSCRIPTEN__
if (quitting) {
emscripten_cancel_main_loop();
}
#endif
}

int main(int argc, char* argv[])
Expand Down
5 changes: 5 additions & 0 deletions test/testgles2.c
Expand Up @@ -466,6 +466,11 @@ void loop()
SDL_GL_SwapWindow(state->windows[i]);
}
}
#ifdef __EMSCRIPTEN__
else {
emscripten_cancel_main_loop();
}
#endif
}

int
Expand Down
5 changes: 5 additions & 0 deletions test/testintersections.c
Expand Up @@ -257,6 +257,11 @@ loop()

SDL_RenderPresent(renderer);
}
#ifdef __EMSCRIPTEN__
if (done) {
emscripten_cancel_main_loop();
}
#endif
}

int
Expand Down
6 changes: 6 additions & 0 deletions test/testjoystick.c
Expand Up @@ -175,6 +175,12 @@ loop(void *arg)
done = SDL_TRUE;
retval = SDL_TRUE; /* keep going, wait for reattach. */
}

#ifdef __EMSCRIPTEN__
if (done) {
emscripten_cancel_main_loop();
}
#endif
}

static SDL_bool
Expand Down
6 changes: 6 additions & 0 deletions test/testoverlay2.c
Expand Up @@ -312,6 +312,12 @@ loop()
SDL_RenderClear(renderer);
SDL_RenderCopy(renderer, MooseTexture, NULL, &displayrect);
SDL_RenderPresent(renderer);

#ifdef __EMSCRIPTEN__
if (done) {
emscripten_cancel_main_loop();
}
#endif
}

int
Expand Down
5 changes: 5 additions & 0 deletions test/testrelative.c
Expand Up @@ -67,6 +67,11 @@ loop(){

SDL_RenderPresent(renderer);
}
#ifdef __EMSCRIPTEN__
if (done) {
emscripten_cancel_main_loop();
}
#endif
}

int
Expand Down
5 changes: 5 additions & 0 deletions test/testrendercopyex.c
Expand Up @@ -152,6 +152,11 @@ void loop()
continue;
Draw(&drawstates[i]);
}
#ifdef __EMSCRIPTEN__
if (done) {
emscripten_cancel_main_loop();
}
#endif
}

int
Expand Down
5 changes: 5 additions & 0 deletions test/testrendertarget.c
Expand Up @@ -241,6 +241,11 @@ loop()
if (!Draw(&drawstates[i])) done = 1;
}
}
#ifdef __EMSCRIPTEN__
if (done) {
emscripten_cancel_main_loop();
}
#endif
}

int
Expand Down
5 changes: 5 additions & 0 deletions test/testscale.c
Expand Up @@ -142,6 +142,11 @@ loop()
continue;
Draw(&drawstates[i]);
}
#ifdef __EMSCRIPTEN__
if (done) {
emscripten_cancel_main_loop();
}
#endif
}

int
Expand Down
5 changes: 5 additions & 0 deletions test/testsprite2.c
Expand Up @@ -251,6 +251,11 @@ loop()
continue;
MoveSprites(state->renderers[i], sprites[i]);
}
#ifdef __EMSCRIPTEN__
if (done) {
emscripten_cancel_main_loop();
}
#endif
}

int
Expand Down
5 changes: 5 additions & 0 deletions test/testspriteminimal.c
Expand Up @@ -136,6 +136,11 @@ void loop()
}
}
MoveSprites(renderer, sprite);
#ifdef __EMSCRIPTEN__
if (done) {
emscripten_cancel_main_loop();
}
#endif
}

int
Expand Down
6 changes: 6 additions & 0 deletions test/teststreaming.c
Expand Up @@ -115,6 +115,12 @@ loop()
SDL_RenderClear(renderer);
SDL_RenderCopy(renderer, MooseTexture, NULL, NULL);
SDL_RenderPresent(renderer);

#ifdef __EMSCRIPTEN__
if (done) {
emscripten_cancel_main_loop();
}
#endif
}

int
Expand Down
6 changes: 6 additions & 0 deletions test/testviewport.c
Expand Up @@ -129,6 +129,12 @@ loop()
SDL_RenderPresent(state->renderers[i]);
}
}

#ifdef __EMSCRIPTEN__
if (done) {
emscripten_cancel_main_loop();
}
#endif
}

int
Expand Down
5 changes: 5 additions & 0 deletions test/testwm2.c
Expand Up @@ -100,6 +100,11 @@ loop()
}
}
}
#ifdef __EMSCRIPTEN__
if (done) {
emscripten_cancel_main_loop();
}
#endif
}

int
Expand Down

0 comments on commit 2c4ad51

Please sign in to comment.