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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<pre> /***********************************************************
* A Template for building OpenGL applications using GLUT
*
* Author: Perspective @ cprogramming.com
* Date : Jan, 2005
*
* Description:
* This code initializes an OpenGL ready window
* using GLUT. Some of the most common callbacks
* are registered to empty or minimal functions.
*
* This code is intended to be a quick starting point
* when building GLUT applications.
*
***********************************************************/
//#include <windows.h>
#include <iostream>
#include <GL/glut.h>
/* process menu option 'op' */
void menu(int op) {
switch(op) {
case 'Q':
case 'q':
exit(0);
}
}
/* executed when a regular key is pressed */
void keyboardDown(unsigned char key, int x, int y) {
switch(key) {
case 'Q':
case 'q':
case 27: // ESC
exit(0);
}
}
/* executed when a regular key is released */
void keyboardUp(unsigned char key, int x, int y) {
}
/* executed when a special key is pressed */
void keyboardSpecialDown(int k, int x, int y) {
}
/* executed when a special key is released */
void keyboardSpecialUp(int k, int x, int y) {
}
/* reshaped window */
void reshape(int width, int height) {
GLfloat fieldOfView = 90.0f;
glViewport (0, 0, (GLsizei) width, (GLsizei) height);
glMatrixMode (GL_PROJECTION);
glLoadIdentity();
gluPerspective(fieldOfView, (GLfloat) width/(GLfloat) height, 0.1, 500.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
/* executed when button 'button' is put into state 'state' at screen position ('x', 'y') */
void mouseClick(int button, int state, int x, int y) {
}