mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 21:01:52 +00:00
Added RasterizerState
This commit is contained in:
@@ -7,6 +7,8 @@ namespace GlitchyEngine.Renderer
|
||||
//public abstract class GraphicsContext
|
||||
public class GraphicsContext
|
||||
{
|
||||
private RasterizerState _currentRasterizerState;
|
||||
|
||||
//public abstract SwapChain SwapChain {get;}
|
||||
public extern SwapChain SwapChain {get;}
|
||||
|
||||
@@ -76,5 +78,18 @@ namespace GlitchyEngine.Renderer
|
||||
}
|
||||
|
||||
public extern void SetIndexBuffer(Buffer buffer, IndexFormat indexFormat = .Index16Bit, uint32 byteOffset = 0);
|
||||
|
||||
public void SetRasterizerState(RasterizerState rasterizerState)
|
||||
{
|
||||
_currentRasterizerState = rasterizerState;
|
||||
SetRasterizerStateImpl();
|
||||
}
|
||||
|
||||
protected extern void SetRasterizerStateImpl();
|
||||
|
||||
public RasterizerState GetRasterizerState()
|
||||
{
|
||||
return _currentRasterizerState;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
namespace GlitchyEngine.Renderer
|
||||
{
|
||||
public enum FillMode
|
||||
{
|
||||
Wireframe,
|
||||
Solid
|
||||
}
|
||||
|
||||
public enum CullMode
|
||||
{
|
||||
None,
|
||||
Front,
|
||||
Back
|
||||
}
|
||||
|
||||
public struct RasterizerStateDescription
|
||||
{
|
||||
public FillMode FillMode;
|
||||
public CullMode CullMode;
|
||||
public bool FrontCounterClockwise;
|
||||
public int32 DepthBias;
|
||||
public float DepthBiasClamp;
|
||||
public float SlopeScaledDepthBias;
|
||||
public bool DepthClipEnabled;
|
||||
public bool ScissorEnabled;
|
||||
public bool MultisampleEnabled;
|
||||
public bool AntialiasedLineEnabled;
|
||||
|
||||
public this() => this = default;
|
||||
|
||||
/**
|
||||
Initializes the RasterizerStateDescription with the specified values
|
||||
*/
|
||||
public this(FillMode fillMode, CullMode cullMode = .Back, bool frontCounterClockwise = false, int32 depthBias = 0, float depthBiasClamp = 0.0f,
|
||||
float slopeScaledDepthBias = 0.0f, bool depthClipEnabled = true, bool scissorEnabled = false, bool multisampleEnabled = false, bool antialiasedLineEnabled = false)
|
||||
{
|
||||
FillMode = fillMode;
|
||||
CullMode = cullMode;
|
||||
FrontCounterClockwise = frontCounterClockwise;
|
||||
DepthBias = depthBias;
|
||||
DepthBiasClamp = depthBiasClamp;
|
||||
SlopeScaledDepthBias = slopeScaledDepthBias;
|
||||
DepthClipEnabled = depthClipEnabled;
|
||||
ScissorEnabled = scissorEnabled;
|
||||
MultisampleEnabled = multisampleEnabled;
|
||||
AntialiasedLineEnabled = antialiasedLineEnabled;
|
||||
}
|
||||
|
||||
public static readonly RasterizerStateDescription Default = .(.Solid, .Back, false, 0, 0f, 0f, true, false, false, false);
|
||||
}
|
||||
|
||||
public class RasterizerState
|
||||
{
|
||||
internal GraphicsContext _context;
|
||||
private RasterizerStateDescription _description;
|
||||
|
||||
public GraphicsContext Context => _context;
|
||||
public RasterizerStateDescription Description => _description;
|
||||
|
||||
protected this(GraphicsContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public extern this(GraphicsContext context, RasterizerStateDescription description);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user