From 511ec18e6fab943437ce4274466bf475d25bfc7b Mon Sep 17 00:00:00 2001 From: Eric-Paul Ickhorn Date: Wed, 11 Oct 2023 12:38:23 +0200 Subject: [PATCH] Fixed camera rotation --- code/source-c/main.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/code/source-c/main.c b/code/source-c/main.c index 47ff023..f29935b 100644 --- a/code/source-c/main.c +++ b/code/source-c/main.c @@ -109,11 +109,14 @@ void render() glClearBufferfv(GL_DEPTH, 0, &depth); mat4x4_perspective(projection_matrix, 120, 1200 / 800, 0.0001f, 1000.0f); - mat4x4_translate(view_matrix, -tc_camera_position.x, -tc_camera_position.y, tc_camera_position.z); + + mat4x4_identity(view_matrix); mat4x4_rotate_X(view_matrix, view_matrix, tc_camera_rotation.x); mat4x4_rotate_Y(view_matrix, view_matrix, tc_camera_rotation.y); mat4x4_rotate_Z(view_matrix, view_matrix, tc_camera_rotation.z); + mat4x4_translate_in_place(view_matrix, -tc_camera_position.x, -tc_camera_position.y, tc_camera_position.z); + glUseProgram(tc_game_state_g.renderer.draw_shader.program_id); int projection_uniform_location = glGetUniformLocation(tc_game_state_g.renderer.draw_shader.program_id, "projection_matrix"); @@ -280,12 +283,12 @@ bool update() if(rotate_left) { - tc_camera_rotation.y += 1.0f / (3.1415 * 2); + tc_camera_rotation.y -= 0.1f / (3.1415 * 2); } if(rotate_right) { - tc_camera_rotation.y -= 1.0f / (3.1415 * 2); + tc_camera_rotation.y += 0.1f / (3.1415 * 2); } return true;