public void GetData <T>( int offsetInBytes, T[] data, int startIndex, int elementCount ) where T : struct { if (data == null) { throw new ArgumentNullException("data"); } if (data.Length < (startIndex + elementCount)) { throw new InvalidOperationException("The array specified in the data parameter is not the correct size for the amount of data requested."); } if (BufferUsage == BufferUsage.WriteOnly) { throw new NotSupportedException( "This IndexBuffer was created with a usage type of BufferUsage.WriteOnly. " + "Calling GetData on a resource that was created with BufferUsage.WriteOnly is not supported." ); } int elementSizeInBytes = Marshal.SizeOf(typeof(T)); GCHandle handle = GCHandle.Alloc(data, GCHandleType.Pinned); FNA3D.FNA3D_GetIndexBufferData( GraphicsDevice.GLDevice, buffer, offsetInBytes, handle.AddrOfPinnedObject() + (startIndex * elementSizeInBytes), elementCount * elementSizeInBytes ); handle.Free(); }