MCPcopy Create free account
hub / github.com/TheForceEngine/TheForceEngine / computeProjMatrix

Function computeProjMatrix

TheForceEngine/TFE_System/math.cpp:36–51  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34 }
35
36 Mat4 computeProjMatrix(f32 fovInRadians, f32 aspectRatio, f32 zNear, f32 zFar)
37 {
38 // Build a projection matrix.
39 const f32 yScale = 1.0f / tanf(fovInRadians * 0.5f);
40 const f32 xScale = yScale / aspectRatio;
41 const f32 zScale = zFar / (zNear - zFar);
42 const f32 wScale = zNear * zFar / (zNear - zFar);
43
44 Mat4 r;
45 r.m0 = { xScale, 0.0f, 0.0f, 0.0f };
46 r.m1 = { 0.0f, yScale, 0.0f, 0.0f };
47 r.m2 = { 0.0f, 0.0f, zScale, wScale };
48 r.m3 = { 0.0f, 0.0f, -1.0f, 0.0f };
49
50 return r;
51 }
52
53 Mat4 computeProjMatrixExplicit(f32 xScale, f32 yScale, f32 zNear, f32 zFar)
54 {

Callers 2

thumbnail_updateFunction · 0.85
computeCameraTransformFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected