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
use super::*;
/// Geometry bindings
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Bindings {
/// Vertex buffers. Data contained in the buffer must match layout
/// specified in the `Pipeline`.
///
/// Most commonly vertex buffer will contain `(x,y,z,w)` coordinates of the
/// vertex in 3d space, as well as `(u,v)` coordinates that map the vertex
/// to some position in the corresponding `Texture`.
pub vertex_buffers: Vec<RawShaderID>,
/// Index buffer which instructs the GPU in which order to draw vertices
/// from a vertex buffer, with each subsequent 3 indices forming a
/// triangle.
pub index_buffer: RawShaderID,
/// Textures to be used with when drawing the geometry in the fragment
/// shader.
pub images: Vec<RawTextureID>,
}
impl Bindings
{
pub fn view<'a>(&'a self) -> BindingsView<'a>
{
let Self { vertex_buffers, index_buffer, images } = self;
BindingsView { vertex_buffers, index_buffer : *index_buffer, images }
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct BindingsView<'a>
{
/// Vertex buffers. Data contained in the buffer must match layout
/// specified in the `PipelineID`.
///
/// Most commonly vertex buffer will contain `(x,y,z,w)` coordinates of the
/// vertex in 3d space, as well as `(u,v)` coordinates that map the vertex
/// to some position in the corresponding `Texture`.
pub vertex_buffers: &'a [RawShaderID],
/// Index buffer which instructs the GPU in which order to draw vertices
/// from a vertex buffer, with each subsequent 3 indices forming a
/// triangle.
pub index_buffer: RawShaderID,
/// Textures to be used with when drawing the geometry in the fragment
/// shader.
pub images: &'a [RawTextureID],
}