Add basic camera controls

This commit is contained in:
4VRDriver
2020-09-03 18:18:32 +02:00
parent 919f65fac7
commit ee6e783c3f
7 changed files with 92 additions and 9 deletions

View File

@@ -11,10 +11,26 @@ EventHandler::EventHandler(GLFWwindow *p_window)
void EventHandler::handleEvents() {
glfwPollEvents();
for(int i=0; i<CAMERA_ACTION_NUM_ITEMS; i++) {
actionCameraRegister[i] = 0;
}
if(glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)
glfwSetWindowShouldClose(window, true);
if (glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS)
actionCameraRegister[cameraForward] = 1;
if (glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS)
actionCameraRegister[cameraBackward] = 1;
if (glfwGetKey(window, GLFW_KEY_SPACE) == GLFW_PRESS)
actionCameraRegister[cameraUp] = 1;
if (glfwGetKey(window, GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS)
actionCameraRegister[cameraDown] = 1;
if (glfwGetKey(window, GLFW_KEY_A) == GLFW_PRESS)
actionCameraRegister[cameraLeft] = 1;
if (glfwGetKey(window, GLFW_KEY_D) == GLFW_PRESS)
actionCameraRegister[cameraRight] = 1;
}
void EventHandler::key_callback(GLFWwindow *p_window, int key, int scancode, int action, int mods) {