This commit is contained in:
2024-12-04 22:35:04 +03:00
commit 3f1740f41f
43 changed files with 1757 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
using Engine.Renderer.Pixel;
using OpenTK.Graphics.OpenGL;
namespace Engine.Renderer.Texture;
public class DynamicTexture<T> : Texture<T> where T : struct, IPixel
{
private readonly PixelFormat _format;
private readonly PixelType _type;
private readonly PixelInternalFormat _internalFormat;
public DynamicTexture(int width, int height) : base(width, height)
{
var pixel = default(T);
_format = pixel.Format;
_type = pixel.Type;
_internalFormat = pixel.InternalFormat;
GL.BindTexture(TextureTarget.Texture2D, Handle);
GL.TexImage2D(TextureTarget.Texture2D, 0, _internalFormat, Width, Height, 0, _format, _type,
IntPtr.Zero);
}
public void Resize(int width, int height)
{
if (Width == width && Height == height)
return;
Width = width;
Height = height;
Bind();
GL.TexImage2D(TextureTarget.Texture2D, 0, _internalFormat, Width, Height, 0, _format, _type,
IntPtr.Zero);
}
}