|
|
|
@ -9,6 +9,7 @@
|
|
|
|
|
#define GLM_FORCE_DEPTH_ZERO_TO_ONE
|
|
|
|
|
#include <cglm/types.h>
|
|
|
|
|
#include <cglm/mat4.h>
|
|
|
|
|
#include <cglm/vec3.h>
|
|
|
|
|
#include <cglm/affine.h>
|
|
|
|
|
#include <cglm/cam.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
@ -1729,32 +1730,32 @@ void key_callback(GLFWwindow* window, int key, int scancode, int action, int mod
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
VkResult update_ubo(void** buffers, uint32_t frame_index) {
|
|
|
|
|
vec3 movement_sum = {0.0f, 0.0f, 0.0f};
|
|
|
|
|
|
|
|
|
|
if(key_flags.forward) {
|
|
|
|
|
world_position[2] += 0.01;
|
|
|
|
|
movement_sum[2] += 0.01;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(key_flags.backward) {
|
|
|
|
|
world_position[2] -= 0.01;
|
|
|
|
|
movement_sum[2] -= 0.01;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(key_flags.left) {
|
|
|
|
|
world_position[0] -= 0.01;
|
|
|
|
|
movement_sum[0] += 0.01;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(key_flags.right) {
|
|
|
|
|
world_position[0] += 0.01;
|
|
|
|
|
movement_sum[0] -= 0.01;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(key_flags.turn_right) {
|
|
|
|
|
rotation += 0.01;
|
|
|
|
|
rotation -= 0.01;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(key_flags.turn_left) {
|
|
|
|
|
rotation -= 0.01;
|
|
|
|
|
rotation += 0.01;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct SceneUBO ubo = {};
|
|
|
|
|
glm_perspective(30.0f, 800.0/600.0, 0.1, 1, ubo.proj);
|
|
|
|
|
vec3 forward = {0.0f, 0.0f, 1.0f};
|
|
|
|
|
vec3 up = {0.0f, 1.0f, 0.0f};
|
|
|
|
|
|
|
|
|
@ -1763,6 +1764,12 @@ VkResult update_ubo(void** buffers, uint32_t frame_index) {
|
|
|
|
|
glm_rotate_make(rot, rotation, up);
|
|
|
|
|
glm_mat4_mulv3(rot, forward, 1.0f, dir);
|
|
|
|
|
|
|
|
|
|
vec3 movement_rot;
|
|
|
|
|
glm_mat4_mulv3(rot, movement_sum, 1.0f, movement_rot);
|
|
|
|
|
glm_vec3_add(movement_rot, world_position, world_position);
|
|
|
|
|
|
|
|
|
|
struct SceneUBO ubo = {};
|
|
|
|
|
glm_perspective(90.0f, 800.0/600.0, 0.1, 100, ubo.proj);
|
|
|
|
|
glm_look(world_position, dir, up, ubo.view);
|
|
|
|
|
|
|
|
|
|
memcpy(buffers[frame_index], (void*)&ubo, sizeof(ubo));
|
|
|
|
|