using System; namespace GlitchyEngine.Renderer { public abstract class Texture : RefCounted { protected GraphicsContext _context ~ _?.ReleaseRef(); protected SamplerState _samplerState ~ _?.ReleaseRef(); public GraphicsContext Context => _context; public SamplerState SamplerState { get => _samplerState; set { if(_samplerState == value) return; _samplerState?.ReleaseRef(); _samplerState = value; _samplerState?.AddRef(); } } public abstract uint32 Width {get;} public abstract uint32 Height {get;} public abstract uint32 Depth {get;} public abstract uint32 ArraySize {get;} public abstract uint32 MipLevels {get;} public void Bind(uint32 slot = 0) { ImplBind(slot); if(_samplerState != null) _samplerState.Bind(slot); } protected extern void ImplBind(uint32 slot); protected this(GraphicsContext context) { _context = context..AddRef(); } } public class Texture2D : Texture { protected String _path ~ delete _; public override extern uint32 Width {get;} public override extern uint32 Height {get;} public override uint32 Depth => 1; public override extern uint32 ArraySize {get;} public override extern uint32 MipLevels {get;} public this(GraphicsContext context, String path) : base(context) { this._path = new String(path); LoadTexturePlatform(); } protected extern void LoadTexturePlatform(); } }