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 crate::buffer::*;
use gl;
use std::mem;
impl Vertex2D {
///
/// Defines the attributes for this structure onto whatever vertex array object is currently bound
///
pub fn define_attributes() {
unsafe {
// Define the attributes
let stride = mem::size_of::<Self>() as gl::types::GLint;
let pos = 0;
// Attribute 0: a_Pos
gl::EnableVertexAttribArray(0);
gl::VertexAttribPointer(
0,
2,
gl::FLOAT,
gl::FALSE,
stride,
pos as *const gl::types::GLvoid);
let pos = pos + 2*mem::size_of::<f32>();
// Attribute 1: a_TexCoord
gl::EnableVertexAttribArray(1);
gl::VertexAttribPointer(
1,
2,
gl::FLOAT,
gl::FALSE,
stride,
pos as *const gl::types::GLvoid);
let pos = pos + 2*mem::size_of::<f32>();
// Attribute 2: a_Color
gl::EnableVertexAttribArray(2);
gl::VertexAttribPointer(
2,
4,
gl::UNSIGNED_BYTE,
gl::FALSE,
stride,
pos as *const gl::types::GLvoid);
}
}
}