summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOmniscient <17525998+omnisci3nce@users.noreply.github.com>2024-03-31 15:35:04 +1100
committerOmniscient <17525998+omnisci3nce@users.noreply.github.com>2024-03-31 15:35:04 +1100
commita56349f682862f065c5e5af6183643fcb1f19617 (patch)
tree65dbee62ec2519f5d39b125f2d551c669b09703f
parent6463c6c1090644438d8449f7ae1a152a4a196123 (diff)
redo cube primitive vertex and normals
-rw-r--r--examples/input/ex_input.c18
-rw-r--r--src/maths/maths.h42
-rw-r--r--src/maths/primitives.h160
-rw-r--r--src/renderer/backends/backend_vulkan.c46
4 files changed, 196 insertions, 70 deletions
diff --git a/examples/input/ex_input.c b/examples/input/ex_input.c
index f102fad..3101968 100644
--- a/examples/input/ex_input.c
+++ b/examples/input/ex_input.c
@@ -23,20 +23,19 @@ void update_camera_rotation(input_state* input, game_state* game, camera* cam);
int main() {
core* core = core_bringup();
- vec3 cam_pos = vec3_create(-15, 20.0, 13);
+ vec3 cam_pos = vec3_create(5, 5, 5);
game_state game = {
.camera = camera_create(cam_pos, vec3_negate(cam_pos), VEC3_Y, deg_to_rad(45.0)),
.camera_euler = vec3_create(90, 0, 0),
.first_mouse_update = true,
};
- // model_handle cube_handle = prim_cube_new(core);
-
printf("Starting look direction: ");
print_vec3(game.camera.front);
// Main loop
- const f32 camera_speed = 0.4;
+ const f32 camera_lateral_speed = 0.2;
+ const f32 camera_zoom_speed = 0.15;
while (!should_exit(core)) {
input_update(&core->input);
@@ -44,18 +43,18 @@ int main() {
vec3 translation = VEC3_ZERO;
if (key_is_pressed(KEYCODE_W) || key_is_pressed(KEYCODE_KEY_UP)) {
printf("Move Forwards\n");
- translation = vec3_mult(game.camera.front, camera_speed);
+ translation = vec3_mult(game.camera.front, camera_zoom_speed);
} else if (key_is_pressed(KEYCODE_S) || key_is_pressed(KEYCODE_KEY_DOWN)) {
printf("Move Backwards\n");
- translation = vec3_mult(game.camera.front, -camera_speed);
+ translation = vec3_mult(game.camera.front, -camera_zoom_speed);
} else if (key_is_pressed(KEYCODE_A) || key_is_pressed(KEYCODE_KEY_LEFT)) {
printf("Move Left\n");
vec3 lateral = vec3_normalise(vec3_cross(game.camera.front, game.camera.up));
- translation = vec3_mult(lateral, -camera_speed);
+ translation = vec3_mult(lateral, -camera_lateral_speed);
} else if (key_is_pressed(KEYCODE_D) || key_is_pressed(KEYCODE_KEY_RIGHT)) {
printf("Move Right\n");
vec3 lateral = vec3_normalise(vec3_cross(game.camera.front, game.camera.up));
- translation = vec3_mult(lateral, camera_speed);
+ translation = vec3_mult(lateral, camera_lateral_speed);
}
game.camera.position = vec3_add(game.camera.position, translation);
// update_camera_rotation(&core->input, &game, &game.camera);
@@ -64,7 +63,6 @@ int main() {
render_frame_begin(&core->renderer);
- // model cube = core->models->data[cube_handle.raw];
mat4 model = mat4_translation(VEC3_ZERO);
gfx_backend_draw_frame(&core->renderer, &game.camera, model);
@@ -86,7 +84,7 @@ void update_camera_rotation(input_state* input, game_state* game, camera* cam) {
game->first_mouse_update = false;
}
- float sensitivity = 0.1f; // change this value to your liking
+ float sensitivity = 0.2f; // change this value to your liking
xoffset *= sensitivity;
yoffset *= sensitivity;
diff --git a/src/maths/maths.h b/src/maths/maths.h
index 6fa2f9b..1432581 100644
--- a/src/maths/maths.h
+++ b/src/maths/maths.h
@@ -132,6 +132,27 @@ static inline mat4 mat4_mult(mat4 lhs, mat4 rhs) {
return out_matrix;
}
+static mat4 mat4_transposed(mat4 matrix) {
+ mat4 out_matrix = mat4_ident();
+ out_matrix.data[0] = matrix.data[0];
+ out_matrix.data[1] = matrix.data[4];
+ out_matrix.data[2] = matrix.data[8];
+ out_matrix.data[3] = matrix.data[12];
+ out_matrix.data[4] = matrix.data[1];
+ out_matrix.data[5] = matrix.data[5];
+ out_matrix.data[6] = matrix.data[9];
+ out_matrix.data[7] = matrix.data[13];
+ out_matrix.data[8] = matrix.data[2];
+ out_matrix.data[9] = matrix.data[6];
+ out_matrix.data[10] = matrix.data[10];
+ out_matrix.data[11] = matrix.data[14];
+ out_matrix.data[12] = matrix.data[3];
+ out_matrix.data[13] = matrix.data[7];
+ out_matrix.data[14] = matrix.data[11];
+ out_matrix.data[15] = matrix.data[15];
+ return out_matrix;
+}
+
#if defined(CEL_REND_BACKEND_VULKAN)
/** @brief Creates a perspective projection matrix compatible with Vulkan */
static inline mat4 mat4_perspective(f32 fov_radians, f32 aspect_ratio, f32 near_clip,
@@ -143,12 +164,31 @@ static inline mat4 mat4_perspective(f32 fov_radians, f32 aspect_ratio, f32 near_
mat4 out_matrix = { .data = { 0 } };
out_matrix.data[0] = 1.0f / (aspect_ratio * half_tan_fov);
- out_matrix.data[5] = -1.0f / half_tan_fov; // Flip Y-axis for Vulkan
+ out_matrix.data[5] = 1.0f / half_tan_fov; // Flip Y-axis for Vulkan
out_matrix.data[10] = -((far_clip + near_clip) / (far_clip - near_clip));
out_matrix.data[11] = -1.0f;
out_matrix.data[14] = -((2.0f * far_clip * near_clip) / (far_clip - near_clip));
+ // float half_tan_fov = tanf(fov_radians * 0.5);
+ // float k = far_clip / (far_clip - near_clip);
+
+ // out_matrix.data[0] = 1.0f / (aspect_ratio * half_tan_fov);
+ // out_matrix.data[5] = 1.0f / half_tan_fov;
+ // out_matrix.data[10] = k;
+ // out_matrix.data[11] = -1.0;
+ // out_matrix.data[14] = -1.0 * near_clip * k;
+
+ // f32 half_tan_fov = tan(fov_radians * 0.5f);
+ // out_matrix.data[0] = 1.0f / (aspect_ratio * half_tan_fov);
+ // out_matrix.data[5] = 1.0f / half_tan_fov;
+ // out_matrix.data[10] = -((far_clip + near_clip) / (far_clip - near_clip));
+ // out_matrix.data[11] = -1.0f;
+ // out_matrix.data[14] =
+ // -((2.0f * far_clip * near_clip) / (far_clip - near_clip));
+ // return out_matrix;
+
return out_matrix;
+ // return mat4_transposed(out_matrix);
}
#else
/** @brief Creates a perspective projection matrix */
diff --git a/src/maths/primitives.h b/src/maths/primitives.h
index fd798c1..77dbbae 100644
--- a/src/maths/primitives.h
+++ b/src/maths/primitives.h
@@ -1,55 +1,135 @@
#pragma once
#include <assert.h>
+#include <stdlib.h>
#include "core.h"
+#include "maths.h"
#include "render_types.h"
-static float cube_vertices[] = {
- // positions // normals // texture coords
- -0.5f, -0.5f, -0.5f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, 0.5f, -0.5f, -0.5f, 0.0f,
- 0.0f, -1.0f, 1.0f, 0.0f, 0.5f, 0.5f, -0.5f, 0.0f, 0.0f, -1.0f, 1.0f, 1.0f,
- 0.5f, 0.5f, -0.5f, 0.0f, 0.0f, -1.0f, 1.0f, 1.0f, -0.5f, 0.5f, -0.5f, 0.0f,
- 0.0f, -1.0f, 0.0f, 1.0f, -0.5f, -0.5f, -0.5f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f,
-
- -0.5f, -0.5f, 0.5f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.5f, -0.5f, 0.5f, 0.0f,
- 0.0f, 1.0f, 1.0f, 0.0f, 0.5f, 0.5f, 0.5f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f,
- 0.5f, 0.5f, 0.5f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, -0.5f, 0.5f, 0.5f, 0.0f,
- 0.0f, 1.0f, 0.0f, 1.0f, -0.5f, -0.5f, 0.5f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f,
-
- -0.5f, 0.5f, 0.5f, -1.0f, 0.0f, 0.0f, 1.0f, 0.0f, -0.5f, 0.5f, -0.5f, -1.0f,
- 0.0f, 0.0f, 1.0f, 1.0f, -0.5f, -0.5f, -0.5f, -1.0f, 0.0f, 0.0f, 0.0f, 1.0f,
- -0.5f, -0.5f, -0.5f, -1.0f, 0.0f, 0.0f, 0.0f, 1.0f, -0.5f, -0.5f, 0.5f, -1.0f,
- 0.0f, 0.0f, 0.0f, 0.0f, -0.5f, 0.5f, 0.5f, -1.0f, 0.0f, 0.0f, 1.0f, 0.0f,
-
- 0.5f, 0.5f, 0.5f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.5f, 0.5f, -0.5f, 1.0f,
- 0.0f, 0.0f, 1.0f, 1.0f, 0.5f, -0.5f, -0.5f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f,
- 0.5f, -0.5f, -0.5f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.5f, -0.5f, 0.5f, 1.0f,
- 0.0f, 0.0f, 0.0f, 0.0f, 0.5f, 0.5f, 0.5f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f,
-
- -0.5f, -0.5f, -0.5f, 0.0f, -1.0f, 0.0f, 0.0f, 1.0f, 0.5f, -0.5f, -0.5f, 0.0f,
- -1.0f, 0.0f, 1.0f, 1.0f, 0.5f, -0.5f, 0.5f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f,
- 0.5f, -0.5f, 0.5f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f, -0.5f, -0.5f, 0.5f, 0.0f,
- -1.0f, 0.0f, 0.0f, 0.0f, -0.5f, -0.5f, -0.5f, 0.0f, -1.0f, 0.0f, 0.0f, 1.0f,
-
- -0.5f, 0.5f, -0.5f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.5f, 0.5f, -0.5f, 0.0f,
- 1.0f, 0.0f, 1.0f, 1.0f, 0.5f, 0.5f, 0.5f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f,
- 0.5f, 0.5f, 0.5f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, -0.5f, 0.5f, 0.5f, 0.0f,
- 1.0f, 0.0f, 0.0f, 0.0f, -0.5f, 0.5f, -0.5f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f
-};
+static const vec3 BACK_BOT_LEFT = (vec3){ 0, 0, 0 };
+static const vec3 BACK_BOT_RIGHT = (vec3){ 1, 0, 0 };
+static const vec3 BACK_TOP_LEFT = (vec3){ 0, 1, 0 };
+static const vec3 BACK_TOP_RIGHT = (vec3){ 1, 1, 0 };
+static const vec3 FRONT_BOT_LEFT = (vec3){ 0, 0, 1 };
+static const vec3 FRONT_BOT_RIGHT = (vec3){ 1, 0, 1 };
+static const vec3 FRONT_TOP_LEFT = (vec3){ 0, 1, 1 };
+static const vec3 FRONT_TOP_RIGHT = (vec3){ 1, 1, 1 };
static mesh prim_cube_mesh_create() {
mesh cube = { 0 };
cube.vertices = vertex_darray_new(36);
- for (int i = 0; i < 36; i++) {
- vertex vert = { .position = vec3_create(cube_vertices[(i * 8) + 0], cube_vertices[(i * 8) + 1],
- cube_vertices[(i * 8) + 2]),
- .normal = vec3_create(cube_vertices[(i * 8) + 3], cube_vertices[(i * 8) + 4],
- cube_vertices[(i * 8) + 5]),
- .uv = (vec2){ .x = cube_vertices[(i * 8) + 6],
- .y = cube_vertices[(i * 8) + 7] } };
- vertex_darray_push(cube.vertices, vert);
+ // back faces
+ vertex_darray_push(
+ cube.vertices,
+ (vertex){ .position = BACK_BOT_LEFT, .normal = VEC3_NEG_Z, .uv = (vec2){ 0 } });
+ vertex_darray_push(
+ cube.vertices,
+ (vertex){ .position = BACK_TOP_LEFT, .normal = VEC3_NEG_Z, .uv = (vec2){ 0 } });
+ vertex_darray_push(
+ cube.vertices,
+ (vertex){ .position = BACK_TOP_LEFT, .normal = VEC3_NEG_Z, .uv = (vec2){ 0 } });
+ vertex_darray_push(
+ cube.vertices,
+ (vertex){ .position = BACK_TOP_RIGHT, .normal = VEC3_NEG_Z, .uv = (vec2){ 0 } });
+ vertex_darray_push(
+ cube.vertices,
+ (vertex){ .position = BACK_BOT_RIGHT, .normal = VEC3_NEG_Z, .uv = (vec2){ 0 } });
+ vertex_darray_push(
+ cube.vertices,
+ (vertex){ .position = BACK_BOT_LEFT, .normal = VEC3_NEG_Z, .uv = (vec2){ 0 } });
+
+ // front faces
+ vertex_darray_push(cube.vertices,
+ (vertex){ .position = FRONT_BOT_LEFT, .normal = VEC3_Z, .uv = (vec2){ 0 } });
+ vertex_darray_push(cube.vertices,
+ (vertex){ .position = FRONT_TOP_RIGHT, .normal = VEC3_Z, .uv = (vec2){ 0 } });
+ vertex_darray_push(cube.vertices,
+ (vertex){ .position = FRONT_TOP_LEFT, .normal = VEC3_Z, .uv = (vec2){ 0 } });
+ vertex_darray_push(cube.vertices,
+ (vertex){ .position = FRONT_BOT_LEFT, .normal = VEC3_Z, .uv = (vec2){ 0 } });
+ vertex_darray_push(cube.vertices,
+ (vertex){ .position = FRONT_BOT_RIGHT, .normal = VEC3_Z, .uv = (vec2){ 0 } });
+ vertex_darray_push(cube.vertices,
+ (vertex){ .position = FRONT_TOP_RIGHT, .normal = VEC3_Z, .uv = (vec2){ 0 } });
+
+ // top faces
+ vertex_darray_push(cube.vertices,
+ (vertex){ .position = BACK_TOP_LEFT, .normal = VEC3_Y, .uv = (vec2){ 0 } });
+ vertex_darray_push(cube.vertices,
+ (vertex){ .position = FRONT_TOP_LEFT, .normal = VEC3_Y, .uv = (vec2){ 0 } });
+ vertex_darray_push(cube.vertices,
+ (vertex){ .position = FRONT_TOP_RIGHT, .normal = VEC3_Y, .uv = (vec2){ 0 } });
+ vertex_darray_push(cube.vertices,
+ (vertex){ .position = BACK_TOP_LEFT, .normal = VEC3_Y, .uv = (vec2){ 0 } });
+ vertex_darray_push(cube.vertices,
+ (vertex){ .position = FRONT_TOP_RIGHT, .normal = VEC3_Y, .uv = (vec2){ 0 } });
+ vertex_darray_push(cube.vertices,
+ (vertex){ .position = BACK_TOP_RIGHT, .normal = VEC3_Y, .uv = (vec2){ 0 } });
+
+ // bottom faces
+ vertex_darray_push(
+ cube.vertices,
+ (vertex){ .position = BACK_BOT_LEFT, .normal = VEC3_NEG_Y, .uv = (vec2){ 0 } });
+ vertex_darray_push(
+ cube.vertices,
+ (vertex){ .position = FRONT_BOT_RIGHT, .normal = VEC3_NEG_Y, .uv = (vec2){ 0 } });
+ vertex_darray_push(
+ cube.vertices,
+ (vertex){ .position = FRONT_BOT_LEFT, .normal = VEC3_NEG_Y, .uv = (vec2){ 0 } });
+ vertex_darray_push(
+ cube.vertices,
+ (vertex){ .position = BACK_BOT_LEFT, .normal = VEC3_NEG_Y, .uv = (vec2){ 0 } });
+ vertex_darray_push(
+ cube.vertices,
+ (vertex){ .position = BACK_BOT_RIGHT, .normal = VEC3_NEG_Y, .uv = (vec2){ 0 } });
+ vertex_darray_push(
+ cube.vertices,
+ (vertex){ .position = FRONT_BOT_RIGHT, .normal = VEC3_NEG_Y, .uv = (vec2){ 0 } });
+
+ // right faces
+ vertex_darray_push(cube.vertices,
+ (vertex){ .position = FRONT_TOP_RIGHT, .normal = VEC3_X, .uv = (vec2){ 0 } });
+ vertex_darray_push(cube.vertices,
+ (vertex){ .position = BACK_BOT_RIGHT, .normal = VEC3_X, .uv = (vec2){ 0 } });
+ vertex_darray_push(cube.vertices,
+ (vertex){ .position = BACK_TOP_RIGHT, .normal = VEC3_X, .uv = (vec2){ 0 } });
+ vertex_darray_push(cube.vertices,
+ (vertex){ .position = BACK_BOT_RIGHT, .normal = VEC3_X, .uv = (vec2){ 0 } });
+ vertex_darray_push(cube.vertices,
+ (vertex){ .position = FRONT_TOP_RIGHT, .normal = VEC3_X, .uv = (vec2){ 0 } });
+ vertex_darray_push(cube.vertices,
+ (vertex){ .position = FRONT_BOT_RIGHT, .normal = VEC3_X, .uv = (vec2){ 0 } });
+
+ // left faces
+ vertex_darray_push(
+ cube.vertices,
+ (vertex){ .position = FRONT_TOP_LEFT, .normal = VEC3_NEG_X, .uv = (vec2){ 0 } });
+ vertex_darray_push(
+ cube.vertices,
+ (vertex){ .position = BACK_TOP_LEFT, .normal = VEC3_NEG_X, .uv = (vec2){ 0 } });
+ vertex_darray_push(
+ cube.vertices,
+ (vertex){ .position = BACK_BOT_LEFT, .normal = VEC3_NEG_X, .uv = (vec2){ 0 } });
+ vertex_darray_push(
+ cube.vertices,
+ (vertex){ .position = BACK_BOT_LEFT, .normal = VEC3_NEG_X, .uv = (vec2){ 0 } });
+ vertex_darray_push(
+ cube.vertices,
+ (vertex){ .position = FRONT_BOT_LEFT, .normal = VEC3_NEG_X, .uv = (vec2){ 0 } });
+ vertex_darray_push(
+ cube.vertices,
+ (vertex){ .position = FRONT_TOP_LEFT, .normal = VEC3_NEG_X, .uv = (vec2){ 0 } });
+
+ cube.indices_len = cube.vertices->len;
+ cube.indices = malloc(sizeof(u32) * cube.indices_len);
+
+ for (u32 i = 0; i < cube.indices_len; i++) {
+ cube.indices[i] = i;
}
+
+ cube.has_indices = true;
+
return cube;
}
diff --git a/src/renderer/backends/backend_vulkan.c b/src/renderer/backends/backend_vulkan.c
index 1657594..97e0a44 100644
--- a/src/renderer/backends/backend_vulkan.c
+++ b/src/renderer/backends/backend_vulkan.c
@@ -654,10 +654,10 @@ void vulkan_object_shader_update_object(vulkan_context* context, vulkan_shader*
vkCmdBindVertexBuffers(cmd_buffer, 0, 1, &context->object_vertex_buffer.handle,
(VkDeviceSize*)offsets);
- // vkCmdBindIndexBuffer(cmd_buffer, context->object_index_buffer.handle, 0, VK_INDEX_TYPE_UINT32);
+ vkCmdBindIndexBuffer(cmd_buffer, context->object_index_buffer.handle, 0, VK_INDEX_TYPE_UINT32);
- // vkCmdDrawIndexed(cmd_buffer, 6, 1, 0, 0, 0);
- vkCmdDraw(cmd_buffer, 36, 1, 0, 0);
+ vkCmdDrawIndexed(cmd_buffer, 36, 1, 0, 0, 0);
+ // vkCmdDraw(cmd_buffer, 36, 1, 0, 0);
}
bool select_physical_device(vulkan_context* ctx) {
@@ -1351,11 +1351,9 @@ void upload_data_range(vulkan_context* context, VkCommandPool pool, VkFence fenc
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
vulkan_buffer staging;
vulkan_buffer_create(context, size, VK_BUFFER_USAGE_TRANSFER_SRC_BIT, flags, true, &staging);
- TRACE("HERE");
// load data into staging buffer
printf("Size: %ld\n", size);
vulkan_buffer_load_data(context, &staging, 0, size, 0, data);
- TRACE("here");
// copy
vulkan_buffer_copy_to(context, pool, fence, queue, staging.handle, 0, buffer->handle, offset,
@@ -1587,18 +1585,19 @@ bool gfx_backend_init(renderer* ren) {
mesh cube = prim_cube_mesh_create();
- const u32 vert_count = 36;
- // vertex_pos verts[4] = { 0 };
+ // const u32 vert_count = 36;
- vertex_pos verts[36] = { 0 };
+ vertex_pos* verts = malloc(sizeof(vertex_pos) * cube.vertices->len);
f32 scale = 3.0;
- for (size_t i = 0; i < 36; i++) {
+ for (size_t i = 0; i < cube.vertices->len; i++) {
verts[i].pos = vec3_mult(cube.vertices->data[i].position, scale);
verts[i].normal = cube.vertices->data[i].normal;
}
- // const f32 s = 10.0;
+ // const f32 s = 1.0;
+ // const u32 vert_count = 4;
+ // vertex_pos verts[4] = { 0 };
// verts[0].pos.x = -0.5 * s;
// verts[0].pos.y = -0.5 * s;
@@ -1612,15 +1611,16 @@ bool gfx_backend_init(renderer* ren) {
// verts[3].pos.x = 0.5 * s;
// verts[3].pos.y = -0.5 * s;
- const u32 index_count = 6;
- u32 indices[6] = { 0, 1, 2, 0, 3, 1 };
+ // const u32 index_count = 6;
+ // u32 indices[6] = { 0, 1, 2, 0, 3, 1 };
upload_data_range(&context, context.device.gfx_command_pool, 0, context.device.graphics_queue,
- &context.object_vertex_buffer, 0, sizeof(vertex_pos) * vert_count, verts);
+ &context.object_vertex_buffer, 0, sizeof(vertex_pos) * cube.vertices->len,
+ verts);
TRACE("Uploaded vertex data");
- // upload_data_range(&context, context.device.gfx_command_pool, 0, context.device.graphics_queue,
- // &context.object_index_buffer, 0, sizeof(u32) * index_count, indices);
- // TRACE("Uploaded index data");
+ upload_data_range(&context, context.device.gfx_command_pool, 0, context.device.graphics_queue,
+ &context.object_index_buffer, 0, sizeof(u32) * cube.indices_len, cube.indices);
+ TRACE("Uploaded index data");
// --- End test code
INFO("Vulkan renderer initialisation succeeded");
@@ -1661,9 +1661,9 @@ void backend_begin_frame(renderer* ren, f32 delta_time) {
VkViewport viewport;
viewport.x = 0.0;
- viewport.y = 0.0;
+ viewport.y = (f32)context.framebuffer_height;
viewport.width = (f32)context.framebuffer_width;
- viewport.height = (f32)context.framebuffer_height;
+ viewport.height = -(f32)context.framebuffer_height;
viewport.minDepth = 0.0;
viewport.maxDepth = 1.0;
@@ -1741,7 +1741,15 @@ void gfx_backend_draw_frame(renderer* ren, camera* cam, mat4 model) {
camera_view_projection(cam, SCR_HEIGHT, SCR_WIDTH, &view, &proj);
- gfx_backend_update_global_state(proj, view, VEC3_ZERO, vec4(1.0, 1.0, 1.0, 1.0), 0);
+ // proj = mat4_perspective(deg_to_rad(45.0), (f32)SCR_WIDTH / SCR_HEIGHT, 0.1, 100.0);
+
+ // proj.data[5] *= -1.0;
+
+ // vec3 pos = vec3_create(2, 2, 2);
+ // vec3 up = VEC3_Y;
+ // view = mat4_look_at(pos, VEC3_ZERO, up);
+
+ gfx_backend_update_global_state(proj, view, cam->position, vec4(1.0, 1.0, 1.0, 1.0), 0);
vulkan_object_shader_update_object(&context, &context.object_shader, model);
backend_end_frame(ren, 16.0);