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
use glium::texture::Texture2d;
use glium::uniforms;
#[derive(Copy, Debug, Clone)]
pub struct ColorVertex {
pub pos: [f32; 2],
pub color: [f32; 4],
}
implement_vertex!(ColorVertex, pos, color);
#[derive(Copy, Debug, Clone)]
pub struct TexVertex {
pub pos: [f32; 2],
pub tex_coords: [f32; 2]
}
implement_vertex!(TexVertex, pos, tex_coords);
pub struct ColorParams {
pub matrix: [[f32; 4]; 4],
}
impl uniforms::Uniforms for ColorParams {
fn visit_values<'b, F>(&'b self, mut f: F) where F: FnMut(&str, uniforms::UniformValue<'b>) {
use glium::uniforms::AsUniformValue;
f("matrix", self.matrix.as_uniform_value());
}
}
pub struct TexParams<'a> {
pub matrix: [[f32; 4]; 4],
pub tex: &'a Texture2d,
pub color_mult: [f32; 4]
}
impl <'a> uniforms::Uniforms for TexParams<'a> {
fn visit_values<'b, F>(&'b self, mut f: F) where F: FnMut(&str, uniforms::UniformValue<'b>) {
use glium::uniforms::AsUniformValue;
f("matrix", self.matrix.as_uniform_value());
f("tex", self.tex.as_uniform_value());
f("color_mult", self.color_mult.as_uniform_value());
}
}