-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
95 lines (73 loc) · 1.9 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/* All needed header files is included there */
#include "muon.h"
int main(int argc, char **argv) {
if (glfwInit() == GL_FALSE) {
printf("glfwInit failed!");
return -1;
}
/* Init window related integears */
//map.windw = 640;
//map.windh = 480;
//frame_per_sec = 75;
fileLoad("conf");
if (glfwOpenWindow(640, 480, 8, 8, 8, 8 ,0 ,0, GLFW_WINDOW) == GL_FALSE) {
printf("glfwOpenWindow failed!");
return -1;
}
/* Init all structs in that function */
initEverything();
glViewport(0, 0, map.windw, map.windh);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, map.windw, map.windh, 0, 0, 1);
glMatrixMode(GL_MODELVIEW);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glAlphaFunc(GL_GREATER, 0.1f);
glDepthMask(GL_TRUE);
glEnable(GL_DEPTH_TEST);
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glEnable(GL_ALPHA_TEST);
/* Load all data here*/
loadSprites();
fileLoad("data/maps/testmap");
//makeGrid();
/*SDL_Surface *test_text;
test_text = makeStringSurface("This is a pretty good bitmap font text :D");*/
Timer fps;
/* Main loop */
int running = 1;
while (running) {
/* Start FPS timer */
Timer_S_ST(&fps, 0);
/* Clear Screen */
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
if (!glfwGetWindowParam(GLFW_OPENED))
running = 0;
cameraControl();
/* Draw all things here */
drawGrid();
objectDrawPoints();
objectDrawOwnBuildings();
objectDrawEnemy();
//objectDrawAll();
drawHud();
glfwSwapBuffers();
/* FPS Cap */
if (Timer_getTime(fps) < 1.0 / frame_per_sec)
glfwSleep((1.0 / frame_per_sec) - Timer_getTime(fps));
/* Write fps in window caption */
sprintf(map.wind_title, "Muon FPS: %d", Timer_getFPS(fps));
glfwSetWindowTitle(map.wind_title);
}
//SDL_Quit();
return 0;
}
/* Init all structs here */
void initEverything() {
current_player = 1;
objectTemplateArray_Init();
Map_init();
initPlayers(2);
//initFont();
}