1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//! VertextArrayObject and methods
use rendering_context::WebGL2RenderingContext;
use wasm_bindgen::prelude::*;
impl WebGL2RenderingContext {
/// Creates and initializes a WebGLRSVertexArrayObject object that represents a vertex array object
/// (VAO) pointing to vertex array data and which provides names for different sets of vertex data.
pub fn create_vertex_array(&self) -> WebGLRSVertexArrayObject {
WebGLRSVertexArrayObject {
context: self,
inner: self._create_vertex_array(),
}
}
}
/// VertexArrayObject
///
/// The WebGLVertexArrayObject interface is part of the WebGL 2 API, represents vertex array objects (VAOs)
/// pointing to vertex array data, and provides names for different sets of vertex data.
#[derive(Clone)]
pub struct WebGLRSVertexArrayObject<'ctx> {
context: &'ctx WebGL2RenderingContext,
inner: WebGLVertexArrayObject,
}
impl<'ctx> WebGLRSVertexArrayObject<'ctx> {
/// Deletes the `WebGLRSVertexArrayObject` on the gpu and consumes itself.
pub fn delete(self) {
self.context._delete_vertex_array(self.inner);
}
/// Return true if this is a valid `WebGLRSVertexArrayObject` object.
pub fn is_valid(&self) -> bool {
self.context._is_vertex_array(&self.inner)
}
/// Binds this `WebGLRSVertexArrayObject` to the buffer.
pub fn bind(&self) {
self.context._bind_vertex_array(&self.inner);
}
}
/// WebGLVerterArrayObject bindings
#[wasm_bindgen]
extern "C" {
#[derive(Clone)]
type WebGLVertexArrayObject;
/// Binding for `WebGL2RenderingContext.createVertexArray()`
#[wasm_bindgen(method, js_name = createVertexArray)]
fn _create_vertex_array(this: &WebGL2RenderingContext) -> WebGLVertexArrayObject;
/// Binding for `WebGL2RenderingContext.deleteVertexArray()`
#[wasm_bindgen(method, js_name = deleteVertexArray)]
fn _delete_vertex_array(this: &WebGL2RenderingContext, vertex_array: WebGLVertexArrayObject);
/// Binding for `WebGL2RenderingContext.isVertexArray()`
#[wasm_bindgen(method, js_name = isVertexArray)]
fn _is_vertex_array(
this: &WebGL2RenderingContext,
vertex_array: &WebGLVertexArrayObject,
) -> bool;
/// Binding for `WebGL2RenderingContext.bindVertexArray()`
#[wasm_bindgen(method, js_name = bindVertexArray)]
fn _bind_vertex_array(this: &WebGL2RenderingContext, vertex_array: &WebGLVertexArrayObject);
}