-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVertexArray.cs
More file actions
41 lines (32 loc) · 1.12 KB
/
VertexArray.cs
File metadata and controls
41 lines (32 loc) · 1.12 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
using OpenGL;
namespace Licenta_ver1
{
/// <summary>
/// Vertex array abstraction.
/// </summary>
public class VertexArray : IDisposable
{
public VertexArray(ShaderProgram program, float[][] buffers, float[] bufferSizes)
{
if (program == null)
throw new ArgumentNullException(nameof(program));
_Buffers = new Buffer[bufferSizes.Length];
for (uint i = 0; i < bufferSizes.Length; i++)
{
_Buffers[i] = new Buffer(buffers[i]);
Gl.BindBuffer(BufferTarget.ArrayBuffer, _Buffers[i].BufferName);
Gl.VertexAttribPointer(i, (int)bufferSizes[i], VertexAttribType.Float, false, 0, IntPtr.Zero);
Gl.EnableVertexAttribArray(i);
}
}
public readonly uint ArrayName;
private readonly Buffer[] _Buffers;
public readonly int Size;
public void Dispose()
{
Gl.DeleteVertexArrays(ArrayName);
for (int i = 0; i < _Buffers.Length; i++)
_Buffers[i].Dispose();
}
}
}