forked from tharvik/COG
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
64 lines (50 loc) · 1.5 KB
/
main.cpp
File metadata and controls
64 lines (50 loc) · 1.5 KB
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
#include "opengl.h"
#include "config.h"
#include "Game.h"
void initLibraries(int *argc, char *argv[]);
void openWindow(int &&x, int &&y, int &&width, int &&height,
std::string &&title);
void setUpOpenGL();
int main(int argc, char *argv[])
{
initLibraries(&argc, argv);
openWindow(MIDDLE_SCREEN_X, MIDDLE_SCREEN_Y,
WINDOW_WIDTH, WINDOW_HEIGHT, PACKAGE_NAME);
setUpOpenGL();
Game game;
game.enterMainMenu();
return EXIT_SUCCESS;
}
void initLibraries(int *argc, char *argv[])
{
// GLUT library
glutInit(argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
}
void openWindow(int &&x, int &&y, int &&width, int &&height,
std::string &&title)
{
glutInitWindowSize(width, height);
glutInitWindowPosition(x, y);
glutCreateWindow(title.c_str());
glutHideWindow();
#ifndef __APPLE__
GLenum err = glewInit();
if (err != GLEW_OK)
logger_error(std::string("Fail to init glew: ") +
((char*) glewGetErrorString(err)));
#endif
}
void setUpOpenGL()
{
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
glEnable(GL_TEXTURE_2D);
glMatrixMode(GL_MODELVIEW);
gluPerspective(FOV, GLdouble(glutGet(GLUT_WINDOW_WIDTH) /
glutGet(GLUT_WINDOW_HEIGHT)), NEAREST, FAREST);
// for VBO indexing
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
}