Repository navigation
Expand file tree
/
Copy pathmain.cpp
More file actions
70 lines (62 loc) · 1.68 KB
/
Copy pathmain.cpp
File metadata and controls
70 lines (62 loc) · 1.68 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
65
66
67
68
69
70
#include "main.h"
#include <unistd.h>
#include <iostream.h>
using namespace std;
int WIDTH = 1200; // screen resolution
int HEIGHT = 900;
float center_x = 0.0;
float center_y = 0.0;
float center_z = 0.0;
void Display()
{
scene1();
};
void keyboard (unsigned char key, int x, int y){
switch (key)
{
case 27: /* ESC */
glutDestroyWindow(winIdMain);
glutLeaveGameMode();
printf ("Exit gracefully\n");
exit (0);
}
}
/* Callback function for reshaping the main window */
void mainReshape (int w, int h) {
glViewport (0, 0, w, h);
glMatrixMode (GL_PROJECTION);
gluPerspective (
40.0, /* Field of view in degree */
1.25, /* aspect ratio e.g. 1280 divided by 1024 */
1.0, /* Z near */
300.0 /* Z far */ );
gluLookAt (
0.0, 0.0, 10.0, /* Eye is at */
center_x, center_y, center_z, /* Center is at */
0.0, 1.0, 0.0 /* Up is in positive Y direction */ );
};
void idle () {
glutSetWindow (winIdMain);
glutPostRedisplay ();
};
void *glutmain(void *arg) {
glutMainLoop (); // keep on looping in this main fucntion
return 0;
}
int main (int argc, char **argv) {
/* Global end signal of demo */
/* Glut initializations */
glutInit (&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
glutGameModeString("1440x900");
glutEnterGameMode();
glutSetCursor(GLUT_CURSOR_NONE); // no mouse pointer
glutAddMenuEntry("Quit", 1);
glutAttachMenu(GLUT_RIGHT_BUTTON);
glutDisplayFunc(Display); // Let's draw something
glutReshapeFunc(mainReshape); // if windows is resized
glutKeyboardFunc(keyboard); // some keybindings
glutIdleFunc(idle); // idle loop for timer increment
glutmain(NULL);
return 0; // die clean
};