From c06b7d9366cdc4773da74a75ee30e88f8a31e76b Mon Sep 17 00:00:00 2001 From: IllusionMan1212 Date: Mon, 23 Oct 2023 04:49:03 +0200 Subject: [PATCH] clean up opengl buffers when dropping aabb --- src/aabb.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/aabb.rs b/src/aabb.rs index fb91c48..a4bb0b2 100644 --- a/src/aabb.rs +++ b/src/aabb.rs @@ -8,6 +8,8 @@ pub struct AABB { pub max: glm::Vec3, indices_len: u32, vao: u32, + vbo: u32, + ebo: u32, } impl AABB { @@ -69,6 +71,8 @@ impl AABB { max, indices_len: indices.len() as u32, vao, + vbo, + ebo } } @@ -88,3 +92,14 @@ impl AABB { } } } + +impl Drop for AABB { + fn drop(&mut self) { + unsafe { + gl::BindVertexArray(0); + gl::DeleteBuffers(1, &self.vbo); + gl::DeleteBuffers(1, &self.ebo); + gl::DeleteVertexArrays(1, &self.vao); + } + } +}