public void SetData <T>( int level, Rectangle?rect, T[] data, int startIndex, int elementCount ) where T : struct { if (data == null) { throw new ArgumentNullException("data"); } int x, y, w, h; if (rect.HasValue) { x = rect.Value.X; y = rect.Value.Y; w = rect.Value.Width; h = rect.Value.Height; } else { x = 0; y = 0; w = Math.Max(Width >> level, 1); h = Math.Max(Height >> level, 1); } int elementSize = Marshal.SizeOf(typeof(T)); GCHandle handle = GCHandle.Alloc(data, GCHandleType.Pinned); FNA3D.FNA3D_SetTextureData2D( GraphicsDevice.GLDevice, texture, x, y, w, h, level, handle.AddrOfPinnedObject() + startIndex * elementSize, elementCount * elementSize ); handle.Free(); }
public void SetDataPointerEXT( int level, Rectangle?rect, IntPtr data, int dataLength ) { if (data == IntPtr.Zero) { throw new ArgumentNullException("data"); } int x, y, w, h; if (rect.HasValue) { x = rect.Value.X; y = rect.Value.Y; w = rect.Value.Width; h = rect.Value.Height; } else { x = 0; y = 0; w = Math.Max(Width >> level, 1); h = Math.Max(Height >> level, 1); } FNA3D.FNA3D_SetTextureData2D( GraphicsDevice.GLDevice, texture, x, y, w, h, level, data, dataLength ); }