In earlier versions of Microsoft® Direct3D® Retained Mode, Retained Mode could not assume render and light states would remain the same from one call to the next. This led to many redundant state changes in a typical application because Retained Mode set the state to a value equal to its current value. The IDirect3DRMDevice3 interface introduces several methods that can be used to eliminate these redundant changes for a modest performance boost: GetStateChangeOptions, LightStateChange, RenderStateChange, and SetStateChangeOptions. To use these methods, follow these steps:
Dev3->SetStateChangeOptions(D3DRMSTATECHANGE_RENDER, 0, D3DRMSTATECHANGE_NONVOLATILE); Dev3->SetStateChangeOptions(D3DRMSTATECHANGE_LIGHT, 0, D3DRMSTATECHANGE_NONVOLATILE);
For example, the following code shows you how to change the texture handle and update the state cache.
Dev3->RenderStateChange(D3DRENDERSTATE_TEXTUREHANDLE, hTex, 0UL);
If you have changed the state and just want Retained Mode to update its state cache, use the UPDATEONLY flag, as shown in the following:
Dev3->RenderStateChange(D3DRENDERSTATE_TEXTUREHANDLE, hTex, D3DRMSTATECHANGE_UPDATEONLY);
If you are going to be changing a state value many times and do not want Retained Mode to keep track of current values, you can turn off redundant state checking for the specified state with the following code. However, this is not recommended because you will lose performance benefits.
Dev3->SetStateChangeOptions(D3DRMSTATECHANGE_RENDER, D3DRENDERSTATE_TEXTUREHANDLE, D3DRMSTATECHANGE_VOLATILE);
Top of Page
© 1999 Microsoft and/or its suppliers. All rights reserved. Terms of Use.