summaryrefslogtreecommitdiff
path: root/engine/src/renderer/vertex_buffer.rs
diff options
context:
space:
mode:
Diffstat (limited to 'engine/src/renderer/vertex_buffer.rs')
-rw-r--r--engine/src/renderer/vertex_buffer.rs18
1 files changed, 17 insertions, 1 deletions
diff --git a/engine/src/renderer/vertex_buffer.rs b/engine/src/renderer/vertex_buffer.rs
index 27ed705..57debc3 100644
--- a/engine/src/renderer/vertex_buffer.rs
+++ b/engine/src/renderer/vertex_buffer.rs
@@ -1,5 +1,6 @@
use std::mem::size_of_val;
+use crate::currently_bound::CurrentlyBound;
use crate::vertex::Vertex;
#[derive(Debug)]
@@ -21,12 +22,27 @@ impl VertexBuffer
Self { buffer }
}
- pub fn store(&self, vertices: &[Vertex], usage: BufferUsage)
+ #[allow(clippy::inline_always)]
+ #[inline(always)]
+ pub fn bind(&self, cb: impl FnOnce(CurrentlyBound<'_, Self>))
{
unsafe {
gl::BindBuffer(gl::ARRAY_BUFFER, self.buffer);
}
+ // SAFETY: A vertex array object is currently bound
+ let currently_bound = unsafe { CurrentlyBound::new() };
+
+ cb(currently_bound);
+ }
+
+ /// Stores vertices in the currently bound vertex bound.
+ pub fn store(
+ _currently_bound: &CurrentlyBound<Self>,
+ vertices: &[Vertex],
+ usage: BufferUsage,
+ )
+ {
unsafe {
#[allow(clippy::cast_possible_wrap)]
gl::BufferData(