So far, this is the best way I can think of for modifying the current RasterizerStateDescription:
class Renderer
...
public bool Wireframe
{
set
{
RasterizerStateDescription curr = _device.ImmediateContext.Rasterizer.State.Description;
RasterizerStateDescription description = new RasterizerStateDescription
{
CullMode = curr.CullMode,
DepthBias = curr.DepthBias,
DepthBiasClamp = curr.DepthBiasClamp,
FillMode = (value ? FillMode.Wireframe : FillMode.Solid),
IsAntialiasedLineEnabled = curr.IsAntialiasedLineEnabled,
IsDepthClipEnabled = curr.IsDepthClipEnabled,
IsFrontCounterclockwise = curr.IsFrontCounterclockwise,
IsMultisampleEnabled = curr.IsMultisampleEnabled,
IsScissorEnabled = curr.IsScissorEnabled,
SlopeScaledDepthBias = curr.SlopeScaledDepthBias,
};
RasterizerState rs = RasterizerState.FromDescription(_device, description);
_device.ImmediateContext.Rasterizer.State = rs;
}
}
This seems necessary because the ImmediateContext's Rasterizer.State.Description is read only. Is there a simpler method for modifying one part of the state at a time, or do I have the right idea?
Alternatively, should I keep track of state in my code, and then just set the RasterizerStateDescription once?
Thanks.