From a0b8275e9cce1ec2f6c78e93f21d2462807c5a70 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 4 Sep 2025 06:04:01 -0700 Subject: [PATCH] Fixed the perspective matrix calculation (thanks @KonkolyTamas!) Fixes https://github.com/libsdl-org/SDL/issues/13867 (cherry picked from commit ea1a769322a28190423d74b7188161f4484a1a22) --- test/testgles2.c | 2 +- test/testgpu_spinning_cube.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/testgles2.c b/test/testgles2.c index 1184eab7cb..5fad872a57 100644 --- a/test/testgles2.c +++ b/test/testgles2.c @@ -179,7 +179,7 @@ perspective_matrix(float fovy, float aspect, float znear, float zfar, float *r) int i; float f; - f = 1.0f / SDL_tanf(fovy * 0.5f); + f = 1.0f / SDL_tanf((fovy / 180.0f) * SDL_PI_F * 0.5f); for (i = 0; i < 16; i++) { r[i] = 0.0; diff --git a/test/testgpu_spinning_cube.c b/test/testgpu_spinning_cube.c index 0eeb034fbb..7ec4aeec00 100644 --- a/test/testgpu_spinning_cube.c +++ b/test/testgpu_spinning_cube.c @@ -133,7 +133,7 @@ perspective_matrix(float fovy, float aspect, float znear, float zfar, float *r) int i; float f; - f = 1.0f/SDL_tanf(fovy * 0.5f); + f = 1.0f/SDL_tanf((fovy / 180.0f) * SDL_PI_F * 0.5f); for (i = 0; i < 16; i++) { r[i] = 0.0;