I'm in C++ and I have many different shape to draw
Each of them come with different state :
Render States
Texture Stage States
Sampler States
Some are transparent, some use light, others use alpha test
They can be call from function that I can place in any order in my code
My problem is that I need to go back to the default state or undo
what the previous state setting changed...before setting only the state I need
I'm at a point where I will have to use 2 functions :
SetAlphaON() and SetAlphaOFF()
So I can immediatly remove any state change before I draw something else
Is there a better way to undo any state change
ID3DXEffectStateManager seems to do this for Fx files...
One thing I have realized is that state change in a loop is very costly on speed...
So I need to minimize change in state...
I wish the function ResetToDefaultState would exist...

State management nightmare
laiseng
Thank you very much for your answer
I will check if I set for PURE device or not, and now I know the redundant values are not much of a problem...
I should change all at once and not call drawing function and set state in a loop...
I found some advise on not using state block...and use effect instead...
http://www.gamedev.net/community/forums/topic.asp topic_id=392052
Try not to use StateBlocks to save & restore device state; you may be setting too much state that way. One way of getting around this problem is to use effects and create some known good states for your rendering techniques, and then switch between those.
http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=61263&SiteID=1
On a non-PURE device, they are filtered by D3D. Redundant calls (i.e. changes to the same value) get filtered. Non-redundant values are added to the command-buffer.
On almost all drivers, when they get a state change command, they simply remember it. When they get a DIP-style command, then they think about setting states and so on.
Izzy545
An excellent wrap up:
http://tomsdxfaq.blogspot.com/2002_07_01_tomsdxfaq_archive.html#78505386