59 lines
2.1 KiB
C++
59 lines
2.1 KiB
C++
#include "funcs.h"
|
|
|
|
void framebuffer_size_callback(GLFWwindow* window, int width, int height) {
|
|
glViewport(0, 0, width, height);
|
|
}
|
|
|
|
void processInput(GLFWwindow* window) {
|
|
if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS) {
|
|
glfwSetWindowShouldClose(window, true);
|
|
}
|
|
if (glfwGetKey(window, GLFW_KEY_LEFT) == GLFW_PRESS) {
|
|
cam->yaw(1.0f*deltaTime);
|
|
}
|
|
if (glfwGetKey(window, GLFW_KEY_RIGHT) == GLFW_PRESS) {
|
|
cam->yaw(-1.0f*deltaTime);
|
|
}
|
|
if (glfwGetKey(window, GLFW_KEY_UP) == GLFW_PRESS) {
|
|
cam->pitch(1.0f*deltaTime);
|
|
}
|
|
if (glfwGetKey(window, GLFW_KEY_DOWN) == GLFW_PRESS) {
|
|
cam->pitch(-1.0f*deltaTime);
|
|
}
|
|
if (glfwGetKey(window, GLFW_KEY_PERIOD) == GLFW_PRESS) {
|
|
cam->roll(1.0f*deltaTime);
|
|
}
|
|
if (glfwGetKey(window, GLFW_KEY_COMMA) == GLFW_PRESS) {
|
|
cam->roll(-1.0f*deltaTime);
|
|
}
|
|
if (glfwGetKey(window, GLFW_KEY_A) == GLFW_PRESS) {
|
|
cam->panPosRelative(glm::vec3(-1.5f, 0.0f, 0.0f)*deltaTime);
|
|
}
|
|
if (glfwGetKey(window, GLFW_KEY_D) == GLFW_PRESS) {
|
|
cam->panPosRelative(glm::vec3(1.5f, 0.0f, 0.0f)*deltaTime);
|
|
}
|
|
if (glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS) {
|
|
cam->panPosRelative(glm::vec3(0.0f, 0.0f, 1.5f)*deltaTime);
|
|
}
|
|
if (glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS) {
|
|
cam->panPosRelative(glm::vec3(0.0f, 0.0f, -1.5f)*deltaTime);
|
|
}
|
|
if (glfwGetKey(window, GLFW_KEY_SPACE) == GLFW_PRESS) {
|
|
cam->panPosRelative(glm::vec3(0.0f, 1.5f, 0.0f)*deltaTime);
|
|
}
|
|
if (glfwGetKey(window, GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS) {
|
|
cam->panPosRelative(glm::vec3(0.0f, -1.5f, 0.0f)*deltaTime);
|
|
}
|
|
if (glfwGetKey(window, GLFW_KEY_Q) == GLFW_PRESS) {
|
|
cam->setPos(glm::vec3(0.0f, 0.0f, -2.0f));
|
|
cam->setTarget(glm::vec3(0.0f, 0.0f, 0.0f));
|
|
cam->resetUp();
|
|
}
|
|
if (glfwGetKey(window, GLFW_KEY_L) == GLFW_PRESS) {
|
|
cam->lockToWorldUp(true);
|
|
cam->resetUp();
|
|
}
|
|
if (glfwGetKey(window, GLFW_KEY_O) == GLFW_PRESS) {
|
|
cam->lockToWorldUp(false);
|
|
}
|
|
} |