MCPcopy Create free account
hub / github.com/Bloom-Engine/engine / mat4_perspective

Function mat4_perspective

native/shared/src/renderer/util.rs:22–31  ·  view source on GitHub ↗
(fovy: f32, aspect: f32, near: f32, far: f32)

Source from the content-addressed store, hash-verified

20// ============================================================
21
22pub fn mat4_perspective(fovy: f32, aspect: f32, near: f32, far: f32) -> [[f32; 4]; 4] {
23 let f = 1.0 / (fovy / 2.0).tan();
24 let nf = 1.0 / (near - far);
25 [
26 [f / aspect, 0.0, 0.0, 0.0],
27 [0.0, f, 0.0, 0.0],
28 [0.0, 0.0, (far + near) * nf, -1.0],
29 [0.0, 0.0, 2.0 * far * near * nf, 0.0],
30 ]
31}
32
33pub fn mat4_ortho(left: f32, right: f32, bottom: f32, top: f32, near: f32, far: f32) -> [[f32; 4]; 4] {
34 // wgpu NDC z range is [0, 1] (not OpenGL's [-1, 1]). Matching

Callers 2

begin_mode_3dMethod · 0.85

Calls

no outgoing calls

Tested by 1