mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 13:01:52 +00:00
Textures can now hold SamplerStates
This commit is contained in:
@@ -39,7 +39,7 @@ namespace GlitchyEngine.Renderer
|
|||||||
nativeTexture.GetDescription(out nativeDesc);
|
nativeTexture.GetDescription(out nativeDesc);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Bind(uint32 slot)
|
protected override void ImplBind(uint32 slot)
|
||||||
{
|
{
|
||||||
_context.nativeContext.VertexShader.SetShaderResources(slot, 1, &nativeView);
|
_context.nativeContext.VertexShader.SetShaderResources(slot, 1, &nativeView);
|
||||||
_context.nativeContext.PixelShader.SetShaderResources(slot, 1, &nativeView);
|
_context.nativeContext.PixelShader.SetShaderResources(slot, 1, &nativeView);
|
||||||
|
|||||||
@@ -6,15 +6,39 @@ namespace GlitchyEngine.Renderer
|
|||||||
{
|
{
|
||||||
protected GraphicsContext _context ~ _?.ReleaseRef();
|
protected GraphicsContext _context ~ _?.ReleaseRef();
|
||||||
|
|
||||||
|
protected SamplerState _samplerState ~ _?.ReleaseRef();
|
||||||
|
|
||||||
public GraphicsContext Context => _context;
|
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 Width {get;}
|
||||||
public abstract uint32 Height {get;}
|
public abstract uint32 Height {get;}
|
||||||
public abstract uint32 Depth {get;}
|
public abstract uint32 Depth {get;}
|
||||||
public abstract uint32 ArraySize {get;}
|
public abstract uint32 ArraySize {get;}
|
||||||
public abstract uint32 MipLevels {get;}
|
public abstract uint32 MipLevels {get;}
|
||||||
|
|
||||||
public abstract void Bind(uint32 slot = 0);
|
public void Bind(uint32 slot = 0)
|
||||||
|
{
|
||||||
|
ImplBind(slot);
|
||||||
|
|
||||||
|
if(_samplerState != null)
|
||||||
|
_samplerState.Bind(slot);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract void ImplBind(uint32 slot);
|
||||||
|
|
||||||
protected this(GraphicsContext context)
|
protected this(GraphicsContext context)
|
||||||
{
|
{
|
||||||
@@ -32,7 +56,7 @@ namespace GlitchyEngine.Renderer
|
|||||||
public override extern uint32 ArraySize {get;}
|
public override extern uint32 ArraySize {get;}
|
||||||
public override extern uint32 MipLevels {get;}
|
public override extern uint32 MipLevels {get;}
|
||||||
|
|
||||||
public override extern void Bind(uint32 slot = 0);
|
protected override extern void ImplBind(uint32 slot);
|
||||||
|
|
||||||
public this(GraphicsContext context, String path) : base(context)
|
public this(GraphicsContext context, String path) : base(context)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -69,7 +69,6 @@ namespace Sandbox
|
|||||||
GraphicsContext _context ~ _?.ReleaseRef();
|
GraphicsContext _context ~ _?.ReleaseRef();
|
||||||
|
|
||||||
Texture2D _texture ~ _?.ReleaseRef();
|
Texture2D _texture ~ _?.ReleaseRef();
|
||||||
SamplerState _sampler ~ _?.ReleaseRef();
|
|
||||||
|
|
||||||
private Vector3 CircleCoord(float angle)
|
private Vector3 CircleCoord(float angle)
|
||||||
{
|
{
|
||||||
@@ -195,11 +194,14 @@ namespace Sandbox
|
|||||||
|
|
||||||
_texture = new Texture2D(_context, "content/Textures/Checkerboard.dds");
|
_texture = new Texture2D(_context, "content/Textures/Checkerboard.dds");
|
||||||
|
|
||||||
_sampler = new SamplerState(_context,
|
let sampler = new SamplerState(_context,
|
||||||
SamplerStateDescription()
|
SamplerStateDescription()
|
||||||
{
|
{
|
||||||
MagFilter = .Point
|
MagFilter = .Point
|
||||||
});
|
});
|
||||||
|
|
||||||
|
_texture.SamplerState = sampler;
|
||||||
|
sampler.ReleaseRef();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Update(GameTime gameTime)
|
public override void Update(GameTime gameTime)
|
||||||
@@ -269,7 +271,6 @@ namespace Sandbox
|
|||||||
_cBuffer.Update();
|
_cBuffer.Update();
|
||||||
|
|
||||||
_texture.Bind();
|
_texture.Bind();
|
||||||
_sampler.Bind();
|
|
||||||
|
|
||||||
Renderer.Submit(_geometryBinding, _effect);
|
Renderer.Submit(_geometryBinding, _effect);
|
||||||
Renderer.Submit(_quadGeometryBinding, _textureEffect, .Scaling(1.5f));
|
Renderer.Submit(_quadGeometryBinding, _textureEffect, .Scaling(1.5f));
|
||||||
|
|||||||
Reference in New Issue
Block a user