Sign in to follow this  

Stateblocks & ID3DXSprite

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this