summaryrefslogtreecommitdiff
path: root/engine/src/mesh/vertex_buffer.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2026-08-13 15:52:12 +0200
committerHampusM <hampus@hampusmat.com>2026-08-13 15:52:12 +0200
commitc9d3e1fda0b238cbb62284e78267f18d5b4c7dcb (patch)
tree736ed0fd76ad3c2ffdf6cc594edeb795a13f7f43 /engine/src/mesh/vertex_buffer.rs
parentc611ee62477564fbe532f51e8526bae2e82dae93 (diff)
refactor(engine): replace mesh::cube mod with new Mesh::cube fn
Diffstat (limited to 'engine/src/mesh/vertex_buffer.rs')
-rw-r--r--engine/src/mesh/vertex_buffer.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/engine/src/mesh/vertex_buffer.rs b/engine/src/mesh/vertex_buffer.rs
index 4df3ffc..90e5752 100644
--- a/engine/src/mesh/vertex_buffer.rs
+++ b/engine/src/mesh/vertex_buffer.rs
@@ -73,6 +73,26 @@ pub struct VertexBuffer
impl VertexBuffer
{
+ pub unsafe fn from_raw(
+ vertex_attr_props: &[VertexAttrProperties],
+ buffer: Vec<u8>,
+ ) -> Self
+ {
+ let last_vertex_attr_props = vertex_attr_props
+ .iter()
+ .max_by_key(|props| props.byte_offset)
+ .expect("No vertex attribute properties are given");
+
+ let vertex_size =
+ last_vertex_attr_props.byte_offset + last_vertex_attr_props.layout.size();
+
+ Self {
+ buf: buffer,
+ vertex_size,
+ vertex_attr_props: vertex_attr_props.to_vec(),
+ }
+ }
+
pub fn with_capacity(vertex_attrs: &[VertexAttrInfo], capacity: usize) -> Self
{
let mut vertex_attr_props = vertex_attrs