mirror of
https://github.com/raysan5/raylib.git
synced 2025-09-18 17:28:15 +00:00
REVIEWED: BeginMode3D()
Simplified some code
This commit is contained in:
19
src/core.c
19
src/core.c
@@ -1913,22 +1913,11 @@ void BeginMode3D(Camera3D camera)
|
|||||||
|
|
||||||
float aspect = (float)CORE.Window.currentFbo.width/(float)CORE.Window.currentFbo.height;
|
float aspect = (float)CORE.Window.currentFbo.width/(float)CORE.Window.currentFbo.height;
|
||||||
|
|
||||||
if (camera.type == CAMERA_PERSPECTIVE)
|
double top = 0;
|
||||||
{
|
if (camera.type == CAMERA_PERSPECTIVE) top = RL_CULL_DISTANCE_NEAR*tan(camera.fovy*0.5*DEG2RAD);
|
||||||
// Setup perspective projection
|
else if (camera.type == CAMERA_ORTHOGRAPHIC) top = camera.fovy/2.0;
|
||||||
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);
|
rlFrustum(-right, top*aspect, -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);
|
|
||||||
}
|
|
||||||
|
|
||||||
// NOTE: zNear and zFar values are important when computing depth buffer values
|
// NOTE: zNear and zFar values are important when computing depth buffer values
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user