Jump to content
  • Advertisement
Sign in to follow this  
endrollex

DX11 How to restore states after draw particle

This topic is 948 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello,

I use Frank Luna's DX11 code draw particle, after draw it will restore default states:

particle.draw();
D3DDC->RSSetState(0);
D3DDC->OMSetDepthStencilState(0, 0);
D3DDC->OMSetBlendState(0, {0.0f, 0.0f, 0.0f, 0.0f}, 0xffffffff);
sprite.draw();

This code restore failed,  then draw DirectXTK SpriteBatch will display nothing.

 

particle.draw();
D3DDC->ClearState();
D3DDC->OMSetRenderTargets(1, render_targets, DepthStencilView);
D3DDC->RSSetViewports(1, &ScreenViewport);
sprite.draw();

Use ClearState() will be OK, but I want to know which certain state is not restore correctly.

Is there step-by-step version of ClearState() existing?

Thanks!

Share this post


Link to post
Share on other sites
Advertisement

ID3D11DeviceContext::ClearState

 

 

This method resets any device context to the default settings. This sets all input/output resource slots, shaders, input layouts, predications, scissor rectangles, depth-stencil state, rasterizer state, blend state, sampler state, and viewports to NULL. The primitive topology is set to UNDEFINED.

 

Personally I never restore state after drawing.  Instead I set the state I want, and all of the state, before drawing, and the code is substantially cleaner and easier to follow/debug.

 

(Exceptions to this should be obvious: resetting rendertargets, etc).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!