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

« back to all changes in this revision

Viewing changes to tests/sdl_canvas_proxy.c

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2013-09-20 22:44:35 UTC
  • mfrom: (4.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20130920224435-apuwj4fsl3fqv1a6
Tags: 1.5.6~20130920~6010666-1
* New snapshot release
* Update the list of supported architectures to the same as libv8
  (Closes: #723129)
* emlibtool has been removed from upstream.
* Fix warning syntax-error-in-dep5-copyright
* Refresh of the patches

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <stdio.h>
 
2
#include <stdlib.h>
 
3
#include <SDL/SDL.h>
 
4
#include <assert.h>
 
5
#include <emscripten.h>
 
6
 
 
7
int main(int argc, char **argv) {
 
8
  FILE *f = fopen("data.txt", "rb");
 
9
  assert(f);
 
10
  assert(fgetc(f) == 'd');
 
11
  assert(fgetc(f) == 'a');
 
12
  assert(fgetc(f) == 't');
 
13
  assert(fgetc(f) == 'u');
 
14
  assert(fgetc(f) == 'm');
 
15
  fclose(f);
 
16
 
 
17
  SDL_Init(SDL_INIT_VIDEO);
 
18
  SDL_Surface *screen = SDL_SetVideoMode(600, 450, 32, SDL_HWSURFACE);
 
19
 
 
20
  SDL_LockSurface(screen);
 
21
  unsigned int *pixels = (unsigned int *)screen->pixels;
 
22
  for (int x = 0; x < screen->w; x++) {
 
23
    for (int y = 0; y < screen->h; y++) {
 
24
      pixels[x + y*screen->h] = x < 300 ? (y < 200 ? 0x3377AA88 : 0xAA3377CC) : (y < 200 ? 0x0066AA77 : 0xAA006699);
 
25
    }
 
26
  }
 
27
  SDL_UnlockSurface(screen);
 
28
 
 
29
  SDL_Quit();
 
30
 
 
31
  EM_ASM(window.close());
 
32
  return 0;
 
33
}
 
34