summaryrefslogtreecommitdiff
path: root/engine/src/opengl/buffer.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2024-04-14 12:34:52 +0200
committerHampusM <hampus@hampusmat.com>2024-04-14 12:35:28 +0200
commit101b455e51f9b702da5517cabe2c3b1086fcb2e7 (patch)
tree470e28acd7a3777dbb4be0208f9cd3177bba52a9 /engine/src/opengl/buffer.rs
parentef7b76ff39d501028852835649f618fcbe17a003 (diff)
feat(engine): use ECS architecture
Diffstat (limited to 'engine/src/opengl/buffer.rs')
-rw-r--r--engine/src/opengl/buffer.rs15
1 files changed, 5 insertions, 10 deletions
diff --git a/engine/src/opengl/buffer.rs b/engine/src/opengl/buffer.rs
index 3a4ecf0..1622804 100644
--- a/engine/src/opengl/buffer.rs
+++ b/engine/src/opengl/buffer.rs
@@ -6,9 +6,8 @@ use crate::opengl::currently_bound::CurrentlyBound;
#[derive(Debug)]
pub struct Buffer<Item, ModeT: Mode>
{
- buffer: gl::types::GLuint,
- _item_pd: PhantomData<Item>,
- _mode_pd: PhantomData<ModeT>,
+ buf: gl::types::GLuint,
+ _pd: PhantomData<(Item, ModeT)>,
}
impl<Item, ModeT: Mode> Buffer<Item, ModeT>
@@ -21,11 +20,7 @@ impl<Item, ModeT: Mode> Buffer<Item, ModeT>
gl::GenBuffers(1, &mut buffer);
};
- Self {
- buffer,
- _item_pd: PhantomData,
- _mode_pd: PhantomData,
- }
+ Self { buf: buffer, _pd: PhantomData }
}
#[allow(clippy::inline_always)]
@@ -33,7 +28,7 @@ impl<Item, ModeT: Mode> Buffer<Item, ModeT>
pub fn bind(&self, cb: impl FnOnce(CurrentlyBound<'_, Self>))
{
unsafe {
- gl::BindBuffer(ModeT::GL_ENUM, self.buffer);
+ gl::BindBuffer(ModeT::GL_ENUM, self.buf);
}
// SAFETY: The buffer object is bound above
@@ -63,7 +58,7 @@ impl<Item, ModeT: Mode> Drop for Buffer<Item, ModeT>
{
#[allow(clippy::cast_possible_wrap, clippy::cast_possible_truncation)]
unsafe {
- gl::DeleteBuffers(1, &self.buffer);
+ gl::DeleteBuffers(1, &self.buf);
}
}
}