# changing depth stencil state in DirectX11

An example from Frank D Luna's 3d Game Programming with Dx11 shows the following effect technique:

technique11 DrawTech
{
pass P0
{

SetBlendState(AdditiveBlending, float4(0.0f, 0.0f, 0.0f, 0.0f), 0xffffffff);
SetDepthStencilState( NoDepthWrites, 0 );
}
}


Setting depth stencil state, blend states etc (and restoring them to previous state) when the Effects library isn't available is my goal.

I've had a hard time finding examples on this though. Luna sidesteps the issue by using the effects framework in his book.

Can anyone help with an example or an svn repository that includes an example?

in the ID3D11DeviceContext, there is such function calls.

they are :
ID3D11DeviceContext::OMSetBlendState()
ID3D11DeviceContext::OMSetDepthStencilState()
ID3D11DeviceContext::OMSetRenderTargets()
ID3D11DeviceContext::OMSetRenderTargetsAndUnorderedAccessViews()

if you look at this website all of the things are listed here, and there you find how you use them and how they work.

http://msdn.microsoft.com/en-us/library/windows/desktop/ff476385(v=vs.85).aspx

for restoring to the last state, you have to have some kind of state machine implementation in your code, that stores the last used state. DX does not do this for you.

Eventualy, the effect library is using thees commands aswell, just that it has some extra stuff with it ( which i really hate ), so you can infact build your own effect system with this and use it more efficent than what you have in dx10/11.