From ac751a27153682f6c7e302106d7a0d14d89c79d0 Mon Sep 17 00:00:00 2001 From: David Rose Date: Wed, 18 Jun 2003 22:14:31 +0000 Subject: [PATCH] force depth buffer clear for render2d --- direct/src/showbase/ShowBase.py | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/direct/src/showbase/ShowBase.py b/direct/src/showbase/ShowBase.py index 76460ab165..364400383f 100644 --- a/direct/src/showbase/ShowBase.py +++ b/direct/src/showbase/ShowBase.py @@ -419,20 +419,25 @@ class ShowBase(DirectObject.DirectObject): # Set up some overrides to turn off certain properties which # we probably won't need for 2-d objects. - # It's particularly important to turn off the depth test, - # since we'll be keeping the same depth buffer already filled - # by the previously-drawn 3-d scene--we don't want to pay for - # a clear operation, but we also don't want to collide with - # that depth buffer. + # It's probably important to turn off the depth test, since + # many 2-d objects will be drawn over each other without + # regard to depth position. + + # We used to avoid clearing the depth buffer before drawing + # render2d, but nowadays we clear it anyway, since we + # occasionally want to put 3-d geometry under render2d, and + # it's simplest (and seems to be easier on graphics drivers) + # if the 2-d scene has been cleared first. + dt = DepthTestAttrib.make(DepthTestAttrib.MNone) dw = DepthWriteAttrib.make(DepthWriteAttrib.MOff) #lt = LightTransition.allOff() - self.render2d.node().setAttrib(dt, 1) - self.render2d.node().setAttrib(dw, 1) + self.render2d.node().setAttrib(dt) + self.render2d.node().setAttrib(dw) #self.render2d.node().setAttrib(lt, 1) self.render2d.setMaterialOff(1) - self.render2d.setTwoSided(1, 1) + self.render2d.setTwoSided(1) # The normal 2-d layer has an aspect ratio that matches the # window, but its coordinate system is square. This means @@ -467,6 +472,10 @@ class ShowBase(DirectObject.DirectObject): # And make a display region to cover the whole layer. dr = layer.makeDisplayRegion() + # Enable clearing of the depth buffer on this new display + # region (see the comment above). + dr.setClearDepthActive(1) + # Now make a new Camera node. cam2dNode = Camera('cam2d') lens = OrthographicLens()