-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cpp
102 lines (75 loc) · 2.1 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
# include "main.h"
# include "RenderingCore.h"
# include "Exception.h"
# include <iostream>
# include <GLUT/glut.h>
using namespace std;
// A few basic colors.
CColor g_objRed (1.0f, 0.0f, 0.0f);
CColor g_objGreen (0.0f, 1.0f, 0.0f);
CColor g_objBlue (0.0f, 0.0f, 1.0f);
CColor g_objYellow (0.0f, 1.0f, 1.0f);
CScene g_objScene = CScene();
CRenderingCore g_Core;
void display(void)
{
static int firstTime;
if (!firstTime) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
g_Core.Render();
glFlush();
}
firstTime = 1;
}
void reshape(int width, int height)
{
/*****************************************************************
STRATEGY:
1. ReDefine the viewport
*****************************************************************/
// 1.
glViewport(0, 0, width, height);
}
void idle(void)
{
glutPostRedisplay();
}
void init () {
/*************************************************************
STRATEGY:
1. Define the clear color
2. Define the projecction volume.
3. Define the modelview projections.
NOTE:
The reason why this code si not inside the reshape function is
that the projection we have is fixed and does not depend upon
the size of the window.
*************************************************************/
// 1.
glClearColor (0, 0, 0, 1);
// 2.
glMatrixMode (GL_PROJECTION);
glLoadIdentity();
glOrtho (0, 640, -480, 0, -10, 10);
// 3.
glMatrixMode (GL_MODELVIEW);
glLoadIdentity();
}
int main(int argc, char** argv)
{
/*************************************************************
Configuration and Initialization
*************************************************************/
g_Log.SetLogFileName ("Log.txt");
g_Log.Write ("\n\n\n **** The log file is operational ****\n");
/************************************************************/ glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGBA | GLUT_SINGLE | GLUT_DEPTH);
glutInitWindowSize(640, 480);
glutCreateWindow("GLUT Program");
glutReshapeFunc(reshape);
glutIdleFunc(idle);
init();
glutDisplayFunc(display);
glutMainLoop();
return EXIT_SUCCESS;
}