using SDL2_gpuCS;
namespace MoonWorks.Graphics;
///
/// Specifies how the rasterizer should be configured for a graphics pipeline.
///
public struct RasterizerState
{
///
/// Specifies whether front faces, back faces, none, or both should be culled.
///
public CullMode CullMode;
///
/// Specifies maximum depth bias of a fragment. Only applies if depth biasing is enabled.
///
public float DepthBiasClamp;
///
/// The constant depth value added to each fragment. Only applies if depth biasing is enabled.
///
public float DepthBiasConstantFactor;
///
/// Specifies whether depth biasing is enabled. Only applies if depth biasing is enabled.
///
public bool DepthBiasEnable;
///
/// Factor applied to a fragment's slope in depth bias calculations. Only applies if depth biasing is enabled.
///
public float DepthBiasSlopeFactor;
///
/// Specifies how triangles should be drawn.
///
public FillMode FillMode;
///
/// Specifies which triangle winding order is designated as front-facing.
///
public FrontFace FrontFace;
public static readonly RasterizerState CW_CullFront = new RasterizerState
{
CullMode = CullMode.Front,
FrontFace = FrontFace.Clockwise,
FillMode = FillMode.Fill,
DepthBiasEnable = false
};
public static readonly RasterizerState CW_CullBack = new RasterizerState
{
CullMode = CullMode.Back,
FrontFace = FrontFace.Clockwise,
FillMode = FillMode.Fill,
DepthBiasEnable = false
};
public static readonly RasterizerState CW_CullNone = new RasterizerState
{
CullMode = CullMode.None,
FrontFace = FrontFace.Clockwise,
FillMode = FillMode.Fill,
DepthBiasEnable = false
};
public static readonly RasterizerState CW_Wireframe = new RasterizerState
{
CullMode = CullMode.None,
FrontFace = FrontFace.Clockwise,
FillMode = FillMode.Line,
DepthBiasEnable = false
};
public static readonly RasterizerState CCW_CullFront = new RasterizerState
{
CullMode = CullMode.Front,
FrontFace = FrontFace.CounterClockwise,
FillMode = FillMode.Fill,
DepthBiasEnable = false
};
public static readonly RasterizerState CCW_CullBack = new RasterizerState
{
CullMode = CullMode.Back,
FrontFace = FrontFace.CounterClockwise,
FillMode = FillMode.Fill,
DepthBiasEnable = false
};
public static readonly RasterizerState CCW_CullNone = new RasterizerState
{
CullMode = CullMode.None,
FrontFace = FrontFace.CounterClockwise,
FillMode = FillMode.Fill,
DepthBiasEnable = false
};
public static readonly RasterizerState CCW_Wireframe = new RasterizerState
{
CullMode = CullMode.None,
FrontFace = FrontFace.CounterClockwise,
FillMode = FillMode.Line,
DepthBiasEnable = false
};
public SDL_Gpu.RasterizerState ToSDL()
{
return new SDL_Gpu.RasterizerState
{
CullMode = (SDL_Gpu.CullMode) CullMode,
DepthBiasClamp = DepthBiasClamp,
DepthBiasConstantFactor = DepthBiasConstantFactor,
DepthBiasEnable = Conversions.BoolToInt(DepthBiasEnable),
DepthBiasSlopeFactor = DepthBiasSlopeFactor,
FillMode = (SDL_Gpu.FillMode) FillMode,
FrontFace = (SDL_Gpu.FrontFace) FrontFace
};
}
}