Hi community,
I’ve came across an annoying phenomenon that I failed to explain.
GUI widgets are seemingly drawn at random order. Each run produces different result.
I’ve created this simplified code that produces the phenomenon.
Sometimes it yields:
, but sometimes red is at top, sometimes green is, sometimes green is not even visible.
from direct.showbase.ShowBase import ShowBase
from direct.gui.DirectGui import *
class TGame(ShowBase):
def __init__(self):
ShowBase.__init__(self)
T1 = DirectFrame(frameColor=(1, 0, 0, 1), parent=render2d, frameSize=(-0.25,0.25,-0.25,0.25), pos=(0.5,0,0.05), sortOrder = 61)
T2 = DirectFrame(frameColor=(0, 1, 0, 1), parent=render2d, frameSize=(-0.25,0.25,-0.25,0.25), pos=(0.55,0,0.05), sortOrder = 72)
T3 = DirectFrame(frameColor=(0, 0, 1, 1), parent=render2d, frameSize=(-0.25,0.25,-0.25,0.25), pos=(0.6,0,0.05), sortOrder = 83)
self.updateTask = taskMgr.add(self.update, "update")
def update(self, task):
pass
game = TGame()
game.run()
I’ve tried adding:
base.render2d.setDepthTest(False)
base.render2d.setDepthWrite(False)
or with True, but it doesn’t seem to affect the result.
I’ve tried to parent them to each other, but also doesn’t seem to work.
What am I doing wrong?

