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
64
65
66
67
68
69
|
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include <SDL2/SDL_ttf.h>
int init( SDL_Window* win, SDL_Renderer* ren ) {
// init subsystems
if( SDL_Init( SDL_INIT_VIDEO) ) {
fprintf( stderr, "SDLInit failed\n" );
return 1;
}
// image subsystem
if( !( IMG_Init( IMG_INIT_PNG ) & IMG_INIT_PNG ) ) {
fprintf( stderr, "IMGInit failed\n" );
return 1;
}
// ttf subsystem
if( TTF_Init() == -1 ) {
fprintf( stderr, "TFTInit failed\n" );
return 1;
}
// create window
win = SDL_CreateWindow("DOOR TO DEATH", 1, 1, 640, 480, SDL_WINDOW_SHOWN );
if( win == NULL ) {
fprintf( stderr, "Making a window failed\n" );
return 1;
}
// create renderer
ren = SDL_CreateRenderer( win, -1, SDL_RENDERER_ACCELERATED );
if( ren == NULL ) {
fprintf( stderr, "Renderer making failed\n" );
return 1;
}
SDL_SetRenderDrawColor( ren, 255, 255, 255, 255 );
SDL_RenderClear( ren );
SDL_RenderPresent( ren );
return 0;
}
int main() {
SDL_Renderer* ren = NULL;
SDL_Window* win = NULL;
SDL_Event e;
if( init( win, ren ) ) return 1;
if( win == NULL ) {
fprintf( stderr, "win is NULL\n" );
}
if( ren == NULL ) {
fprintf( stderr, "ren is NULL\n" );
return 1;
}
while(1) {
SDL_PollEvent( &e );
if( e.type == SDL_QUIT ) return 0;
}
SDL_Quit();
return 0;
}
|