Sign in to follow this  
PumpkinPieman

Coming back to the Direct 3D side of DX.

Recommended Posts

PumpkinPieman    382
It's been a while since I've been working with the D3D side of DX because that was the first thing I played with when making my engine. Now, I'm planning to add and improve certain features of my code in sprite rendering and animation. Since the majority of my game ideas involve 2D concepts I'm sticking to a sprite based engine for now, but what is really getting me is ID3DXSPRITE. It's not that it's bad; it's that I feel like I don't have enough flexibility with it. It seems on the whole way to basic for what I want to do, so keeping that thought I've been thinking about writing my own sprite interface. Now what's getting me is what got me when I started with direct x, sorting and optimization. I know now that I should just make a rough draft and improve it as I find out more, but I'm kind of hoping that I can get some answers before I start. It's going to work much like ID3DXSPRITE, you lock the sprite interface, draw the sprites then unlock. But my question is, how are these sorted? How are they displayed based on the sort?

Share this post


Link to post
Share on other sites
Mezz    571
I'm not quite sure I follow your questions.

The sprites are sorted based on the flags you specify when you call Begin(), by texture, by depth etc. if you mean what sorting algorithm would Microsoft have implemented to sort them, well, I don't know. It's quite possible that they maintain a sorted list because as you add sprites to the batch (i.e. call Draw()) it can know where to insert them into the list.

I do not understand your question about how they are displayed based on the sort - could you rephrase it / be more specific?

-Mezz

Share this post


Link to post
Share on other sites
PumpkinPieman    382
I think you actually answered my question, I forgot about those flags. What about render states, if I change the renderstate mid way through the calls will it just disregard them?

Share this post


Link to post
Share on other sites
Mezz    571
If you mean changing render states between Begin() and End() calls, I think the state change will take effect, but remember that it's not until End() sprites will actually be drawn, so if you change state a bunch of times only the last one set will probably have an effect (not really sure though, not tried it).

-Mezz

Share this post


Link to post
Share on other sites
DrunkenHyena    805
Quote:
Original post by Mezz
If you mean changing render states between Begin() and End() calls, I think the state change will take effect, but remember that it's not until End() sprites will actually be drawn, so if you change state a bunch of times only the last one set will probably have an effect (not really sure though, not tried it).

-Mezz


Small correction, you can also call the Flush method to draw the pending sprites. This way you can change a state, draw some sprites, flush, then change states again and repeat.

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