Add Drop implementations for OpenGL structures

This commit is contained in:
Mikhail "L117" Nikolenko 2021-02-20 05:00:10 +10:00 committed by GitHub
parent 3dafec076b
commit 4f22e6f518
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 0 deletions

View File

@ -754,6 +754,16 @@ impl QuadRenderer {
}
}
impl Drop for QuadRenderer {
fn drop(&mut self) {
unsafe {
gl::DeleteBuffers(1, &self.vbo_instance);
gl::DeleteBuffers(1, &self.ebo);
gl::DeleteVertexArrays(1, &self.vao);
}
}
}
impl<'a> RenderApi<'a> {
pub fn clear(&self, color: Rgb) {
unsafe {
@ -1402,3 +1412,11 @@ impl Atlas {
Ok(())
}
}
impl Drop for Atlas {
fn drop(&mut self) {
unsafe {
gl::DeleteTextures(1, &self.id);
}
}
}

View File

@ -344,6 +344,15 @@ impl RectRenderer {
}
}
impl Drop for RectRenderer {
fn drop(&mut self) {
unsafe {
gl::DeleteBuffers(1, &self.vbo);
gl::DeleteVertexArrays(1, &self.vao);
}
}
}
/// Rectangle drawing program.
#[derive(Debug)]
pub struct RectShaderProgram {