-
-
Notifications
You must be signed in to change notification settings - Fork 427
/
Copy pathVertexArrayObject.cs
42 lines (35 loc) · 1.18 KB
/
VertexArrayObject.cs
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
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using Silk.NET.OpenGL;
namespace AndroidDemo
{
public class VertexArrayObject<TVertexType, TIndexType> : IDisposable
where TVertexType : unmanaged
where TIndexType : unmanaged
{
private uint _handle;
private GL _gl;
public VertexArrayObject(GL gl, BufferObject<TVertexType> vbo, BufferObject<TIndexType> ebo)
{
_gl = gl;
_handle = _gl.GenVertexArray();
Bind();
vbo.Bind();
ebo.Bind();
}
public unsafe void VertexAttributePointer(uint index, int count, VertexAttribPointerType type, uint vertexSize, int offSet)
{
_gl.VertexAttribPointer(index, count, type, false, vertexSize * (uint) sizeof(TVertexType), (void*) (offSet * sizeof(TVertexType)));
_gl.EnableVertexAttribArray(index);
}
public void Bind()
{
_gl.BindVertexArray(_handle);
}
public void Dispose()
{
_gl.DeleteVertexArray(_handle);
}
}
}