REVIEWED: BeginMode3D()
Simplified some code
This commit is contained in:
parent
a1d9987e7c
commit
d4e2c331b1
1 changed files with 5 additions and 16 deletions
21
src/core.c
21
src/core.c
|
@ -1912,23 +1912,12 @@ void BeginMode3D(Camera3D camera)
|
||||||
rlLoadIdentity(); // Reset current matrix (projection)
|
rlLoadIdentity(); // Reset current matrix (projection)
|
||||||
|
|
||||||
float aspect = (float)CORE.Window.currentFbo.width/(float)CORE.Window.currentFbo.height;
|
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)
|
rlFrustum(-right, top*aspect, -top, top, RL_CULL_DISTANCE_NEAR, RL_CULL_DISTANCE_FAR);
|
||||||
{
|
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
// NOTE: zNear and zFar values are important when computing depth buffer values
|
// NOTE: zNear and zFar values are important when computing depth buffer values
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue