How to use and makes sense of info from GetRenderState?

Started by
3 comments, last by johnnyBravo 20 years, 2 months ago
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,
Advertisement
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.
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 ... */
}

Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse


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
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.
[sub]My spoon is too big.[/sub]

This topic is closed to new replies.

Advertisement