52 lines
2.0 KiB
C++
52 lines
2.0 KiB
C++
#include "vulkan_app.hpp"
|
|
|
|
namespace vapp{
|
|
void Vulkan::processInput(){
|
|
float currentFrame = static_cast<float>(glfwGetTime());
|
|
deltaTime = currentFrame - lastFrame;
|
|
lastFrame = currentFrame;
|
|
|
|
if(glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS)
|
|
camera.ProcessKeyboard(FORWARD, deltaTime);
|
|
if(glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS)
|
|
camera.ProcessKeyboard(BACKWARD, deltaTime);
|
|
if(glfwGetKey(window, GLFW_KEY_A) == GLFW_PRESS)
|
|
camera.ProcessKeyboard(LEFT, deltaTime);
|
|
if(glfwGetKey(window, GLFW_KEY_D) == GLFW_PRESS)
|
|
camera.ProcessKeyboard(RIGHT, deltaTime);
|
|
if(glfwGetKey(window, GLFW_KEY_SPACE) == GLFW_PRESS)
|
|
camera.ProcessKeyboard(UP, deltaTime);
|
|
if(glfwGetKey(window, GLFW_KEY_LEFT_CONTROL) == GLFW_PRESS)
|
|
camera.ProcessKeyboard(DOWN, deltaTime);
|
|
}
|
|
|
|
void Vulkan::keyCallback(GLFWwindow *window, int key, int scancode, int action, int mods){
|
|
Vulkan *app = static_cast<Vulkan*>(glfwGetWindowUserPointer(window));
|
|
if(key == GLFW_KEY_LEFT_SHIFT){
|
|
if(action == GLFW_PRESS)
|
|
app->camera.MovementSpeed = 5.0f;
|
|
else if(action == GLFW_RELEASE)
|
|
app->camera.MovementSpeed = 2.5f;
|
|
}
|
|
}
|
|
|
|
void Vulkan::mouseCallback(GLFWwindow *window, double xpos, double ypos){
|
|
auto app = static_cast<Vulkan*>(glfwGetWindowUserPointer(window));
|
|
if(app->firstMouse){
|
|
app->lastX = xpos;
|
|
app->lastY = ypos;
|
|
app->firstMouse = false;
|
|
}
|
|
float xoff = xpos - app->lastX;
|
|
float yoff = app->lastY - ypos;
|
|
app->lastX = xpos;
|
|
app->lastY = ypos;
|
|
app->camera.ProcessMouseMovement(xoff, yoff);
|
|
}
|
|
|
|
void Vulkan::scrollCallback(GLFWwindow *window, double /*x*/, double yoffset){
|
|
Vulkan *app = static_cast<Vulkan*>(glfwGetWindowUserPointer(window));
|
|
app->camera.ProcessMouseScroll(static_cast<float>(yoffset));
|
|
}
|
|
}
|