summaryrefslogtreecommitdiffhomepage
path: root/src/core.c
diff options
context:
space:
mode:
authorRay <[email protected]>2021-03-19 13:20:23 +0100
committerRay <[email protected]>2021-03-19 13:20:23 +0100
commitd4e2c331b1a751dd02cac36502bbb161406b0d80 (patch)
treedfe7535df6835d35349239b6a16c3f9417043fd2 /src/core.c
parenta1d9987e7ca2c1be760a761ff673754a55a88813 (diff)
downloadraylib-d4e2c331b1a751dd02cac36502bbb161406b0d80.tar.gz
raylib-d4e2c331b1a751dd02cac36502bbb161406b0d80.zip
REVIEWED: BeginMode3D()
Simplified some code
Diffstat (limited to 'src/core.c')
-rw-r--r--src/core.c21
1 files changed, 5 insertions, 16 deletions
diff --git a/src/core.c b/src/core.c
index e9306f24..d01032ac 100644
--- a/src/core.c
+++ b/src/core.c
@@ -1912,23 +1912,12 @@ void BeginMode3D(Camera3D camera)
rlLoadIdentity(); // Reset current matrix (projection)
float aspect = (float)CORE.Window.currentFbo.width/(float)CORE.Window.currentFbo.height;
+
+ double top = 0;
+ if (camera.type == CAMERA_PERSPECTIVE) top = RL_CULL_DISTANCE_NEAR*tan(camera.fovy*0.5*DEG2RAD);
+ else if (camera.type == CAMERA_ORTHOGRAPHIC) top = camera.fovy/2.0;
- if (camera.type == CAMERA_PERSPECTIVE)
- {
- // Setup perspective projection
- double top = RL_CULL_DISTANCE_NEAR*tan(camera.fovy*0.5*DEG2RAD);
- double right = top*aspect;
-
- rlFrustum(-right, right, -top, top, RL_CULL_DISTANCE_NEAR, RL_CULL_DISTANCE_FAR);
- }
- else if (camera.type == CAMERA_ORTHOGRAPHIC)
- {
- // Setup orthographic projection
- double top = camera.fovy/2.0;
- double right = top*aspect;
-
- rlOrtho(-right, right, -top,top, RL_CULL_DISTANCE_NEAR, RL_CULL_DISTANCE_FAR);
- }
+ rlFrustum(-right, top*aspect, -top, top, RL_CULL_DISTANCE_NEAR, RL_CULL_DISTANCE_FAR);
// NOTE: zNear and zFar values are important when computing depth buffer values