Skip to content

cf_perspective

Category: math
GitHub: cute_math3d.h


Builds a right-handed perspective projection matrix.

CF_M4x4 cf_perspective(float fov_radians, float aspect, float znear, float zfar)
Parameters Description
fov_radians The vertical field of view.
aspect The viewport aspect ratio, width divided by height.
znear Distance to the near clip plane. Must be greater than zero.
zfar Distance to the far clip plane.

Return Value

Returns a matrix mapping the view frustum to clip space.

Remarks

Right-handed, with clip-space z in [0, 1] -- znear maps to 0 and zfar to 1. See cf_ortho for why that convention is not optional on SDL_GPU. Pairs with CF_COMPARE_FUNCTION_LESS_THAN and a depth clear of 1.0.

CF_M4x4
cf_ortho
cf_look_at
cf_mul
CF_RenderState