Browse Source

Implemented missing Drops

raster
Bergmann89 4 years ago
parent
commit
a69f42a65b
3 changed files with 27 additions and 2 deletions
  1. +6
    -0
      glc/src/array_buffer.rs
  2. +6
    -0
      glc/src/texture.rs
  3. +15
    -2
      glc/src/vertex_array.rs

+ 6
- 0
glc/src/array_buffer.rs View File

@@ -150,6 +150,12 @@ impl ArrayBuffer {
}
}

impl Drop for ArrayBuffer {
fn drop(&mut self) {
gl::delete_buffers(1, &self.id);
}
}

impl Bindable for ArrayBuffer {
fn bind(&self) {
gl::bind_buffer(self.target.as_enum(), self.id);


+ 6
- 0
glc/src/texture.rs View File

@@ -125,6 +125,12 @@ impl Texture {
}
}

impl Drop for Texture {
fn drop(&mut self) {
gl::delete_textures(1, &self.id);
}
}

impl Bindable for Texture {
fn bind(&self) {
gl::bind_texture(self.target.as_enum(), self.id);


+ 15
- 2
glc/src/vertex_array.rs View File

@@ -25,6 +25,12 @@ impl VertexArray {
}
}

impl Drop for VertexArray {
fn drop(&mut self) {
gl::delete_vertex_arrays(1, &self.id);
}
}

impl Bindable for VertexArray {
fn bind(&self) {
gl::bind_vertex_array(self.id);
@@ -59,15 +65,16 @@ impl Builder {

Error::checked(|| gl::create_vertex_arrays(1, &mut id))?;

let vertex_array = VertexArray {
let mut vertex_array = VertexArray {
id,
buffers: Vec::new(),
};

let guard = BindGuard::new(&vertex_array);

let mut buffers = Vec::new();
for binding in self.bindings {
let _guard = BindGuard::new(&binding.buffer);
let guard = BindGuard::new(&binding.buffer);

for pointer in binding.pointers {
Error::checked(|| {
@@ -86,10 +93,16 @@ impl Builder {
)
})?;
}

drop(guard);

buffers.push(binding.buffer);
}

drop(guard);

vertex_array.buffers = buffers;

Ok(vertex_array)
}
}


Loading…
Cancel
Save