.
This commit is contained in:
22
Engine/Renderer/Texture/ITexture.cs
Normal file
22
Engine/Renderer/Texture/ITexture.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using Engine.Asset;
|
||||
using Engine.Renderer.Pixel;
|
||||
|
||||
namespace Engine.Renderer.Texture;
|
||||
|
||||
public interface ITexture<T> : IConstTexture<T> where T : struct, IPixel
|
||||
{
|
||||
public void UploadPixels(int x, int y, int width, int height, T[,] pixels);
|
||||
}
|
||||
|
||||
public static class TextureExtensions
|
||||
{
|
||||
public static void UploadPixels<T>(this ITexture<T> texture, Image<T> image) where T : struct, IPixel
|
||||
=> texture.UploadPixels(0, 0, image);
|
||||
|
||||
public static void UploadPixels<T>(this ITexture<T> texture, int x, int y, Image<T> image)
|
||||
where T : struct, IPixel =>
|
||||
texture.UploadPixels(x, y, image.Width, image.Height, image.Pixels);
|
||||
|
||||
public static void UploadPixels<T>(this ITexture<T> texture, T[,] pixels) where T : struct, IPixel
|
||||
=> texture.UploadPixels(0, 0, texture.Width, texture.Height, pixels);
|
||||
}
|
||||
Reference in New Issue
Block a user