mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 13:01:52 +00:00
Added constructor and SetData to Texture2D
obviously this has to be done for the other texture types as well at some point
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using GlitchyEngine.Math;
|
||||
|
||||
namespace GlitchyEngine.Renderer
|
||||
{
|
||||
@@ -53,6 +54,8 @@ namespace GlitchyEngine.Renderer
|
||||
public uint32 ArraySize;
|
||||
public uint32 MipLevels;
|
||||
public Format Format;
|
||||
public Usage Usage;
|
||||
public CPUAccessFlags CpuAccess;
|
||||
}
|
||||
|
||||
public class Texture2D : Texture
|
||||
@@ -73,9 +76,49 @@ namespace GlitchyEngine.Renderer
|
||||
LoadTexturePlatform();
|
||||
}
|
||||
|
||||
public this(GraphicsContext context, Texture2DDesc desc) : base(context)
|
||||
{
|
||||
PrepareTexturePlatform(desc);
|
||||
}
|
||||
|
||||
public void SetData<T>(T* data, uint32 arraySlice = 0, uint32 mipSlice = 0)
|
||||
{
|
||||
PlatformSetData(data, (.)sizeof(T), 0, 0, Width, Height, arraySlice, mipSlice, .Write);
|
||||
}
|
||||
|
||||
public void SetData<T>(T* data, uint32 x, uint32 y, uint32 width, uint32 height, uint32 arraySlice = 0, uint32 mipSlice = 0)
|
||||
{
|
||||
PlatformSetData(data, (.)sizeof(T), x, y, width, height, arraySlice, mipSlice, .Write);
|
||||
}
|
||||
|
||||
/*
|
||||
uint32 width, uint32 height, Format format,
|
||||
uint32 mipLevels = 1, uint32 arraySize = 1, Usage usage = .Default, CPUAccessFlags cpuAccess = .None
|
||||
*/
|
||||
|
||||
protected extern void LoadTexturePlatform();
|
||||
|
||||
protected extern void CreateTexturePlatform(Texture2DDesc desc, void* data, uint32 linePitch);
|
||||
|
||||
/**
|
||||
* Prepares the texture so that a call to SetData can successfully upload the data to the gpu.
|
||||
*/
|
||||
protected extern void PrepareTexturePlatform(Texture2DDesc desc);
|
||||
|
||||
protected extern Result<void> PlatformSetData(void* data, uint32 elementSize, uint32 destX,
|
||||
uint32 destY, uint32 destWidth, uint32 destHeight, uint32 arraySlice, uint32 mipLevel, GlitchyEngine.Renderer.MapType mapType);
|
||||
|
||||
/**
|
||||
* Copies the texel-data of this texture to the given destination texture.
|
||||
*/
|
||||
public static extern void CopySubresourceRegion(Texture2D source, Texture2D destination,
|
||||
ResourceBox sourceBox = default, uint32 destX = 0, uint32 destY = 0,
|
||||
uint32 srcArraySlice = 0, uint32 srcMipSlice = 0, uint32 destArraySlice = 0, uint32 destMipSlice = 0);
|
||||
|
||||
/**
|
||||
* Copies the data to the given destination.
|
||||
*/
|
||||
public extern void CopyTo(Texture2D destination);
|
||||
}
|
||||
|
||||
public class TextureCube : Texture
|
||||
|
||||
Reference in New Issue
Block a user