Cannot disable depth/color clear for manually created buffer

I have this setup:

lens = base.cam.node().getLens()

self.mainMask = 1
self.obstructionMask = 2

self.mainBuf = self.makeFBO("main buffer", -3, extra_flags = GraphicsPipe.BFRequireParasite)
self.maincam = base.makeCamera(self.mainBuf, lens=lens)
self.maincam.reparentTo(base.cam)
self.mainTex = Texture()
self.mainBuf.addRenderTexture(self.mainTex, GraphicsOutput.RTMBindOrCopy, GraphicsOutput.RTPColor)

self.backBuf = self.makeFBO("back buffer", -2, extra_flags = GraphicsPipe.BFRequireParasite)
self.backcam = base.makeCamera(self.backBuf, lens=lens, mask=self.obstructionMask)
self.backcam.reparentTo(base.cam)
self.backTex = Texture()
self.backBuf.addRenderTexture(self.backTex, GraphicsOutput.RTMBindOrCopy, GraphicsOutput.RTPColor)

self.frontBuf = self.makeFBO("front buffer", -1, extra_flags = GraphicsPipe.BFRequireParasite)
self.frontcam = base.makeCamera(self.frontBuf, lens=lens, mask=self.obstructionMask)
self.frontcam.reparentTo(base.cam)
self.frontTex = Texture()
self.frontBuf.addRenderTexture(self.frontTex, GraphicsOutput.RTMBindOrCopy, GraphicsOutput.RTPColor)

#self.mainBuf.shareDepthBuffer(self.backBuf)
#self.mainBuf.shareDepthBuffer(self.frontBuf)

# disable default camera
base.cam.node().setActive(False)
base.cam.node().getDisplayRegion(0).setActive(False)

self.mainBuf.setSort(1)
self.backBuf.setSort(2)
self.frontBuf.setSort(3)
base.win.setSort(4)

self.maincam.node().getDisplayRegion(0).setSort(1)
self.backcam.node().getDisplayRegion(0).setSort(2)
self.frontcam.node().getDisplayRegion(0).setSort(3)

# By default, panda usually clears the screen before every
# camera and before every window.  Tell it not to do that.
# Then, tell it specifically when to clear and what to clear.
self.maincam.node().getDisplayRegion(0).disableClears()
self.backcam.node().getDisplayRegion(0).disableClears()
self.frontcam.node().getDisplayRegion(0).disableClears()
base.cam.node().getDisplayRegion(0).disableClears()
base.cam2d.node().getDisplayRegion(0).disableClears()
base.win.disableClears()

base.win.setClearDepthActive(False)
base.win.setClearColorActive(False)
base.cam.node().getDisplayRegion(0).setClearColorActive(False)
base.cam2d.node().getDisplayRegion(0).setClearColorActive(False)
self.backcam.node().getDisplayRegion(0).setClearColorActive(False)
self.backcam.node().getDisplayRegion(0).setClearColor(Vec4(0,0,0,1))
self.backcam.node().getDisplayRegion(0).setClearDepthActive(False)
self.frontcam.node().getDisplayRegion(0).setClearColorActive(False)
self.frontcam.node().getDisplayRegion(0).setClearColor(Vec4(0,0,0,0))
self.frontcam.node().getDisplayRegion(0).setClearDepthActive(False)

# Clear any render attribs on the root node. This is necessary
# because by default, panda assigns some attribs to the root
# node.  These default attribs will override the
# carefully-configured render attribs that we just attached
# to the cameras.  The simplest solution is to just clear
# them all out.
render.setState(RenderState.makeEmpty())

tempnode = NodePath(PandaNode("temp node"))
#tempnode.setTwoSided(True, 100)
tempnode.setAttrib(CullFaceAttrib.make(CullFaceAttrib.MCullCounterClockwise), 100)
self.backcam.node().setInitialState(tempnode.getState())

tempnode = NodePath(PandaNode("temp node"))
#tempnode.setTwoSided(True, 100)
tempnode.setAttrib(CullFaceAttrib.make(CullFaceAttrib.MCullClockwise), 100)
self.frontcam.node().setInitialState(tempnode.getState())

base.setBackgroundColor(Vec4(1,0,0,0))
		
self.accept("v", base.bufferViewer.toggleEnable)
self.accept("V", base.bufferViewer.toggleEnable)
base.bufferViewer.setPosition("llcorner")

def makeFBO(self, name, sort, rgb=1, alpha=1, depth=1, aux=0, extra_flags = 0):
	# This routine creates an offscreen buffer.  All the complicated
	# parameters are basically demanding capabilities from the offscreen
	# buffer - we demand that it be able to render to texture on every
	# bitplane, that it can support aux bitplanes, that it track
	# the size of the host window, that it can render to texture
	# cumulatively, and so forth.
	winprops = WindowProperties()
	props = FrameBufferProperties()
	props.setRgbColor(rgb)
	props.setAlphaBits(alpha)
	props.setDepthBits(depth)
	props.setAuxRgba(aux)
	return base.graphicsEngine.makeOutput(
		base.pipe, name, sort,
		props, winprops,
		#GraphicsPipe.BFSizeTrackHost | GraphicsPipe.BFCanBindEvery | 
		#GraphicsPipe.BFRttCumulative | GraphicsPipe.BFRefuseWindow |
		GraphicsPipe.BFSizeTrackHost | GraphicsPipe.BFRefuseWindow | 
		#GraphicsPipe.BFResizeable | 
		extra_flags,
		base.win.getGsg(), base.win)

When I run the program, buffer viewer shows that all buffers are cleared from any previous renderings. If I disable clear-color, buffers have grey background, otherwise they have the color which I specify in setClearColor.

Since your buffers are parasite buffers, they are actually rendered into the main window, and they are inheriting the clear color from that window.

David

But why clear is performed at all? I thought I’ve turned clear of every possible buffer off… It seems that disable/deactivate commands are just ignored u_u

Ah, I see. But you never disable the clear on the ParasiteBuffers as you create them. The default behavior when you create a new buffer is to enable clear, so each of your ParasiteBuffers still has clear enabled.

David

Thanks, now I got it) Seems like I really overlooked this bit of documentation. My deepest apologies ^^