int main int argc char argv SDL_Surface screen SDL_Event event SDL_Rec

 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
int main(int argc, char *argv[]){
SDL_Surface *screen;
SDL_Event event;
SDL_Rect dst;
if (SDL_Init(SDL_INIT_VIDEO))
return 1;
screen = SDL_SetVideoMode(640, 480, 32,
SDL_ANYFORMAT);
if (!screen){
SDL_Quit();
return 1;
}
dst.x = 10;
dst.y = 10;
dst.w = 50;
dst.h = 50;
SDL_FillRect(screen, &dst,
SDL_MapRGB(screen->format,0,255,0));
SDL_Flip(screen);
while(SDL_WaitEvent(&event)){
if(event.type == SDL_QUIT ||
(event.type == SDL_KEYDOWN &&
event.key.keysym.sym == SDLK_ESCAPE))
{
SDL_Quit();
return 0;
}
}
SDL_Quit();
return 2;
}