Skip to content

Commit

Permalink
Add glCreateVertexArrays as create_named_vertex_array
Browse files Browse the repository at this point in the history
  • Loading branch information
chyyran committed Aug 9, 2024
1 parent 03ed28e commit ac35eec
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,8 @@ pub trait HasContext: __private::Sealed {

unsafe fn create_vertex_array(&self) -> Result<Self::VertexArray, String>;

unsafe fn create_named_vertex_array(&self) -> Result<Self::VertexArray, String>;

unsafe fn delete_vertex_array(&self, vertex_array: Self::VertexArray);

unsafe fn bind_vertex_array(&self, vertex_array: Option<Self::VertexArray>);
Expand Down
7 changes: 7 additions & 0 deletions src/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1198,6 +1198,13 @@ impl HasContext for Context {
Ok(NativeVertexArray(non_zero_gl_name(vertex_array)))
}

unsafe fn create_named_vertex_array(&self) -> Result<Self::VertexArray, String> {
let gl = &self.raw;
let mut vertex_array = 0;
gl.CreateVertexArrays(1, &mut vertex_array);
Ok(NativeVertexArray(non_zero_gl_name(vertex_array)))
}

unsafe fn delete_vertex_array(&self, vertex_array: Self::VertexArray) {
let gl = &self.raw;
gl.DeleteVertexArrays(1, &vertex_array.0.get());
Expand Down
3 changes: 3 additions & 0 deletions src/web_sys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2469,6 +2469,9 @@ impl HasContext for Context {
}
}

unsafe fn create_named_vertex_array(&self) -> Result<Self::VertexArray, String> {
unimplemented!()
}
unsafe fn delete_vertex_array(&self, vertex_array: Self::VertexArray) {
let mut vertex_arrays = self.vertex_arrays.borrow_mut();
if let Some(ref va) = vertex_arrays.remove(vertex_array) {
Expand Down

0 comments on commit ac35eec

Please sign in to comment.