Onscreenimage Priority

How do you make one onscreenimage (parented to render2d) render in front of another in Panda3d?
I have tried changing the order of when they are defined, and adjusting the Y value of its position. So far, nothing has made a difference.

Have you tried assigning them to a bin – either “fixed” or a new bin of your own making of type BT_fixed – and assigning sort orders appropriately? Something like this:

# Presume that your images are onScreenImage1 and 
# onScreenImage2, and are defined elsewhere.
cullManager = CullBinManager.getGlobalPtr()
# According to the manual page linked-to below,
# the highest-order standard bin has order 50, 
# so I'm assigning our new bin a sort order of 60.
cullManager.addBin("onscreenImageBin", cullManager.BTFixed, 60)
onScreenImage1.setBin(onscreenImageBin, 1)
onScreenImage2.setBin(onscreenImageBin, 2)

This manual page might be useful.

It works perfectly. Thanks!

Can this be done for onscreen text as well?

Sure, why wouldn’t it? This method works irrespective of the specific contents of the geometry that you want to render. Usually text gets compiled into an image anyway, so there’s not even a difference there.

cullManager = CullBinManager.getGlobalPtr()
cullManager.addBin("onscreenImageBin", cullManager.BTFixed, 60)
onScreenText1.setBin(onscreenImageBin, 1)
onScreenText2.setBin(onscreenImageBin, 2)


Are you asking whether that is correct (I would imagine so, depending of course on which onScreenText you want in front of the other), or are you indicating that it doesn’t work?

onscreenImageBin in the setBin call should be in quotation marks.

Ah, I missed that – I second rdb’s answer, in that case.