From 262092066834f0bf4848f0cd8a3bc6c851118881 Mon Sep 17 00:00:00 2001 From: HampusM Date: Fri, 7 Nov 2025 13:54:54 +0100 Subject: feat(opengl-bindings): add Buffer & VertexArray delete fns --- opengl-bindings/Cargo.toml | 4 +++- opengl-bindings/src/buffer.rs | 9 ++++++++- opengl-bindings/src/vertex_array.rs | 11 ++++++++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/opengl-bindings/Cargo.toml b/opengl-bindings/Cargo.toml index 8251642..cac3c1e 100644 --- a/opengl-bindings/Cargo.toml +++ b/opengl-bindings/Cargo.toml @@ -61,5 +61,7 @@ gl_commands = [ "Disable", "GetIntegerv", "DebugMessageCallback", - "DebugMessageControl" + "DebugMessageControl", + "DeleteVertexArrays", + "DeleteBuffers" ] diff --git a/opengl-bindings/src/buffer.rs b/opengl-bindings/src/buffer.rs index c64ec8d..4c91649 100644 --- a/opengl-bindings/src/buffer.rs +++ b/opengl-bindings/src/buffer.rs @@ -105,7 +105,7 @@ impl Buffer let Ok(offset_casted) = crate::sys::types::GLintptr::try_from(offset) else { unreachable!(); // Reason: The total size can be casted to a GLintptr - // (done above) so offsets should be castable as well + // (done above) so offsets should be castable as well }; unsafe { @@ -121,6 +121,13 @@ impl Buffer Ok(()) } + pub fn delete(&self, current_context: &CurrentContextWithFns<'_>) + { + unsafe { + current_context.fns().DeleteBuffers(1, &raw const self.buf); + } + } + pub(crate) fn object(&self) -> crate::sys::types::GLuint { self.buf diff --git a/opengl-bindings/src/vertex_array.rs b/opengl-bindings/src/vertex_array.rs index 9942fe7..d3af604 100644 --- a/opengl-bindings/src/vertex_array.rs +++ b/opengl-bindings/src/vertex_array.rs @@ -3,8 +3,8 @@ use std::mem::size_of; use safer_ffi::layout::ReprC; -use crate::buffer::Buffer; use crate::CurrentContextWithFns; +use crate::buffer::Buffer; #[derive(Debug)] pub struct VertexArray @@ -188,6 +188,15 @@ impl VertexArray { unsafe { current_context.fns().BindVertexArray(self.array) } } + + pub fn delete(&self, current_context: &CurrentContextWithFns<'_>) + { + unsafe { + current_context + .fns() + .DeleteVertexArrays(1, &raw const self.array); + } + } } #[derive(Debug)] -- cgit v1.2.3-18-g5258