Skip to content

Commit 4b8328d

Browse files
committed
[add] vertex buffer & mesh structs for implementing meshes.
1 parent 3018d8c commit 4b8328d

6 files changed

Lines changed: 23 additions & 1 deletion

File tree

crates/lambda-platform/src/vertex.rs

Whitespace-only changes.

lambda/examples/push_constants.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ impl Component for PushConstantsExample {
123123

124124
// Create a projection matrix.
125125
let mut projection: [[f32; 4]; 4] =
126-
matrix::perspective_matrix(1.0 / 2.0, 1700.0 / 900.0, 0.1, 200.0);
126+
matrix::perspective_matrix(0.25, 1700.0 / 900.0, 0.1, 200.0);
127127
projection.as_mut()[1].as_mut()[1] *= -1.0;
128128

129129
// Rotate model.

lambda/src/core/render/mesh.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
use super::vertex::Vertex;
2+
3+
pub struct Mesh {
4+
pub vertices: Vec<Vertex>,
5+
pub indices: Vec<u32>,
6+
}

lambda/src/core/render/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
//! High level Rendering API designed for cross platform rendering and
22
//! windowing.
33
4+
// Module Exports
45
pub mod command;
6+
pub mod mesh;
57
pub mod pipeline;
68
pub mod render_pass;
79
pub mod shader;
10+
pub mod vertex;
811
pub mod viewport;
912
pub mod window;
1013

lambda/src/core/render/vertex.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#[derive(Clone, Copy, Debug)]
2+
pub struct Vertex {
3+
pub position: [f32; 3],
4+
pub normal: [f32; 3],
5+
pub color: [f32; 3],
6+
}

lambda/src/math/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,19 @@
33
pub mod matrix;
44
pub mod vector;
55

6+
pub enum Angle {
7+
Radians(f32),
8+
Degrees(f32),
9+
Turns(f32),
10+
}
11+
612
/// Convert a turn into radians.
713
fn turns_to_radians(turns: f32) -> f32 {
814
return turns * std::f32::consts::PI * 2.0;
915
}
1016

1117
#[macro_export]
18+
/// Assert that two values are equal, with a given tolerance.
1219
macro_rules! assert_approximately_equal {
1320
($a:expr, $b:expr, $eps:expr) => {{
1421
let (a, b, eps) = ($a, $b, $eps);

0 commit comments

Comments
 (0)