-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
87 lines (59 loc) · 1.76 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
//
// Created by Jaime Blasco, Clara Landaríbar, Belén García on May 2018.
//
#include "core/GLCore.hpp"
#include "core/Game.hpp"
#include "core/Window.hpp"
#include "core/MouseController.hpp"
#include "core/KeyboardController.hpp"
void onDisplay();
void onIdle();
void glutConfig(int argc, char* argv[]);
#define NAME "Klondike"
#define W 640
#define H 480
int main(int argc, char* argv[]) {
glutConfig(argc, argv);
Game::init();
glutMainLoop();
return 0;
}
void onDisplay() {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glBackgroundColor(Color(167, 204, 237));
glLoadIdentity();
Game::draw();
Game::update();
glutSwapBuffers();
}
// update all instances animation
void onIdle() { Game::update(); }
void glutConfig(int argc, char* argv[]) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
glutInitWindowSize(W, H);
glutInitWindowPosition(100, 100);
glutCreateWindow(NAME);
glutDisplayFunc(onDisplay);
glutIdleFunc(onIdle);
glutReshapeFunc(Window::onResize);
glutSpecialFunc(Keyboard::onArrowDown);
glutKeyboardFunc(Keyboard::onKeyDown);
glutMouseFunc(Mouse::onClick);
glutMotionFunc(Mouse::onClickMotion);
glutPassiveMotionFunc(Mouse::onMotion);
glEnable(GL_DEPTH_TEST);
glPointSize(5.0);
glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);
glEnable(GL_BLEND);
glEnable(GL_POINT_SMOOTH);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// Set lighting intensity and color
GLfloat qaAmbientLight[] = { 0.415,0.717, 0.9, 0.1 };
glLightfv(GL_LIGHT0, GL_AMBIENT, qaAmbientLight);
// Light source position
GLfloat qaLightPosition[] = { 0, 1, 0, 1 };
glLightfv(GL_LIGHT0, GL_POSITION, qaLightPosition);
GLfloat globalAmbient[] = { 0,0,0 };
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, globalAmbient);
}