Skip to main content
gamedev.net
🔒 Locked

SetRenderState

Started by Jower 2 replies 250+ views
Original Post
Jower
Jower
How does LPDIRECT3DDEVICE9->SetRenderState work anyway ? If I want to render different sprites with different renderstates how do I do that ? Do I have to put them in different BeginScene/EndScene or Begin/End commands or something ? If I try to render different sprites and change renderstate between them it just uses the last renderstate
circlesoft
circlesoft
Since ID3DXSPRITE batches all sprites that were rendered between the Begin() and End() commands, it''s going to use the last renderstate set. You have to do multiple Begin() End() sets, and change the renderstates for each set.


Dustin Franklin
Mircrosoft DirectX MVP
Namethatnobodyelsetook
Namethatnobodyelsetook
Your question is wrong. You should be asking how the sprite system works.

SetRenderState changes the render state, right when you call it. Any draw commands that follow use this new state.

The sprite system attempts to gain performance by batching. You do a begin which prepares to batch. You tell it to draw, and it just remembers what you said. You tell it to draw more, and again it just remembers. When you say End(), it takes all that stored information and does a DrawIndexedPrimitive() with it.

Because internally it''s queueing your requests, your render state changes aren''t working as expected. If there''s a flush call, you can try that, or End() and Begin() again. As always you want to limit the number of draw calls, so don''t try to use this change states between each sprite.
Jower
Jower
Oooh
Seems to be working.
Though now I have to use Begin/End 4 times each instead of 1
hehe
Well, supposed I can live with that
Tnx for the help anyway

Topic Locked

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

Sign in to reply to this topic.