From 24209ebf57321e0bcf8eeeaebca716e27e1695a3 Mon Sep 17 00:00:00 2001 From: Alberto Mardegan Date: Fri, 17 May 2024 23:12:53 +0300 Subject: [PATCH] Do not transpose the projection matrix The 4x4 projection matrix is correct as-is, there's no need of transposing it. As a matter of fact, transposing it was causing the scene to always be horizontally centered regardless of the left/right planes set on glFrustum(). This went unnoticed until now because most of the examples/tutorials use a simple frustum where both vertical and horizontal coordinates are set to [-1, 1]. --- src/gc_gl.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/gc_gl.c b/src/gc_gl.c index 37c3908..5a8da30 100644 --- a/src/gc_gl.c +++ b/src/gc_gl.c @@ -106,16 +106,12 @@ static void draw_arrays_general(float *ptr_pos, float *ptr_normal, float *ptr_te #define PROJECTION_UPDATE \ { \ - float trans[4][4]; \ - int i; \ - int j; \ - for (i = 0; i < 4; i++) \ - for (j = 0; j < 4; j++) \ - trans[i][j] = glparamstate.projection_matrix[j][i]; \ - if (trans[3][3] != 0) \ - GX_LoadProjectionMtx(trans, GX_ORTHOGRAPHIC); \ + if (glparamstate.projection_matrix[3][3] != 0) \ + GX_LoadProjectionMtx(glparamstate.projection_matrix, \ + GX_ORTHOGRAPHIC); \ else \ - GX_LoadProjectionMtx(trans, GX_PERSPECTIVE); \ + GX_LoadProjectionMtx(glparamstate.projection_matrix, \ + GX_PERSPECTIVE); \ } #define NORMAL_UPDATE \