Initialise VertexBuffers immediately
This commit is contained in:
@@ -55,6 +55,28 @@ namespace OpenRA.Platforms.Default
|
||||
}
|
||||
}
|
||||
|
||||
public VertexBuffer(T[] data, bool dynamic = true)
|
||||
{
|
||||
OpenGL.glGenBuffers(1, out buffer);
|
||||
OpenGL.CheckGLError();
|
||||
Bind();
|
||||
|
||||
var ptr = GCHandle.Alloc(data, GCHandleType.Pinned);
|
||||
try
|
||||
{
|
||||
OpenGL.glBufferData(OpenGL.GL_ARRAY_BUFFER,
|
||||
new IntPtr(VertexSize * data.Length),
|
||||
ptr.AddrOfPinnedObject(),
|
||||
dynamic ? OpenGL.GL_DYNAMIC_DRAW : OpenGL.GL_STATIC_DRAW);
|
||||
}
|
||||
finally
|
||||
{
|
||||
ptr.Free();
|
||||
}
|
||||
|
||||
OpenGL.CheckGLError();
|
||||
}
|
||||
|
||||
public void SetData(T[] data, int length)
|
||||
{
|
||||
SetData(data, 0, 0, length);
|
||||
|
||||
Reference in New Issue
Block a user