|
|
@@ -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) |
|
|
|
} |
|
|
|
} |
|
|
|