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

« back to all changes in this revision

Viewing changes to tests/hello_world_sdl.cpp

  • 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:
2
2
#include <SDL/SDL.h>
3
3
 
4
4
 
5
 
int main() {
 
5
extern "C" int main(int argc, char** argv) {
6
6
  printf("hello, world!\n");
7
7
 
8
8
  SDL_Init(SDL_INIT_VIDEO);
11
11
  if (SDL_MUSTLOCK(screen)) SDL_LockSurface(screen);
12
12
  for (int i = 0; i < 256; i++) {
13
13
    for (int j = 0; j < 256; j++) {
14
 
      *((char*)screen->pixels + i*256*4 + j*4 + 0) = i;
15
 
      *((char*)screen->pixels + i*256*4 + j*4 + 1) = j;
16
 
      *((char*)screen->pixels + i*256*4 + j*4 + 2) = 255-i;
17
 
      *((char*)screen->pixels + i*256*4 + j*4 + 3) = (i+j)%255; // actually ignored, since this is to the screen
 
14
      // alpha component is actually ignored, since this is to the screen
 
15
      *((Uint32*)screen->pixels + i * 256 + j) = SDL_MapRGBA(screen->format, i, j, 255-i, (i+j) % 255);
18
16
    }
19
17
  }
20
18
  if (SDL_MUSTLOCK(screen)) SDL_UnlockSurface(screen);