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
use super::attribute_location::AttributeLocation;
use web_sys::{WebGl2RenderingContext, WebGlBuffer};

/// Context that is used when a new attribute is created
#[derive(Debug, Clone)]
pub struct AttributeCreateContext {
    gl: WebGl2RenderingContext,
    now: f64,
    webgl_buffer: WebGlBuffer,
    attribute_location: AttributeLocation,
}

impl AttributeCreateContext {
    /// @todo: make this into a builder pattern
    pub fn new(
        gl: WebGl2RenderingContext,
        now: f64,
        webgl_buffer: WebGlBuffer,
        attribute_location: AttributeLocation,
    ) -> Self {
        Self {
            gl,
            now,
            webgl_buffer,
            attribute_location,
        }
    }

    pub fn gl(&self) -> &WebGl2RenderingContext {
        &self.gl
    }

    pub fn now(&self) -> f64 {
        self.now
    }

    pub fn webgl_buffer(&self) -> &WebGlBuffer {
        &self.webgl_buffer
    }

    pub fn attribute_location(&self) -> &AttributeLocation {
        &self.attribute_location
    }
}