The CommonStates class is a factory which simplifies setting the most common combinations of Direct3D rendering states.
For exception safety, it is recommended you make use of the C++ RAII pattern and use a std::unique_ptr or std::shared_ptr
http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.blendstate_fields.aspx
Depth/Stencil State
http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.depthstencilstate_fields.aspx
Rasterizer State
http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.rasterizerstate_fields.aspx
Sampler State
http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.samplerstate_fields.aspx
Initialization
The CommonStates constructor requires a Direct3D 11 device.
std::unique_ptr<CommonStates> states(new CommonStates(device));
Using this helper to set device state
deviceContext->OMSetBlendState(states->Opaque(), Colors::Black, 0xFFFFFFFF);
deviceContext->OMSetDepthStencilState(states->DepthDefault(), 0);
deviceContext->RSSetState(states->CullCounterClockwise());
auto samplerState = states->LinearWrap();
deviceContext->PSSetSamplers(0, 1, &samplerState);
Available states
Blending Statehttp://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.blendstate_fields.aspx
- ID3D11BlendState* Opaque();
- ID3D11BlendState* AlphaBlend();
- ID3D11BlendState* Additive();
- ID3D11BlendState* NonPremultiplied();
Depth/Stencil State
http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.depthstencilstate_fields.aspx
- ID3D11DepthStencilState* DepthNone();
- ID3D11DepthStencilState* DepthDefault();
- ID3D11DepthStencilState* DepthRead();
Rasterizer State
http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.rasterizerstate_fields.aspx
- ID3D11RasterizerState* CullNone();
- ID3D11RasterizerState* CullClockwise();
- ID3D11RasterizerState* CullCounterClockwise();
- ID3D11RasterizerState* Wireframe();
Sampler State
http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.samplerstate_fields.aspx
- ID3D11SamplerState* PointWrap();
- ID3D11SamplerState* PointClamp();
- ID3D11SamplerState* LinearWrap();
- ID3D11SamplerState* LinearClamp();
- ID3D11SamplerState* AnisotropicWrap();
- ID3D11SamplerState* AnisotropicClamp();