Fixed the perspective matrix calculation (thanks @KonkolyTamas!)

Fixes https://github.com/libsdl-org/SDL/issues/13867
This commit is contained in:
Sam Lantinga
2025-09-04 06:04:01 -07:00
parent 637a9b34ab
commit ea1a769322
3 changed files with 3 additions and 3 deletions

View File

@@ -97,7 +97,7 @@ static SDL_FPoint ProjectVec3ToRect(const Vector3 *v, const SDL_FRect *rect)
const float cameraZ = 4.0f; /* Camera is at(0, 0, +4), looking toward origin */
float aspect = rect->w / rect->h;
float fovScaleY = SDL_tanf((verticalFOV_deg * SDL_PI_F / 180.0f) * 0.5f);
float fovScaleY = SDL_tanf(((verticalFOV_deg / 180.0f) * SDL_PI_F) * 0.5f);
float fovScaleX = fovScaleY * aspect;
float relZ = cameraZ - v->z;

View File

@@ -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;

View File

@@ -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;