-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
94 lines (77 loc) · 2.69 KB
/
Copy pathmain.cpp
File metadata and controls
94 lines (77 loc) · 2.69 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*
* CS475/CS675 - Computer Graphics
* Transformers Assignment Base Code
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <cstdlib>
#include <unistd.h>
#include <iostream>
#include <string>
#include "gl_framework.hpp"
#include "animator.hpp"
std::string filename, progname;
Animator animator(512,512);
void key_callback_wrapper(GLFWwindow* window, int key, int scancode, int action, int mods) {
animator.WORLD.robot.keys.key_callback(window,key,scancode,action,mods);
animator.WORLD.key_callback(window,key,scancode,action,mods);
animator.key_callback(window,key,scancode,action,mods);
//!Close the window if the ESC key was pressed
if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
glfwSetWindowShouldClose(window, GL_TRUE);
}
int main (int argc, char *argv[])
{
progname=argv[0];
//! The pointer to the GLFW window
GLFWwindow* window;
//! Setting up the GLFW Error callback
glfwSetErrorCallback(csX75::error_callback);
//! Initialize GLFW
if (!glfwInit())
return -1;
int win_width=512;
int win_height=512;
//! Create a windowed mode window and its OpenGL context
window = glfwCreateWindow(win_width, win_height, "Transformers", NULL, NULL);
if (!window)
{
glfwTerminate();
return -1;
}
//! Make the window's context current
glfwMakeContextCurrent(window);
//Keyboard Callback
glfwSetKeyCallback(window, key_callback_wrapper);
//Framebuffer resize callback
glfwSetFramebufferSizeCallback(window, csX75::framebuffer_size_callback);
// Ensure we can capture the escape key being pressed below
glfwSetInputMode(window, GLFW_STICKY_KEYS, GL_TRUE);
glfwGetFramebufferSize(window, &win_width, &win_height);
csX75::framebuffer_size_callback(window, win_width, win_height);
//Initialize GL state
csX75::initGL();
// Initialize animator, world and robot
animator = Animator(win_width,win_height);
glScalef(0.5,0.5,0.5);
// Loop until the user closes the window
while (glfwWindowShouldClose(window) == 0)
{
// Render here
animator.renderFrame();
}
glfwDestroyWindow(window);
glfwTerminate();
return 0;
}