Jump to content

  • Log In with Google      Sign In   
  • Create Account


Best way to use zIndex


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 ptchaos   Members   -  Reputation: 135

Like
0Likes
Like

Posted 24 February 2013 - 09:53 AM

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



Sponsor:

#2 SiCrane   Moderators   -  Reputation: 9386

Like
3Likes
Like

Posted 24 February 2013 - 10:17 AM

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.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS