Quantcast
Channel: directxtk Wiki Rss Feed
Viewing all articles
Browse latest Browse all 874

Updated Wiki: CommonStates

$
0
0
The CommonStates class is a factory which simplifies setting the most common
combinations of D3D rendering states.

Initialization

The CommonStates constructor requires a Direct3D 11 device.

std::unique_ptr<CommonStates> states(new CommonStates(device));
For exception safety, it is recommended you make use of the C++ RAII pattern and use a std::unique_ptr or std::shared_ptr

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

ID3D11BlendState* Opaque();
ID3D11BlendState* AlphaBlend();
ID3D11BlendState* Additive();
ID3D11BlendState* NonPremultiplied();

ID3D11DepthStencilState* DepthNone();
ID3D11DepthStencilState* DepthDefault();
ID3D11DepthStencilState* DepthRead();

ID3D11RasterizerState* CullNone();
ID3D11RasterizerState* CullClockwise();
ID3D11RasterizerState* CullCounterClockwise();
ID3D11RasterizerState* Wireframe();

ID3D11SamplerState* PointWrap();
ID3D11SamplerState* PointClamp();
ID3D11SamplerState* LinearWrap();
ID3D11SamplerState* LinearClamp();
ID3D11SamplerState* AnisotropicWrap();
ID3D11SamplerState* AnisotropicClamp();

Viewing all articles
Browse latest Browse all 874

Trending Articles