~ubuntu-branches/ubuntu/vivid/emscripten/vivid

« back to all changes in this revision

Viewing changes to tests/sdl_quit.c

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2013-05-02 13:11:51 UTC
  • Revision ID: package-import@ubuntu.com-20130502131151-q8dvteqr1ef2x7xz
Tags: upstream-1.4.1~20130504~adb56cb
ImportĀ upstreamĀ versionĀ 1.4.1~20130504~adb56cb

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <stdio.h>
 
2
#include <SDL/SDL.h>
 
3
#include <SDL/SDL_ttf.h>
 
4
#include <assert.h>
 
5
#include <emscripten.h>
 
6
 
 
7
int result = 0;
 
8
 
 
9
void one() {
 
10
  SDL_Event event;
 
11
  while (SDL_PollEvent(&event)) {
 
12
    switch(event.type) {
 
13
      case SDL_QUIT: {
 
14
        if (!result) { // prevent infinite recursion since REPORT_RESULT does window.close too.
 
15
          result = 1;
 
16
          REPORT_RESULT_INTERNAL(1);
 
17
        }
 
18
      }
 
19
    }
 
20
  }
 
21
}
 
22
 
 
23
void main_2();
 
24
 
 
25
int main() {
 
26
  SDL_Init(SDL_INIT_VIDEO);
 
27
  SDL_Surface *screen = SDL_SetVideoMode(600, 450, 32, SDL_HWSURFACE);
 
28
 
 
29
  emscripten_set_main_loop(one, 0, 0);
 
30
 
 
31
  emscripten_run_script("setTimeout(function() { window.close() }, 2000)");
 
32
}
 
33