summaryrefslogtreecommitdiff
path: root/engine/src/vertex.rs
diff options
context:
space:
mode:
Diffstat (limited to 'engine/src/vertex.rs')
-rw-r--r--engine/src/vertex.rs26
1 files changed, 23 insertions, 3 deletions
diff --git a/engine/src/vertex.rs b/engine/src/vertex.rs
index 62f629b..9df646f 100644
--- a/engine/src/vertex.rs
+++ b/engine/src/vertex.rs
@@ -1,7 +1,7 @@
use std::mem::size_of;
use crate::color::Color;
-use crate::vector::Vec3;
+use crate::vector::{Vec2, Vec3};
#[derive(Debug, Clone, Default)]
#[repr(C)]
@@ -9,6 +9,7 @@ pub struct Vertex
{
pos: Vec3<f32>,
color: Color<f32>,
+ texture_coords: Vec2<f32>,
}
#[derive(Debug, Default)]
@@ -16,6 +17,7 @@ pub struct Builder
{
pos: Option<Vec3<f32>>,
color: Option<Color<f32>>,
+ texture_coords: Vec2<f32>,
}
impl Builder
@@ -23,7 +25,7 @@ impl Builder
#[must_use]
pub fn new() -> Self
{
- Self { pos: None, color: None }
+ Self::default()
}
#[must_use]
@@ -43,12 +45,24 @@ impl Builder
}
#[must_use]
+ pub fn texture_coords(mut self, texture_coords: Vec2<f32>) -> Self
+ {
+ self.texture_coords = texture_coords;
+
+ self
+ }
+
+ #[must_use]
pub fn build(self) -> Option<Vertex>
{
let pos = self.pos?;
let color = self.color?;
- Some(Vertex { pos, color })
+ Some(Vertex {
+ pos,
+ color,
+ texture_coords: self.texture_coords,
+ })
}
}
@@ -69,6 +83,12 @@ impl Vertex
component_cnt: AttributeComponentCnt::Three,
component_size: size_of::<f32>(),
},
+ Attribute {
+ index: 2,
+ component_type: AttributeComponentType::Float,
+ component_cnt: AttributeComponentCnt::Two,
+ component_size: size_of::<f32>(),
+ },
]
}
}