Jump to content
  • Advertisement
Sign in to follow this  
ptchaos

Best way to use zIndex

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

Greetings,

 

I have a list of objects that have a property zIndex, which indicates the order the objects are processed (updated/draw).

 

Whats the best way to process them in the correct order? Sort the vector each time I push a new object? Use another kind of container?

 

Think about operative system windows. Usual they are showed in the order they are opened (with some exceptions ofc). But when you click on one in the back, it activates and passes to the front. Does it remove from the list and pushes again so its the last to be drawn?

 

Think in a top-down game. You have the ground tiles, then ground objects, then flying objects. Do you have separated lists for each layer?

 

It probably depends on the use, but whats the usual approach to this?

 

 

Thanks,

 

chaos

Share this post


Link to post
Share on other sites
Advertisement
I would say there is probably no usual way to do this. Depending on application, you may stick objects into a vector and sort on every insertion, stuff objects into an sorted associative container like a map, generate a new sorted list every time you render, ignore z order for objects and depend on the renderer to sort faces of the objects as part of the render and so on. A window manager has very different requirements for z order than a game with highly dynamic objects and view points.

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!