-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
123 lines (103 loc) · 2.07 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#include "main.h"
#include "mygl.h"
myGL gl;
// プロトタイプ宣言
void initCallFunc();
void setCallBackFunction();
void display0();
void display1();
void reshape0(int, int);
void reshape1(int, int);
void idle();
void mouseClick(int button, int state, int x, int y);
void mouseMotion(int x, int y);
void mouseWheel(int wheel_number, int direction, int x, int y);
void keyboard(unsigned char key, int x, int y);
void timer(int value);
void close();
int main(int argc, char *argv[])
{
glutInit(&argc, argv);
initCallFunc();
return 0;
}
// 最初だけ呼ばれる関数(サブスレッドのrunの中で呼ぶ)
void initCallFunc()
{
// 各コールバック関数の設定
setCallBackFunction();
gl.initialize();
// ループ開始
glutMainLoop();
}
// コールバック関数の設定
void setCallBackFunction()
{
// Window1
gl.createWindow(0);
glutDisplayFunc(display0);
glutReshapeFunc(reshape0);
glutIdleFunc(idle);
glutKeyboardFunc(keyboard);
glutMouseFunc(mouseClick);
glutMotionFunc(mouseMotion);
glutMouseWheelFunc(mouseWheel);
glutTimerFunc(unsigned int(0.01*1000), timer, 0);
glutCloseFunc(close);
gl.initWindow(0);
// Window2
gl.createWindow(1);
glutDisplayFunc(display1);
glutReshapeFunc(reshape1);
glutIdleFunc(idle);
gl.initWindow(1);
// Window3
//gl.createWindow(2);
//glutDisplayFunc(display);
//glutReshapeFunc(reshape);
//glutIdleFunc(idle);
}
// クラス内の関数は直接コールバックに使えないので普通の関数を介する
void display0()
{
gl.display_camera_view();
}
void display1()
{
gl.display_projector_view();
}
void idle()
{
gl.idle();
}
void reshape0(int w, int h)
{
gl.reshape(w, h);
}
void reshape1(int w, int h)
{
gl.reshape(w, h);
}
void mouseClick(int button, int state, int x, int y )
{
gl.mouseClick(button, state, x, y);
}
void mouseMotion(int x, int y)
{
gl.mouseMotion(x, y);
}
void mouseWheel(int wheel_number, int direction, int x, int y)
{
gl.mouseWheel(wheel_number, direction, x, y);
}
void keyboard(unsigned char key, int x, int y)
{
gl.keyboard(key, x, y);
}
void timer(int value){
gl.timer(value);
glutTimerFunc(unsigned int(0.01*1000), timer, 0);
}
void close(){
gl.close();
}