From 249e75b46f07ebca6cce1b648b5d34bc4a75792c Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 30 Aug 2012 14:49:12 -0700 Subject: support for SDL_QUIT event --- tests/sdl_quit.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 tests/sdl_quit.c (limited to 'tests/sdl_quit.c') diff --git a/tests/sdl_quit.c b/tests/sdl_quit.c new file mode 100644 index 00000000..1a07526f --- /dev/null +++ b/tests/sdl_quit.c @@ -0,0 +1,33 @@ +#include +#include +#include +#include +#include + +int result = 0; + +void one() { + SDL_Event event; + while (SDL_PollEvent(&event)) { + switch(event.type) { + case SDL_QUIT: { + if (!result) { // prevent infinite recursion since REPORT_RESULT does window.close too. + result = 1; + REPORT_RESULT_INTERNAL(1); + } + } + } + } +} + +void main_2(); + +int main() { + SDL_Init(SDL_INIT_VIDEO); + SDL_Surface *screen = SDL_SetVideoMode(600, 450, 32, SDL_HWSURFACE); + + emscripten_set_main_loop(one, 0); + + emscripten_run_script("setTimeout(function() { window.close() }, 2000)"); +} + -- cgit v1.2.3-70-g09d2