Jelajahi Sumber

Fixed the perspective matrix calculation (thanks @KonkolyTamas!)

Fixes https://github.com/libsdl-org/SDL/issues/13867

(cherry picked from commit ea1a769322a28190423d74b7188161f4484a1a22)
Sam Lantinga 6 bulan lalu
induk
melakukan
a0b8275e9c
2 mengubah file dengan 2 tambahan dan 2 penghapusan
  1. 1 1
      test/testgles2.c
  2. 1 1
      test/testgpu_spinning_cube.c

+ 1 - 1
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;

+ 1 - 1
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;