Jump to content
  • Advertisement
Sign in to follow this  
stringa

D3DXSprites - Drawn Out of Order

This topic is 3916 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

When I scale some sprites (specifically the background) and draw it first before everything else ( which is NOT scaled ), it draws the background on top of everything. It's like it doesn't finish drawing the background and finished other draw calls before the first one is done. is there any way to fix this?

Share this post


Link to post
Share on other sites
Advertisement
By default, D3DXSprite should always draw your sprites in the order that you called Draw(). If you have sorting on, then perhaps D3DXSprite is sorting your background to draw last (not that I would have any idea how that would work).

Share this post


Link to post
Share on other sites
No sorting... I presort my data in a set and then just iterate through it calling draw. Everything is correct in my set and also...


if i scale everything else, it draws correctly

I've never seen this before

Share this post


Link to post
Share on other sites
I have never used the d3dxsprite system, but possibly the scale factor (is it a vector or scalar?) is scaling the sprite's z/depth value. If the background's z was scaled down, it could fill the depth buffer and then block the other sprites from being rendered over it. And when you scale the others, their z value is smaller than the background's again. I don't really know how d3dxsprites work, but just a guess.

Share this post


Link to post
Share on other sites
I always set the z-value to 1 when I send it to Draw...I actually copy over all the position data into a new vector and they all have a zvalue of 1

Share this post


Link to post
Share on other sites
That probably means that the scale factor you set indeed does scale the z value of the sprite. When you set the z value to zero, scaling won't have any effect, because of zero's multiplication identity. Then the depth test won't matter and sprites will be rendered back to front in the order you draw them. This is likely the case, but I'm not positive.

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!