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

« back to all changes in this revision

Viewing changes to tests/sdl_canvas_palette.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 <emscripten.h>
 
4
 
 
5
int main() {
 
6
  SDL_Init(SDL_INIT_VIDEO);
 
7
  SDL_Surface *screen = SDL_SetVideoMode(600, 400, 8, SDL_HWSURFACE | SDL_HWPALETTE);
 
8
 
 
9
  //initialize sdl palette
 
10
  //with red green and blue
 
11
  //colors
 
12
  SDL_Color pal[3];
 
13
  pal[0].r = 255;
 
14
  pal[0].g = 0;
 
15
  pal[0].b = 0;
 
16
  pal[0].unused = 0;
 
17
 
 
18
  pal[1].r = 0;
 
19
  pal[1].g = 255;
 
20
  pal[1].b = 0;
 
21
  pal[1].unused = 0;
 
22
 
 
23
  pal[2].r = 0;
 
24
  pal[2].g = 0;
 
25
  pal[2].b = 255;
 
26
  pal[2].unused = 0;
 
27
 
 
28
  SDL_SetColors(screen, pal, 0, 3);
 
29
 
 
30
  SDL_FillRect(screen, NULL, 0);
 
31
 
 
32
  {
 
33
    SDL_Rect rect = { 300, 0, 300, 200 };
 
34
    SDL_FillRect(screen, &rect, 1);
 
35
  }
 
36
 
 
37
  {
 
38
    SDL_Rect rect = { 0, 200, 600, 200 };
 
39
    SDL_FillRect(screen, &rect, 2);
 
40
  }
 
41
 
 
42
  //changing green color
 
43
  //to yellow
 
44
  pal[1].r = 255;
 
45
  SDL_SetColors(screen, pal, 1, 1);
 
46
 
 
47
  {
 
48
    SDL_Rect rect = { 300, 200, 300, 200 };
 
49
    SDL_FillRect(screen, &rect, 1);
 
50
  }
 
51
 
 
52
  printf("you should see red, blue and yellow rectangles\n");
 
53
 
 
54
  SDL_Quit();
 
55
 
 
56
  return 0;
 
57
}
 
58