Advertisement Jump to content
Sign in to follow this  

Stateblocks & ID3DXSprite

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I'm sorry to post about two completely different things in one post but since the questions are very short. First of all, is there any thumb rule of when it's faster to use a stateblock than to change just a couple of states. Say that I want to change alpha from disabled to enabled, turn off z testing and disable lighting (3 states), then draw something and then change all three of them back. Would this be faster with: SaveCurrentBlock() LoadSpecialBlock() Render() ReloadOldBlock() and does it matter how many states I change in the block? The second question is regarding ID3DXSprite, can I use a pixel shader on ID3DXSprite objects? I can't get it to work and just wondering why.

Share this post

Link to post
Share on other sites
I'm not quite sure on the exact efficiency of using state blocks, but I do know that it would be beneficial to capture all of your state blocks at initialization, then simply apply them. So your render layout would change to:


You can always experiment and see which way is faster. Since you are only using 3 states, it may very well be faster. However, since D3D buffers all the states, it may not be (I am leaning towards this - since you only changed 3 states, only 3 changes will have to be made - not the entire block).


I'm pretty sure you can't use custom shaders with Sprite. This is because it sets up many FFP states (check the ID3DXSprite::Begin() page). However, you could always set up your own textured-quad system, which would allow you to use any shader you like.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!