forked from benob/rs97_st-sdl
-
Notifications
You must be signed in to change notification settings - Fork 1
/
sdl_test.c
38 lines (32 loc) · 771 Bytes
/
sdl_test.c
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
#include <SDL/SDL.h>
int main(int argc, char** argv) {
SDL_Init(SDL_INIT_VIDEO);
printf("Testing SDL\n");
SDL_Surface* screen = SDL_SetVideoMode(320, 240, 16, SDL_HWSURFACE);
int quit = 0;
while( !quit ){
SDL_Event event;
while( SDL_PollEvent( &event ) ){
switch( event.type ){
case SDL_KEYDOWN:
case SDL_KEYUP:
quit = 1;
break;
case SDL_QUIT:
quit = 1;
break;
default:
break;
}
}
SDL_Rect rect;
rect.x = rand() % screen->w;
rect.y = rand() % screen->h;
rect.w = rand() % (screen->w - rect.x);
rect.h = rand() % (screen->h - rect.y);
SDL_FillRect(screen, &rect, SDL_MapRGB(screen->format, rand() % 255, rand() % 255, rand() % 255));
SDL_Flip(screen);
SDL_Delay(1000 / 60);
}
SDL_Quit();
}