-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathTriangleDrawable.cs
39 lines (36 loc) · 1.08 KB
/
TriangleDrawable.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
using OpenTK.Graphics.OpenGL;
using System;
using Core.Primitive;
namespace Core
{
//@ T : VertexAttribute
public class TriangleDrawable<T> : DrawableBase<T> where T : struct, IGenericVertexAttribute
{
public TriangleDrawable()
{
}
public override void Draw()
{
if (mbReadyToDraw)
{
BindVertexArray();
BindIndexBuffer();
GL.DrawElements(PrimitiveType.Triangles, mIndexCount, DrawElementsType.UnsignedInt, 0);
UnbindIndexBuffer();
UnbindVertexArray();
}
}
public override void Draw(uint Offset, uint Count)
{
if(mbReadyToDraw)
{
BindVertexArray();
BindIndexBuffer();
var ByteOffset = new IntPtr(Offset * sizeof(uint));
GL.DrawElements(PrimitiveType.Triangles, (int)Count, DrawElementsType.UnsignedInt, ByteOffset);
UnbindIndexBuffer();
UnbindVertexArray();
}
}
}
}