Add glDrawElements
This commit is contained in:
committed by
Matthias Mailänder
parent
f6c1453b5b
commit
9b8895df39
@@ -50,6 +50,7 @@ namespace OpenRA.Platforms.Default
|
||||
|
||||
// Data types
|
||||
public const int GL_UNSIGNED_BYTE = 0x1401;
|
||||
public const int GL_UNSIGNED_INT = 0x1405;
|
||||
public const int GL_FLOAT = 0x1406;
|
||||
|
||||
// Errors
|
||||
@@ -394,6 +395,9 @@ namespace OpenRA.Platforms.Default
|
||||
public delegate void DrawArrays(int mode, int first, int count);
|
||||
public static DrawArrays glDrawArrays { get; private set; }
|
||||
|
||||
public delegate void DrawElements(int mode, int count, int type, IntPtr indices);
|
||||
public static DrawElements glDrawElements { get; private set; }
|
||||
|
||||
public delegate void Enable(int cap);
|
||||
public static Enable glEnable { get; private set; }
|
||||
|
||||
@@ -590,6 +594,7 @@ namespace OpenRA.Platforms.Default
|
||||
glEnableVertexAttribArray = Bind<EnableVertexAttribArray>("glEnableVertexAttribArray");
|
||||
glDisableVertexAttribArray = Bind<DisableVertexAttribArray>("glDisableVertexAttribArray");
|
||||
glDrawArrays = Bind<DrawArrays>("glDrawArrays");
|
||||
glDrawElements = Bind<DrawElements>("glDrawElements");
|
||||
glBlendEquation = Bind<BlendEquation>("glBlendEquation");
|
||||
glBlendEquationSeparate = Bind<BlendEquationSeparate>("glBlendEquationSeparate");
|
||||
glBlendFunc = Bind<BlendFunc>("glBlendFunc");
|
||||
|
||||
@@ -170,6 +170,13 @@ namespace OpenRA.Platforms.Default
|
||||
OpenGL.CheckGLError();
|
||||
}
|
||||
|
||||
public void DrawElements(int numIndices, int offset)
|
||||
{
|
||||
VerifyThreadAffinity();
|
||||
OpenGL.glDrawElements(OpenGL.GL_TRIANGLES, numIndices, OpenGL.GL_UNSIGNED_INT, new IntPtr(offset));
|
||||
OpenGL.CheckGLError();
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
VerifyThreadAffinity();
|
||||
|
||||
@@ -48,6 +48,7 @@ namespace OpenRA.Platforms.Default
|
||||
Func<object, IVertexBuffer<Vertex>> getCreateVertexBuffer;
|
||||
Func<object, IIndexBuffer> getCreateIndexBuffer;
|
||||
Action<object> doDrawPrimitives;
|
||||
Action<object> doDrawElements;
|
||||
Action<object> doEnableScissor;
|
||||
Action<object> doSetBlendMode;
|
||||
Action<object> doSetVSync;
|
||||
@@ -102,6 +103,12 @@ namespace OpenRA.Platforms.Default
|
||||
var t = ((PrimitiveType, int, int))tuple;
|
||||
context.DrawPrimitives(t.Item1, t.Item2, t.Item3);
|
||||
};
|
||||
doDrawElements =
|
||||
tuple =>
|
||||
{
|
||||
var t = ((int, int))tuple;
|
||||
context.DrawElements(t.Item1, t.Item2);
|
||||
};
|
||||
doEnableScissor =
|
||||
tuple =>
|
||||
{
|
||||
@@ -431,6 +438,11 @@ namespace OpenRA.Platforms.Default
|
||||
Post(doDrawPrimitives, (type, firstVertex, numVertices));
|
||||
}
|
||||
|
||||
public void DrawElements(int numIndices, int offset)
|
||||
{
|
||||
Post(doDrawElements, (numIndices, offset));
|
||||
}
|
||||
|
||||
public void EnableDepthBuffer()
|
||||
{
|
||||
Post(doEnableDepthBuffer);
|
||||
|
||||
Reference in New Issue
Block a user