Added camera

Moved some math types
Added some more vector types
Did the camera matrix calulations
Updated shaders to take push constants
This commit is contained in:
2025-10-05 02:40:59 +01:00
parent 2c67896cf2
commit 3b8c50a361
15 changed files with 355 additions and 70 deletions

View File

@@ -171,10 +171,17 @@ void G_PipelinesLoad(G_State *game) {
vk.CreateDescriptorSetLayout(vk.device, &set_info, 0, &basic->layout.set);
VkPushConstantRange push_range = { 0 };
push_range.stageFlags = VK_SHADER_STAGE_VERTEX_BIT;
push_range.offset = 0;
push_range.size = 128;
VkPipelineLayoutCreateInfo layout_create = { 0 };
layout_create.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
layout_create.setLayoutCount = 1;
layout_create.pSetLayouts = &basic->layout.set;
layout_create.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
layout_create.setLayoutCount = 1;
layout_create.pSetLayouts = &basic->layout.set;
layout_create.pushConstantRangeCount = 1;
layout_create.pPushConstantRanges = &push_range;
vk.CreatePipelineLayout(vk.device, &layout_create, 0, &basic->layout.pipeline);
}
@@ -193,6 +200,14 @@ void G_PipelinesLoad(G_State *game) {
Vk_PipelineCreate(basic);
}
void G_CalulateCamera(G_Camera *camera, F32 aspect) {
Mat4x4FInv proj = M4x4F_Perspective(camera->fov, aspect, camera->nearp, camera->farp);
Mat4x4FInv view = M4x4F_CameraView(camera->x, camera->y, camera->z, camera->p);
camera->proj.fwd = M4x4F_Mul(proj.fwd, view.fwd);
camera->proj.inv = M4x4F_Mul(view.inv, proj.inv);
}
#include "impl/aabb.c"
#include "impl/nav.c"
#include "impl/player.c"