-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
76 lines (63 loc) · 1.91 KB
/
main.cpp
File metadata and controls
76 lines (63 loc) · 1.91 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
71
72
73
74
75
76
#include "stdafx.h"
#include "GameFramework.h"
GLvoid Keyboard(unsigned char key, int x, int y);
GLvoid TimerFunction(int value);
GLvoid drawScene(GLvoid);
GLvoid Reshape(int w, int h);
GLvoid mouse(int button, int state, int x, int y);
GLvoid mouseMotion(int x, int y);
GameFramework GameManager;
void main(int argc, char** argv) //--- 윈도우 출력하고 콜백함수 설정
{
//--- 윈도우 생성하기
glutInit(&argc, argv); // glut 초기화
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA); // 디스플레이 모드 설정
glutInitWindowPosition(0, 0); // 윈도우의 위치 지정
glutInitWindowSize(WINDOW_LENGTH, WINDOW_HEIGHT); // 윈도우의 크기 지정
glutCreateWindow("Rolling Space"); // 윈도우 생성(윈도우 이름)
//--- GLEW 초기화하기
glewExperimental = GL_TRUE;
if (glewInit() != GLEW_OK) // glew 초기화
{
std::cerr << "Unable to initialize GLEW" << std::endl;
exit(EXIT_FAILURE);
}
else
std::cout << "GLEW Initialized\n";
GameManager.Create();
glutMotionFunc(mouseMotion);
glutMouseFunc(mouse);
glutKeyboardFunc(Keyboard);
glutDisplayFunc(drawScene); // 출력 콜백함수의 지정
glutReshapeFunc(Reshape); // 다시 그리기 콜백함수 지정
glutTimerFunc(10, TimerFunction, 1);
glutMainLoop(); // 이벤트 처리 시작
}
GLvoid drawScene()
{
GameManager.OnDraw();
glutSwapBuffers(); // 화면에 출력하기
}
GLvoid Reshape(int w, int h) //--- 콜백 함수: 다시 그리기 콜백 함수
{
glViewport(0, 0, w, h);
}
GLvoid Keyboard(unsigned char key, int x, int y) {
GameManager.KeyBoard(key, x, y);
glutPostRedisplay();
}
GLvoid TimerFunction(int value) {
GameManager.curFrameTime = clock();
GameManager.OnUpdate(GameManager.GetTick());
glutTimerFunc(10, TimerFunction, 0);
GameManager.prevFrameTime = GameManager.curFrameTime;
glutPostRedisplay();
}
GLvoid mouse(int button, int state, int x, int y) {
GameManager.Mouse(button, state, x, y);
glutPostRedisplay();
}
GLvoid mouseMotion(int x, int y) {
GameManager.MouseMotion(x, y);
glutPostRedisplay();
}