Camera and Movementhooks are implemented but Camerarotation is faulty

This commit is contained in:
t
2025-04-07 23:01:58 +02:00
parent ce8bc3a96b
commit 76ea39b784
4 changed files with 215 additions and 26 deletions
+19 -4
View File
@@ -219,6 +219,7 @@ namespace vapp{
VkPhysicalDeviceFeatures deviceFeatures{};
deviceFeatures.samplerAnisotropy = VK_TRUE;
deviceFeatures.sampleRateShading = VK_TRUE;
VkDeviceCreateInfo createInfo{};
createInfo.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO;
@@ -554,6 +555,8 @@ namespace vapp{
multisampling.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
multisampling.sampleShadingEnable = VK_FALSE;
multisampling.rasterizationSamples = msaaSamples;
multisampling.sampleShadingEnable = VK_TRUE;
multisampling.minSampleShading = .8f;
VkPipelineColorBlendAttachmentState colorBlendAttachment{};
colorBlendAttachment.colorWriteMask = VK_COLOR_COMPONENT_R_BIT
@@ -759,9 +762,8 @@ namespace vapp{
if(tiling == VK_IMAGE_TILING_OPTIMAL && (props.optimalTilingFeatures & features) == features){
return format;
}
throw std::runtime_error("Func: findSupportedFormat\nError: Failed to find supported Format!\n");
}
throw std::runtime_error("Func: findSupportedFormat\nError: Failed to find supported Format!\n");
}
VkFormat Vulkan::findDepthFormat(){
@@ -1435,8 +1437,8 @@ namespace vapp{
UniformBufferObject ubo{};
// INFO: Change here for other angles
ubo.model = glm::rotate(glm::mat4(1.0f), time * glm::radians(60.0f), glm::vec3(0.0f, 0.0f, 1.0f));
ubo.view = glm::lookAt(glm::vec3(2.0f, 2.0f, 2.0f), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, 1.0f));
ubo.model = glm::rotate(glm::mat4(1.0f), time * glm::radians(0.0f), glm::vec3(0.0f, 0.0f, 1.0f));
ubo.view = glm::lookAt(cameraPos, cameraFront, cameraUp);
ubo.proj = glm::perspective(glm::radians(45.0f), swapChainExtent.width / (float)swapChainExtent.height, 0.1f, 10.0f);
// removing this line results in the image rendering upside down
@@ -1543,6 +1545,13 @@ namespace vapp{
app->framebufferResized = true;
}
static void handleMouseInputCallback(GLFWwindow* window, double xpos, double ypos) {
Vulkan* vulkan = static_cast<Vulkan*>(glfwGetWindowUserPointer(window));
if (vulkan) {
vulkan->handleMouseInput(window, xpos, ypos);
}
}
void Vulkan::initWindow(const char *windowName){
glfwInit();
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); // tell glfw to not use opengl
@@ -1550,6 +1559,9 @@ namespace vapp{
this->window = glfwCreateWindow(static_cast<int>(_width), static_cast<int>(_height), windowName, nullptr, nullptr);
glfwSetWindowUserPointer(window, this);
glfwSetFramebufferSizeCallback(window, framebufferResizeCallback);
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_CAPTURED);
glfwSetCursorPosCallback(window, handleMouseInputCallback);
}
void Vulkan::initVulkan(){
@@ -1584,6 +1596,9 @@ namespace vapp{
while(!glfwWindowShouldClose(this->window)){
// glfwSwapBuffers(window);
glfwPollEvents();
handleKeyboardInput();
drawFrame();
}
vkDeviceWaitIdle(device);