• ### Popular Now

• 10
• 13
• 18
• 27
• 9

#### Archived

This topic is now archived and is closed to further replies.

# How to use and makes sense of info from GetRenderState?

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

## Recommended Posts

Hi, in my program i want to use GetRenderState to check what values of SetRenderState have been applied. eg lp_Device->SetRenderState( D3DRS_FILLMODE, D3DFILL_WIREFRAME ); lp_Device->SetRenderState( D3DRS_AMBIENT, D3DCOLOR_XRGB(255,255,255)); (lp_Device is the d3d device) If I call both these at the same time so the ambient lighting of every 3D object is fully bright, and showing the wireframes of these objects. How would I be able to tell that both the wireframe fillmode has been set , and that ambient lighting is set. Thanks,

##### Share on other sites
Either remember yourself, or use device->GetRenderState()

The latter won''t work on pure devices. If your device isn''t pure, then directx remembers which states are set and using SetRenderState for a state that is already active does nothing. So, just go ahead and do lp_Device->SetRenderState( D3DRS_FILLMODE, D3DFILL_WIREFRAME ); when you need it without worrying whether you''re setting it when it is already active.

##### Share on other sites
What''s the problem here?

DWORD fillMode, ambientColor;lpDevice->GetRenderState(D3DRS_FILLMODE, &fillMode);lpDevice->GetRenderState(D3DRS_AMBIENT, &ambientColor);if((D3DFILL_WIREFRAME==fillMode)&&(D3DCOLOR_XRGB(255,255,255)==ambientColor)){ /* ... do stuff ... */}

##### Share on other sites

Ah thankyou superpig.
Fidelio, the reason im doing it is i have classes that i want to put functions in to set alpha blend etc for 3d objects eg meshes.

but i dont want to call things unnecessarily as i heard this can slow things down

eg if the render state is already set, dont re-set it

##### Share on other sites
You''ll almost certainly have worse performance calling get and then set than if you just set redundantly. Most renderstates set fairly quickly, not superquick but not slow enough that anything but the most basic of state management could really be beneficial.

Plus, like Fidelio66 said, pure devices won''t let you query current state. Ultimately you should prefer a pure device, as most D3D runtime calls just go straight to the driver. So, avoid most Get calls if you can.

I like pie.