diff options
| author | Ray <[email protected]> | 2021-03-19 21:55:47 +0100 |
|---|---|---|
| committer | Ray <[email protected]> | 2021-03-19 21:55:47 +0100 |
| commit | 5967c1ba1a8b6311cc4abd1a3a2b3d61cccc7760 (patch) | |
| tree | 45bf853078ebf8e1b2c18da5b72adf46b879f430 /src/core.c | |
| parent | be8d5a7ae2e5f89e7a03060a852883556c56c405 (diff) | |
| download | raylib-5967c1ba1a8b6311cc4abd1a3a2b3d61cccc7760.tar.gz raylib-5967c1ba1a8b6311cc4abd1a3a2b3d61cccc7760.zip | |
REVIEWED: BeginMode3D()
Diffstat (limited to 'src/core.c')
| -rw-r--r-- | src/core.c | 20 |
1 files changed, 15 insertions, 5 deletions
@@ -1913,13 +1913,23 @@ void BeginMode3D(Camera3D camera) float aspect = (float)CORE.Window.currentFbo.width/(float)CORE.Window.currentFbo.height; - double top = 0; - if (camera.projection == CAMERA_PERSPECTIVE) top = RL_CULL_DISTANCE_NEAR*tan(camera.fovy*0.5*DEG2RAD); - else if (camera.projection == CAMERA_ORTHOGRAPHIC) top = camera.fovy/2.0; + // NOTE: zNear and zFar values are important when computing depth buffer values + if (camera.projection == CAMERA_PERSPECTIVE) + { + // Setup perspective projection + double top = RL_CULL_DISTANCE_NEAR*tan(camera.fovy*0.5*DEG2RAD); + double right = top*aspect; - rlFrustum(-top*aspect, top*aspect, -top, top, RL_CULL_DISTANCE_NEAR, RL_CULL_DISTANCE_FAR); + rlFrustum(-right, right, -top, top, RL_CULL_DISTANCE_NEAR, RL_CULL_DISTANCE_FAR); + } + else if (camera.projection == CAMERA_ORTHOGRAPHIC) + { + // Setup orthographic projection + double top = camera.fovy/2.0; + double right = top*aspect; - // NOTE: zNear and zFar values are important when computing depth buffer values + rlOrtho(-right, right, -top,top, RL_CULL_DISTANCE_NEAR, RL_CULL_DISTANCE_FAR); + } rlMatrixMode(RL_MODELVIEW); // Switch back to modelview matrix rlLoadIdentity(); // Reset current matrix (modelview) |
