Jump to content
  • Advertisement
Sign in to follow this  
marshdabeachy

Sprite Z-Order

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

Beginner question... how do I go about setting the z-order for sprites being positioned with a D3DVECTOR2 position? I know a D3DVECTOR3's z parameter will be used as depth, but I'm doing 2D matrix transformations and can't use the third parameter. Or would prefer not to use it, anyway, since it'd muck up my stuff.

Share this post


Link to post
Share on other sites
Advertisement
turn off z-buffer, draw your sprites in whatever order you need, and turno on z-buffer. It is that simple[smile]

Share this post


Link to post
Share on other sites
Okay, well then I'm still stuck. I'm trying to sort all the sprites by their distance to the camera, so I can draw them in the correct order. Of course it's being a pain and not working.

In my render function, I stuffed the sprite info into a vector:

std::sort(spriteSort.begin(), spriteSort.end(), compare);


The compare function:

bool compare(spriteInfo* a, spriteInfo* b) {
return a->distToCamera < b->distToCamera;
}


I ran debug on it, the compare function is being called. There are no errors or warnings. Everything is supposed to be perfect. But it's not sorting. I run through the vector afterward, and it's like I didn't even call sort. It does nothing to it.

Uh... what?

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!