-
Notifications
You must be signed in to change notification settings - Fork 0
/
controls.h
63 lines (55 loc) · 1.34 KB
/
controls.h
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
#include <iostream>
#include <math.h>
#include <vector>
// GLEW
#define GLEW_STATIC
#include <GL/glew.h>
//GLM
#define GLM_FORCE_RADIANS
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
// GLFW
#include <GLFW/glfw3.h>
extern glm::vec3 camPosition;
//extern GLFWwindow* window;
using namespace std;
void scroll_callback(GLFWwindow* window, double xoffset, double yoffset)
{
float camHeight=camPosition.z;
if(camHeight<=9900 && yoffset<00)
camHeight+=100;
if(camHeight>=200 && yoffset>00)
camHeight-=100;
camPosition.z=camHeight;
}
void key_callback(GLFWwindow* window, int key, int scancode, int action, int mode)
{
//std::cout << key << std::endl;
if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
glfwSetWindowShouldClose(window, GL_TRUE);
else if (key == GLFW_KEY_RIGHT && camPosition.x<9900)
{
camPosition.x += 100;
}
else if (key == GLFW_KEY_LEFT && camPosition.x>-9900)
{
camPosition.x -= 100;
}
else if (key == GLFW_KEY_KP_ADD && camPosition.z>200)
{
camPosition.z -= 100;
}
else if (key == GLFW_KEY_KP_SUBTRACT && camPosition.z<9900)
{
camPosition.z += 100;
}
else if (key == GLFW_KEY_UP)
{
camPosition.y += 100;
}
else if (key == GLFW_KEY_DOWN)
{
camPosition.y -= 100;
}
}