ugli_raw/gl/
vao.rs

1use super::*;
2
3pub type VertexArrayObject = gl::types::GLuint;
4
5impl Context {
6    pub fn bind_vertex_array(&self, vao: &VertexArrayObject) {
7        unsafe {
8            gl::BindVertexArray(*vao);
9        }
10    }
11
12    pub fn create_vertex_array(&self) -> Option<VertexArrayObject> {
13        let mut handle = std::mem::MaybeUninit::uninit();
14        unsafe {
15            gl::GenVertexArrays(1, handle.as_mut_ptr());
16        }
17        let handle = unsafe { handle.assume_init() };
18        if handle == 0 {
19            None
20        } else {
21            Some(handle)
22        }
23    }
24
25    pub fn delete_vertex_array(&self, vao: &VertexArrayObject) {
26        unsafe {
27            gl::DeleteVertexArrays(1, vao);
28        }
29    }
30}