-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
105 lines (86 loc) · 2.64 KB
/
main.cpp
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
96
97
98
99
100
101
102
103
104
105
#define _USE_MATH_DEFINES
#include <cmath>
#include <chrono>
#include <cctype>
#include <vector>
#include <thread>
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <GL/glut.h>
#include <Windows.h>
#include <mmsystem.h>
#include "Shape.h"
#include "Sphere.h"
#include "Rectangle.h"
#include "Cuboid.h"
#include "LightSource.h"
#include "ScreenLogger.h"
#include "typedefs.h"
#include "materials.h"
#include "rendering.h"
#include "display_lists.h"
#include "globals.h"
#include "ControllerInterface.h"
#include "FileManager.h"
#include "menu.h"
int main(int argc, char* argv[])
{
// Window Creation
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(windowWidth, windowHeight);
glutInitWindowPosition(500, 100);
glutCreateWindow("3D Platformer");
ScreenLogger::getInstance().setDimensions(windowWidth, windowHeight);
if (FULLSCREEN)
glutFullScreen();
// Attributes
glEnable(GL_DEPTH_TEST); // Depth Buffer
glClearColor(0.05f, 0.12f, 0.20f, 1.0f); // Night Sky Background
glEnable(GL_LIGHTING); // Lighting
glEnable(GL_LIGHT0); // Light Source
glShadeModel(GL_SMOOTH);
//glEnable(GL_NORMALIZE); // Normals Preservation for units
//glEnable(GL_COLOR_MATERIAL); // Make glColorf() as Material
glLineWidth(0.1f);
glPointSize(0.3f);
glColor3f(1.0f, 1.0f, 1.0f);
// Pre-compiled lists initialization
initDisplayLists();
// Window menu
create_window_menu();
// ----------- Window Matrix (BEGIN) ----------- //
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
// Initialization of Window Matrix for on-screen string rendering.
glPushMatrix();
{
gluOrtho2D(0.0, (double)windowWidth, 0.0, (double)windowHeight);
glGetFloatv(GL_PROJECTION_MATRIX, windowMatrix);
}
glPopMatrix();
// ----------- Window Matrix (BEGIN) ----------- //
// Returns mouse to the center of the window.
glutWarpPointer(windowCenter[0], windowCenter[1]);
// Hides cursor.
glutSetCursor(GLUT_CURSOR_NONE);
// Ignores prolonged push of a key.
glutIgnoreKeyRepeat(TRUE);
ControllerInterface::initializeWorld();
// ----------- CALLBACK FUNCTIONS (BEGIN) ----------- //
glutDisplayFunc(ControllerInterface::Callback::display);
glutKeyboardFunc(ControllerInterface::Callback::keyboardDown);
glutKeyboardUpFunc(ControllerInterface::Callback::keyboardUp);
glutPassiveMotionFunc(ControllerInterface::Callback::passiveMotion);
glutSpecialFunc(nullptr);
glutIdleFunc(nullptr);
// ----------- CALLBACK FUNCTIONS (END) ----------- //
PlaySound(
FileManager::getInstance().mainAmbienceTheme().c_str(),
nullptr,
SND_ASYNC | SND_NODEFAULT | SND_LOOP
);
glutMainLoop();
return EXIT_SUCCESS;
}