Permalink
Browse files

port VertexBuffer to OpenTK

  • Loading branch information...
1 parent 0831c2e commit 71c50a80199fa8c639c542d8ff7e28abb8d8738e @Mailaender committed Sep 12, 2012
Showing with 9 additions and 10 deletions.
  1. +9 −10 OpenRA.Renderer.SdlCommon/VertexBuffer.cs
@@ -12,8 +12,7 @@
using System.Runtime.InteropServices;
using OpenRA.FileFormats.Graphics;
using OpenTK;
-using OpenTK.Compatibility;
-using Tao.OpenGl;
+using OpenTK.Graphics.OpenGL;
namespace OpenRA.Renderer.SdlCommon
{
@@ -25,20 +24,20 @@ public class VertexBuffer<T> : IVertexBuffer<T>
public VertexBuffer(int size)
{
- Gl.glGenBuffersARB(1, out buffer);
+ GL.Arb.GenBuffers(1, out buffer);
ErrorHandler.CheckGlError();
Bind();
- Gl.glBufferDataARB(Gl.GL_ARRAY_BUFFER_ARB,
+ GL.Arb.BufferData(BufferTargetArb.ArrayBuffer,
new IntPtr(vertexSize * size),
new T[ size ],
- Gl.GL_DYNAMIC_DRAW_ARB);
+ BufferUsageArb.DynamicDraw);
ErrorHandler.CheckGlError();
}
public void SetData(T[] data, int length)
{
Bind();
- Gl.glBufferSubDataARB(Gl.GL_ARRAY_BUFFER_ARB,
+ GL.Arb.BufferSubData(BufferTargetArb.ArrayBuffer,
IntPtr.Zero,
new IntPtr(vertexSize * length),
data);
@@ -47,15 +46,15 @@ public void SetData(T[] data, int length)
public void Bind()
{
- Gl.glBindBufferARB(Gl.GL_ARRAY_BUFFER_ARB, buffer);
+ GL.Arb.BindBuffer(BufferTargetArb.ArrayBuffer, buffer);
ErrorHandler.CheckGlError();
- Gl.glVertexPointer(3, Gl.GL_FLOAT, vertexSize, IntPtr.Zero);
+ GL.VertexPointer(3, VertexPointerType.Float, vertexSize, IntPtr.Zero);
ErrorHandler.CheckGlError();
- Gl.glTexCoordPointer(4, Gl.GL_FLOAT, vertexSize, new IntPtr(12));
+ GL.TexCoordPointer(4, TexCoordPointerType.Float, vertexSize, new IntPtr(12));
ErrorHandler.CheckGlError();
}
- void FinalizeInner() { Gl.glDeleteBuffersARB( 1, ref buffer ); }
+ void FinalizeInner() { GL.Arb.DeleteBuffers( 1, ref buffer ); }
~VertexBuffer() { Game.RunAfterTick( FinalizeInner ); }
}
}

0 comments on commit 71c50a8

Please sign in to comment.