Added missing loop cancel for Emscripten in test programs.

This commit is contained in:
Philipp Wiesemann 2015-05-18 21:21:14 +02:00
parent ac10a2f29d
commit 2c4ad51d44
18 changed files with 97 additions and 0 deletions

View File

@ -162,6 +162,11 @@ loop()
break; break;
} }
} }
#ifdef __EMSCRIPTEN__
if (done) {
emscripten_cancel_main_loop();
}
#endif
} }
int int

View File

@ -198,6 +198,11 @@ loop()
SDL_RenderPresent(renderer); SDL_RenderPresent(renderer);
} }
#ifdef __EMSCRIPTEN__
if (done) {
emscripten_cancel_main_loop();
}
#endif
} }
int int

View File

@ -62,11 +62,17 @@ loop()
while (SDL_PollEvent(&e)) { while (SDL_PollEvent(&e)) {
if (e.type == SDL_QUIT) { if (e.type == SDL_QUIT) {
done = 1; done = 1;
#ifdef __EMSCRIPTEN__
emscripten_cancel_main_loop();
#endif
return; return;
} }
if(e.key.keysym.sym == SDLK_ESCAPE) { if(e.key.keysym.sym == SDLK_ESCAPE) {
done = 1; done = 1;
#ifdef __EMSCRIPTEN__
emscripten_cancel_main_loop();
#endif
return; return;
} }
} }

View File

@ -153,6 +153,12 @@ loop(void *arg)
done = SDL_TRUE; done = SDL_TRUE;
retval = SDL_TRUE; /* keep going, wait for reattach. */ retval = SDL_TRUE; /* keep going, wait for reattach. */
} }
#ifdef __EMSCRIPTEN__
if (done) {
emscripten_cancel_main_loop();
}
#endif
} }
SDL_bool SDL_bool

View File

@ -266,6 +266,12 @@ void loop()
} }
} }
DrawScreen(screen, window); DrawScreen(screen, window);
#ifdef __EMSCRIPTEN__
if (quitting) {
emscripten_cancel_main_loop();
}
#endif
} }
int main(int argc, char* argv[]) int main(int argc, char* argv[])

View File

@ -466,6 +466,11 @@ void loop()
SDL_GL_SwapWindow(state->windows[i]); SDL_GL_SwapWindow(state->windows[i]);
} }
} }
#ifdef __EMSCRIPTEN__
else {
emscripten_cancel_main_loop();
}
#endif
} }
int int

View File

@ -257,6 +257,11 @@ loop()
SDL_RenderPresent(renderer); SDL_RenderPresent(renderer);
} }
#ifdef __EMSCRIPTEN__
if (done) {
emscripten_cancel_main_loop();
}
#endif
} }
int int

View File

@ -175,6 +175,12 @@ loop(void *arg)
done = SDL_TRUE; done = SDL_TRUE;
retval = SDL_TRUE; /* keep going, wait for reattach. */ retval = SDL_TRUE; /* keep going, wait for reattach. */
} }
#ifdef __EMSCRIPTEN__
if (done) {
emscripten_cancel_main_loop();
}
#endif
} }
static SDL_bool static SDL_bool

View File

@ -312,6 +312,12 @@ loop()
SDL_RenderClear(renderer); SDL_RenderClear(renderer);
SDL_RenderCopy(renderer, MooseTexture, NULL, &displayrect); SDL_RenderCopy(renderer, MooseTexture, NULL, &displayrect);
SDL_RenderPresent(renderer); SDL_RenderPresent(renderer);
#ifdef __EMSCRIPTEN__
if (done) {
emscripten_cancel_main_loop();
}
#endif
} }
int int

View File

@ -67,6 +67,11 @@ loop(){
SDL_RenderPresent(renderer); SDL_RenderPresent(renderer);
} }
#ifdef __EMSCRIPTEN__
if (done) {
emscripten_cancel_main_loop();
}
#endif
} }
int int

View File

@ -152,6 +152,11 @@ void loop()
continue; continue;
Draw(&drawstates[i]); Draw(&drawstates[i]);
} }
#ifdef __EMSCRIPTEN__
if (done) {
emscripten_cancel_main_loop();
}
#endif
} }
int int

View File

@ -241,6 +241,11 @@ loop()
if (!Draw(&drawstates[i])) done = 1; if (!Draw(&drawstates[i])) done = 1;
} }
} }
#ifdef __EMSCRIPTEN__
if (done) {
emscripten_cancel_main_loop();
}
#endif
} }
int int

View File

@ -142,6 +142,11 @@ loop()
continue; continue;
Draw(&drawstates[i]); Draw(&drawstates[i]);
} }
#ifdef __EMSCRIPTEN__
if (done) {
emscripten_cancel_main_loop();
}
#endif
} }
int int

View File

@ -251,6 +251,11 @@ loop()
continue; continue;
MoveSprites(state->renderers[i], sprites[i]); MoveSprites(state->renderers[i], sprites[i]);
} }
#ifdef __EMSCRIPTEN__
if (done) {
emscripten_cancel_main_loop();
}
#endif
} }
int int

View File

@ -136,6 +136,11 @@ void loop()
} }
} }
MoveSprites(renderer, sprite); MoveSprites(renderer, sprite);
#ifdef __EMSCRIPTEN__
if (done) {
emscripten_cancel_main_loop();
}
#endif
} }
int int

View File

@ -115,6 +115,12 @@ loop()
SDL_RenderClear(renderer); SDL_RenderClear(renderer);
SDL_RenderCopy(renderer, MooseTexture, NULL, NULL); SDL_RenderCopy(renderer, MooseTexture, NULL, NULL);
SDL_RenderPresent(renderer); SDL_RenderPresent(renderer);
#ifdef __EMSCRIPTEN__
if (done) {
emscripten_cancel_main_loop();
}
#endif
} }
int int

View File

@ -129,6 +129,12 @@ loop()
SDL_RenderPresent(state->renderers[i]); SDL_RenderPresent(state->renderers[i]);
} }
} }
#ifdef __EMSCRIPTEN__
if (done) {
emscripten_cancel_main_loop();
}
#endif
} }
int int

View File

@ -100,6 +100,11 @@ loop()
} }
} }
} }
#ifdef __EMSCRIPTEN__
if (done) {
emscripten_cancel_main_loop();
}
#endif
} }
int int