summaryrefslogtreecommitdiff
path: root/display.c
blob: a4ac62b285c7406f7cba382fe62ccc7402f8161c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <SDL/SDL.h>
#include <SDL/SDL_gfxPrimitives.h>

#include "display.h"

static SDL_Surface *screen;
static int g_width, g_height;

void display_init( int width, int height) {
  g_width = width;
  g_height = height;

  if (SDL_Init (SDL_INIT_EVERYTHING) == -1) {
    fprintf( stderr, "Can't initialize SDL.\n" );
    exit (1);
  }

  screen = SDL_SetVideoMode ( width, height, 24, SDL_SWSURFACE | SDL_DOUBLEBUF );
  if( !screen ) {
    fprintf( stderr, "Can't set video mode.\n" );
    exit( 1 );
  }

  memset( screen->pixels, 0, width * height * 3 );
  SDL_WM_SetCaption ( "GodMachine", "GodMachine" );

}

void display_clear( ) {
//  rectangleColor( screen, 0, 0, g_width, g_height, 0 );

  memset( screen->pixels, 0, g_width * g_height * 3 );
  vlineColor( screen, g_width / 2, 0, g_height, 0xffffffff );
  hlineColor( screen, 0, g_width, g_height / 2, 0xffffffff );
}

void display_circle( int wii_id, int x, int y, int w ) {
  int xoff = ( wii_id & 1 ) * g_width / 2;
  int yoff = ( wii_id >> 1 ) * g_height / 2;

  filledCircleColor(screen, x + xoff, y + yoff, w, 0xffffffff );

}

void display_line( int wii_id, int x0, int y0, int x1, int y1 ) {
  int xoff = ( wii_id & 1 ) * g_width / 2;
  int yoff = ( wii_id >> 1 ) * g_height / 2;

  aalineColor( screen, x0 + xoff, y0 + yoff, x1 + xoff, y1 + yoff, 0xffffffff );

}

void display_rectangle( int wii_id, int x, int y, int w, int h ) {
  int xoff = ( wii_id & 1 ) * g_width / 2;
  int yoff = ( wii_id >> 1 ) * g_height / 2;

  boxColor( screen, x + xoff, y + yoff, x + xoff + w, y + yoff + h, 0xffffffff );

}

void display_redraw() {
  SDL_Flip( screen );
}