[SOLVED] Render to texture: No depth checking

I’m trying to render a 3d scene to a texture. For the most part, this has gone as expected; make a render texture, render a Scene to it, blat it into a bitmap and render that bad boy into my s2d.

Except there’s no depth data on the 3d rendering, so the result is pretty wonky. Polygons just decide via seniority who gets to be on top, and that’s no fair!

After digging through the source, I realized my render texture needed a depth buffer (default is null, which disables depth info!), however, adding one simply results in a blank texture. It’s pretty unclear why this might be, so I’m hoping someone else has an idea what might be going on.

Relevant snippits:

Initialization

		texSceneRT = new Texture( k_ERTSizeW, k_ERTSizeH, [Target] );
		depthSceneRT = new DepthBuffer( k_ERTSizeW, k_ERTSizeH );
		texSceneRT.depthBuffer = depthSceneRT;

		// ...

		var bmp = new Bitmap( h2d.Tile.fromTexture( texSceneRT ) );
		s2d.addChild(bmp);

And now when we go to render…

		// Prep
		texSceneRT.clear( 0x0 );

		// Render 3d scene
		app.engine.pushTarget( texSceneRT );
		s3d.render(e);
		app.engine.popTarget();

		// Render 2d scene		
		s2d.render(e);  

Where am I going wrong here? I see mention of CachedBitmap in a few older discussions, but that has long since been purged from the code base.

Replying for posterity and future google searches:

You need to call engine.clear( 0x0, 1 ) after pushTarget to clear the depth buffer.