summaryrefslogtreecommitdiff
path: root/engine/src/mesh/vertex_buffer.rs
diff options
context:
space:
mode:
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