GUI objects seemingly z-ordered at random
GUI objects seemingly z-ordered at random
I am creating simple GUI objects for a simple HUD, but I find that sometimes objects order themselves out of order of creation instead of in the order I created them in, with some appearing on top of ones I created after them. This seems to just happen whenever it wants. Is there a concrete fix to this? I'm on Irrlicht 1.8.5.
Re: GUI objects seemingly z-ordered at random
Main order is parents drawn before children (so children are on top). And children should be drawn in the order in which they are added (so last one added ends up on top). There are functions like bringToFront/sendToBack to change it, but unless you call those the order of creating is the drawing order. If that is not the case then there is something suspicous going on. I mean you can look at "virtual void draw()" function in IGUIElement.h - it's pretty trivial - just looping over the children.
edit: Maybe you draw custom ui elements? Those need to have IGUIElement::draw(); as last line for this to work
edit: Maybe you draw custom ui elements? Those need to have IGUIElement::draw(); as last line for this to work
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: GUI objects seemingly z-ordered at random
Hm. I'm just using the basic Irrlicht elements, I have a button created after I create an Image and sometimes the button appears behind the Image and vice versa.
Re: GUI objects seemingly z-ordered at random
Please show an example then. I'm pretty certain this is a bug in your code. All Irrlicht does is go over the list in a simple loop. And that list isn't re-ordered anywhere. Edit: Maybe you do set a custom 2d material? In that case you have be careful not to change the ZBuffer, ZWriteEnable flags.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm