Pushing the renderstate, to easily restore a default

I have a number of objects which all have slightly different renderstates. I currently have to save the old state, change it on the device, render and then restore each state one by one.

I can get the total renderstate from a device and save it, but I can not reassign it like so...

oldRenderstate = device.RenderState;

do stuff

device.RenderSTate= oldRenderstate.

Can I somehow push the renderstate and later pop it back in



Answer this question

Pushing the renderstate, to easily restore a default

  • KFowler

    Yes you can do this. Take a look at the StateBlock class. You can save your default states in such a block and then set it with only one call (Apply).

    BTW: If you are using a “PureDevice” you can not use the get methods to query the current renderstate values.



  • Pushing the renderstate, to easily restore a default