use gl;
use std::ops::{Deref};
pub struct VertexArray {
vertex_array_object: gl::types::GLuint
}
impl VertexArray {
pub fn new() -> VertexArray {
unsafe {
let mut new_array: gl::types::GLuint = 0;
gl::GenVertexArrays(1, &mut new_array);
VertexArray {
vertex_array_object: new_array
}
}
}
}
impl Deref for VertexArray {
type Target = gl::types::GLuint;
fn deref(&self) -> &gl::types::GLuint {
&self.vertex_array_object
}
}
impl Drop for VertexArray {
fn drop(&mut self) {
unsafe {
gl::DeleteVertexArrays(1, &mut self.vertex_array_object);
}
}
}