change type buffer setdata to use element offset and length

pull/14/head
cosmonaut 2021-02-01 22:53:24 -08:00
parent ada9a1bb05
commit 68bb51439f
1 changed files with 11 additions and 8 deletions

View File

@ -23,18 +23,20 @@ namespace MoonWorks.Graphics
public unsafe void SetData<T>(
T[] data,
uint offsetInBytes,
uint dataLengthInBytes
uint offsetInElements,
uint lengthInElements
) where T : unmanaged
{
var elementSize = Marshal.SizeOf<T>();
fixed (T* ptr = &data[0])
{
Refresh.Refresh_SetBufferData(
Device.Handle,
Handle,
offsetInBytes,
(uint) (offsetInElements * elementSize),
(IntPtr) ptr,
dataLengthInBytes
(uint) (lengthInElements * elementSize)
);
}
}
@ -71,15 +73,16 @@ namespace MoonWorks.Graphics
public unsafe void SetData<T>(
T* data,
uint offsetInBytes,
uint dataLengthInBytes
uint offsetInElements,
uint lengthInElements
) where T : unmanaged {
var elementSize = Marshal.SizeOf<T>();
Refresh.Refresh_SetBufferData(
Device.Handle,
Handle,
offsetInBytes,
(uint) (offsetInElements * elementSize),
(IntPtr) data,
dataLengthInBytes
(uint) (lengthInElements * elementSize)
);
}