-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
62 lines (42 loc) · 1.11 KB
/
main.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include"core.h"
// SDL Variables
SDL_Window *window;
SDL_Renderer *renderer;
SDL_Surface *screen;
TTF_Font *font;
/*
* Initializes SDL and all SDL extension libraries
*/
void initSDL()
{
SDL_Init(SDL_INIT_EVERYTHING);
window = SDL_CreateWindow("Game Window",
SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
DEFAULT_WINDOW_WIDTH,
DEFAULT_WINDOW_HEIGHT,
0
);
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_SOFTWARE); //<--Check on different graphics cards if should be SDL_RENDERER_ACCELERATED
screen = SDL_GetWindowSurface(window);
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
SDL_RenderClear(renderer);
SDL_RenderPresent(renderer);
TTF_Init();
font = TTF_OpenFont("fonts/c64.ttf", 12);
// Redirect output to log files
FILE * my_stdout = freopen ("logs/my_stdout.txt", "wt" /*or "wt"*/, stdout);
FILE * my_stderr = freopen ("logs/my_stderr.txt", "wb" /*or "wt"*/, stderr);
}
void closeSDL()
{
TTF_CloseFont(font);
SDL_DestroyWindow(window);
SDL_Quit();
}
int main(int argc, char *argv[])
{
initGame();
runGame();
return 0;
}