Skip to main content
gamedev.net
🔒 Locked

SetRenderState

Started by Jower Apr 20, 2004 at 10:55 AM 1 replies 550+ views
Original Post
Jower
Jower
Hey, I''m trying to do something like
LPDIRECT3DDEVICE9->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_EQUAL);
LPD3DXSPRITE->Draw(...);
LPDIRECT3DDEVICE9->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_NOTEQUAL);
LPD3DXSPRITE->Draw(...);
all with the same LPD3DXSPRITE and within the same Begin() End() and it dosen''t seem to work, it just uses the last one I set and draw with that. Isen''t there some way to change the renderstate during rendering ? Or do I have to do something like using multiple LPD3DXSPRITE''s ?
neneboricua19
neneboricua19
Yes, you can change the state during rendering. Since you''re using the same sprite at the same position, it makes sense that the last one is what is shown since it overwrites the first one.

If you''re trying to do alpha blending, then there are a few more states you need to set up. You need to set things like the source color, destination color, where to get the alpha value from, etc... It''s all in the SDK docs.

neneboricua
DrunkenHyena
DrunkenHyena
When you call Draw between Begin and End it does not actually draw anything, it simply batches the sprite to be drawn later. And when it draws later it uses the current settings. Try something like:


LPD3DXSPRITE->Begin()
LPDIRECT3DDEVICE9->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_EQUAL);
//Draw all sprites that use D3DCMP_EQUAL, many is better than few
LPD3DXSPRITE->Flush();
LPDIRECT3DDEVICE9->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_NOTEQUAL);
//Draw all sprites using D3DCMP_NOTEQUAL
LPD3DXSPRITE->End();


Flush forces the sprites to be rendered and End does an implicit Flush.


Stay Casual,

Ken
Drunken Hyena

[edited by - DrunkenHyena on April 20, 2004 1:42:42 PM]
Stay Casual,KenDrunken Hyena</FON

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.