clean up opengl buffers when dropping aabb

This commit is contained in:
2023-10-23 04:49:03 +02:00
parent b8d55e8c61
commit c06b7d9366
+15
View File
@@ -8,6 +8,8 @@ pub struct AABB {
pub max: glm::Vec3, pub max: glm::Vec3,
indices_len: u32, indices_len: u32,
vao: u32, vao: u32,
vbo: u32,
ebo: u32,
} }
impl AABB { impl AABB {
@@ -69,6 +71,8 @@ impl AABB {
max, max,
indices_len: indices.len() as u32, indices_len: indices.len() as u32,
vao, 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);
}
}
}