From 101b455e51f9b702da5517cabe2c3b1086fcb2e7 Mon Sep 17 00:00:00 2001 From: HampusM Date: Sun, 14 Apr 2024 12:34:52 +0200 Subject: feat(engine): use ECS architecture --- engine/src/opengl/buffer.rs | 15 +++++---------- engine/src/opengl/mod.rs | 4 ++-- 2 files changed, 7 insertions(+), 12 deletions(-) (limited to 'engine/src/opengl') 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 { - buffer: gl::types::GLuint, - _item_pd: PhantomData, - _mode_pd: PhantomData, + buf: gl::types::GLuint, + _pd: PhantomData<(Item, ModeT)>, } impl Buffer @@ -21,11 +20,7 @@ impl Buffer 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 Buffer 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 Drop for Buffer { #[allow(clippy::cast_possible_wrap, clippy::cast_possible_truncation)] unsafe { - gl::DeleteBuffers(1, &self.buffer); + gl::DeleteBuffers(1, &self.buf); } } } diff --git a/engine/src/opengl/mod.rs b/engine/src/opengl/mod.rs index d58ca50..6898c49 100644 --- a/engine/src/opengl/mod.rs +++ b/engine/src/opengl/mod.rs @@ -1,6 +1,6 @@ use bitflags::bitflags; -use glfw::WindowSize; +use crate::data_types::dimens::Dimens; use crate::vector::Vec2; pub mod buffer; @@ -14,7 +14,7 @@ mod util; #[cfg(feature = "debug")] pub mod debug; -pub fn set_viewport(position: &Vec2, size: &WindowSize) +pub fn set_viewport(position: &Vec2, size: Dimens) { unsafe { #[allow(clippy::cast_possible_wrap)] -- cgit v1.2.3-18-g5258