|
|
@ -127,14 +127,12 @@ const struct Vertex vertices[] = {
|
|
|
|
{.pos = { 0.5f, -0.5f, 0.5f}, .color = {0.0f, 1.0f, 0.0f}},
|
|
|
|
{.pos = { 0.5f, -0.5f, 0.5f}, .color = {0.0f, 1.0f, 0.0f}},
|
|
|
|
{.pos = { 0.5f, 0.5f, 0.5f}, .color = {0.0f, 0.0f, 1.0f}},
|
|
|
|
{.pos = { 0.5f, 0.5f, 0.5f}, .color = {0.0f, 0.0f, 1.0f}},
|
|
|
|
{.pos = {-0.5f, 0.5f, 0.5f}, .color = {1.0f, 1.0f, 1.0f}},
|
|
|
|
{.pos = {-0.5f, 0.5f, 0.5f}, .color = {1.0f, 1.0f, 1.0f}},
|
|
|
|
|
|
|
|
{.pos = { 0.5f, 0.5f, 1.0f}, .color = {0.0f, 0.0f, 1.0f}},
|
|
|
|
|
|
|
|
{.pos = {-0.5f, 0.5f, 1.0f}, .color = {1.0f, 1.0f, 1.0f}},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//const uint16_t indices[] = {
|
|
|
|
|
|
|
|
// 0, 1, 2, 2, 3, 0,
|
|
|
|
|
|
|
|
//};
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
const uint16_t indices[] = {
|
|
|
|
const uint16_t indices[] = {
|
|
|
|
2, 1, 0, 0, 3, 2,
|
|
|
|
2, 1, 0, 0, 3, 2, 5, 4, 3,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const char * validation_layers[] = {
|
|
|
|
const char * validation_layers[] = {
|
|
|
@ -1647,7 +1645,7 @@ VulkanContext* init_vulkan(GLFWwindow* window, uint32_t max_frames_in_flight) {
|
|
|
|
context->simple_mesh_material = simple_mesh_material;
|
|
|
|
context->simple_mesh_material = simple_mesh_material;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Mesh triangle_mesh = load_mesh(context->physical_device, context->device, (struct Vertex*)vertices, 4, (uint16_t*)indices, 6, context->transfer_command_pool, context->queues.transfer);
|
|
|
|
Mesh triangle_mesh = load_mesh(context->physical_device, context->device, (struct Vertex*)vertices, 6, (uint16_t*)indices, 9, context->transfer_command_pool, context->queues.transfer);
|
|
|
|
if(triangle_mesh.vertex_buffer.buffer == VK_NULL_HANDLE) {
|
|
|
|
if(triangle_mesh.vertex_buffer.buffer == VK_NULL_HANDLE) {
|
|
|
|
fprintf(stderr, "failed to load triangle mesh\n");
|
|
|
|
fprintf(stderr, "failed to load triangle mesh\n");
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -1664,6 +1662,8 @@ struct {
|
|
|
|
bool backward: 1;
|
|
|
|
bool backward: 1;
|
|
|
|
bool left: 1;
|
|
|
|
bool left: 1;
|
|
|
|
bool right: 1;
|
|
|
|
bool right: 1;
|
|
|
|
|
|
|
|
bool up: 1;
|
|
|
|
|
|
|
|
bool down: 1;
|
|
|
|
bool turn_left: 1;
|
|
|
|
bool turn_left: 1;
|
|
|
|
bool turn_right: 1;
|
|
|
|
bool turn_right: 1;
|
|
|
|
} key_flags = {
|
|
|
|
} key_flags = {
|
|
|
@ -1711,6 +1711,22 @@ void key_callback(GLFWwindow* window, int key, int scancode, int action, int mod
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case GLFW_KEY_SPACE:
|
|
|
|
|
|
|
|
if(action == GLFW_PRESS) {
|
|
|
|
|
|
|
|
key_flags.up = true;
|
|
|
|
|
|
|
|
} else if(action == GLFW_RELEASE) {
|
|
|
|
|
|
|
|
key_flags.up = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case GLFW_KEY_LEFT_SHIFT:
|
|
|
|
|
|
|
|
if(action == GLFW_PRESS) {
|
|
|
|
|
|
|
|
key_flags.down = true;
|
|
|
|
|
|
|
|
} else if(action == GLFW_RELEASE) {
|
|
|
|
|
|
|
|
key_flags.down = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case GLFW_KEY_RIGHT:
|
|
|
|
case GLFW_KEY_RIGHT:
|
|
|
|
if(action == GLFW_PRESS) {
|
|
|
|
if(action == GLFW_PRESS) {
|
|
|
|
key_flags.turn_right = true;
|
|
|
|
key_flags.turn_right = true;
|
|
|
@ -1741,11 +1757,19 @@ VkResult update_ubo(void** buffers, uint32_t frame_index) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(key_flags.left) {
|
|
|
|
if(key_flags.left) {
|
|
|
|
movement_sum[0] += 0.01;
|
|
|
|
movement_sum[0] -= 0.01;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(key_flags.right) {
|
|
|
|
if(key_flags.right) {
|
|
|
|
movement_sum[0] -= 0.01;
|
|
|
|
movement_sum[0] += 0.01;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(key_flags.up) {
|
|
|
|
|
|
|
|
movement_sum[1] += 0.01;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(key_flags.down) {
|
|
|
|
|
|
|
|
movement_sum[1] -= 0.01;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(key_flags.turn_right) {
|
|
|
|
if(key_flags.turn_right) {
|
|
|
@ -1757,7 +1781,7 @@ VkResult update_ubo(void** buffers, uint32_t frame_index) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
vec3 forward = {0.0f, 0.0f, 1.0f};
|
|
|
|
vec3 forward = {0.0f, 0.0f, 1.0f};
|
|
|
|
vec3 up = {0.0f, 1.0f, 0.0f};
|
|
|
|
vec3 up = {0.0f, -1.0f, 0.0f};
|
|
|
|
|
|
|
|
|
|
|
|
vec3 dir;
|
|
|
|
vec3 dir;
|
|
|
|
mat4 rot;
|
|
|
|
mat4 rot;
|
|
|
|