public void SetData <T>(T[] source, int sourceStartIndex, int sourceCount, int targetStartIndex = 0) where T : struct { VerifyParametersSetData(source, sourceStartIndex, sourceCount, targetStartIndex); GCHandle gCHandle = GCHandle.Alloc(source, GCHandleType.Pinned); try { int num = Utilities.SizeOf <T>(); int vertexStride = VertexDeclaration.VertexStride; GLWrapper.BindBuffer(All.ArrayBuffer, m_buffer); GL.BufferSubData(All.ArrayBuffer, new IntPtr(targetStartIndex * vertexStride), new IntPtr(num * sourceCount), gCHandle.AddrOfPinnedObject() + sourceStartIndex * num); } finally { gCHandle.Free(); } }
public void AllocateBuffer() { GL.GenBuffers(1, out m_buffer); GLWrapper.BindBuffer(All.ArrayBuffer, m_buffer); GL.BufferData(All.ArrayBuffer, new IntPtr(VertexDeclaration.VertexStride * VerticesCount), IntPtr.Zero, All.StaticDraw); }
public void AllocateBuffer() { GL.GenBuffers(1, out m_buffer); GLWrapper.BindBuffer(All.ElementArrayBuffer, m_buffer); GL.BufferData(All.ElementArrayBuffer, new IntPtr(IndexFormat.GetSize() * IndicesCount), IntPtr.Zero, All.StaticDraw); }