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
67
68
69
70
71
72
73
74
75
use Program;
use types::*;
pub struct UniformData(pub(crate) GLint, Program);
impl UniformData {
pub fn new(program: &Program, name: &[u8]) -> Self {
assert_eq!(name[name.len() -1], b'\0');
let opengl = program.opengl();
let r = gl!(opengl, (opengl.get().uniform)(program.get(),
name.as_ptr() as *const _));
UniformData(r, program.clone())
}
pub fn is_none(&self) -> bool {
self.0 == -1
}
pub fn set_mat4(&self, mat4: [f32; 16]) -> () {
self.1.bind();
let opengl = self.1.opengl();
gl!(opengl, (opengl.get().uniform_mat4)(self.0, 1,
0 , mat4.as_ptr()));
}
pub fn set_int1(&self, int1: i32) -> () {
self.1.bind();
let opengl = self.1.opengl();
gl!(opengl, (opengl.get().uniform_int1)(self.0, int1));
}
pub fn set_vec1(&self, vec1: f32) -> () {
self.1.bind();
let opengl = self.1.opengl();
gl!(opengl, (opengl.get().uniform_vec1)(self.0, vec1));
}
pub fn set_vec2(&self, vec: &[f32; 2]) -> () {
self.1.bind();
let opengl = self.1.opengl();
gl!(opengl, (opengl.get().uniform_vec2)(self.0, vec[0],
vec[1]));
}
pub fn set_vec3(&self, vec: &[f32; 3]) -> () {
self.1.bind();
let opengl = self.1.opengl();
gl!(opengl, (opengl.get().uniform_vec3)(self.0, vec[0],
vec[1], vec[2]));
}
pub fn set_vec4(&self, vec: &[f32; 4]) -> () {
self.1.bind();
let opengl = self.1.opengl();
gl!(opengl, (opengl.get().uniform_vec4)(self.0, vec[0],
vec[1], vec[2], vec[3]));
}
}