-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
77 lines (53 loc) · 1.56 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include "main.h"
#include <stdlib.h>
#include <stdio.h>
#include <SDL/SDL.h>
#include "defs.h"
#include "mainloop.h"
#include "message.h"
#include "input.h"
#include "snge.h"
#include "config.h"
#include "particles.h"
char dataPath[256] = _DATA_PATH;
int screenWidth = _SCREEN_WIDTH;
int screenHeight = _SCREEN_HEIGHT;
int enableFullscreen = 0;
int filteringType = 0;
static void readConfiguration()
{
char path[256];
sprintf(path, "%sdefault.cfg", dataPath);
char resolution[256];
cfg_Open(path);
cfg_SeekSection("graphics");
cfg_GetIntValue("fullscreen", &enableFullscreen);
cfg_GetIntValue("filtering", &filteringType);
cfg_GetStringValue("resolution", resolution);
sscanf(resolution, "%dx%d", &screenWidth, &screenHeight);
cfg_Close();
}
int main(int argc, char **argv)
{
message_OutEx("Data path is set to '%s'\n", _DATA_PATH);
readConfiguration();
SDL_Surface* screen;
if(SDL_Init(SDL_INIT_VIDEO) < 0)
message_CriticalError("Could not initialize SDL video.\n");
atexit(SDL_Quit);
if(!(screen = SDL_SetVideoMode(screenWidth, screenHeight, 32, SDL_OPENGL | (enableFullscreen ? SDL_FULLSCREEN : 0))))
message_CriticalError("Could not set desired video mode.\n");
SDL_WM_SetCaption("D-Man", NULL);
common_Init();
graphics_Init(screenWidth, screenHeight);
input_Init();
sprites_Init();
snge_Init();
particles_Init();
mainloop_Go();
particles_Cleanup();
sprites_FreeAll();
snge_FreeSprites();
message_Out("Goodbye.\n");
return EXIT_SUCCESS;
}