-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBuffer.cs
More file actions
30 lines (26 loc) · 873 Bytes
/
Buffer.cs
File metadata and controls
30 lines (26 loc) · 873 Bytes
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
using OpenGL;
namespace Licenta_ver1
{
/// <summary>
/// Buffer abstraction.
/// </summary>
public class Buffer : IDisposable
{
public Buffer(float[] buffer)
{
if (buffer == null)
throw new ArgumentNullException(nameof(buffer));
// Generate a buffer name: buffer does not exists yet
BufferName = Gl.GenBuffer();
// First bind create the buffer, determining its type
Gl.BindBuffer(BufferTarget.ArrayBuffer, BufferName);
// Set buffer information, 'buffer' is pinned automatically
Gl.BufferData(BufferTarget.ArrayBuffer, (uint)(4 * buffer.Length), buffer, BufferUsage.StaticDraw);
}
public readonly uint BufferName;
public void Dispose()
{
Gl.DeleteBuffers(BufferName);
}
}
}