-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVertexArrayObject.cs
More file actions
50 lines (44 loc) · 1.07 KB
/
Copy pathVertexArrayObject.cs
File metadata and controls
50 lines (44 loc) · 1.07 KB
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
using Silk.NET.OpenGL;
internal class VertexArrayObject<TVertexType, TIndexType> : IDisposable
where TVertexType : unmanaged
where TIndexType : unmanaged
{
private readonly GL Gl;
private readonly uint vao;
public VertexArrayObject(
GL Gl,
BufferObject<TVertexType> vbo,
BufferObject<TIndexType>? ebo = null
)
{
this.Gl = Gl;
vao = Gl.GenVertexArray();
Bind();
vbo.Bind();
ebo?.Bind();
}
public void VertexAttributePointer(
uint index,
int size,
VertexAttribPointerType type,
uint stride = 1,
int offset = 0
)
{
Bind();
unsafe
{
Gl.VertexAttribPointer(
index,
size,
type,
false,
stride * (uint)sizeof(TVertexType),
(void*)offset
);
}
Gl.EnableVertexAttribArray(index);
}
public void Bind() => Gl.BindVertexArray(vao);
public void Dispose() => Gl.DeleteVertexArray(vao);
}