I'm trying to render to texture and then display that texture using draw2DImage. However, I'm having some odd problems that look like drawing order problems when I render to a texture--and only when I render to a texture.
Here's an example output image:
That's what happens when I do:
Code: Select all
// _renderTarget is set up using CreateRenderTargetTexture earlier.
_device.VideoDriver.SetRenderTarget(_renderTarget, true, true, Color.Black);
_device.SceneManager.DrawAll();
_device.VideoDriver.SetRenderTarget(null, true, true, Color.Black);
// A little bit later...
Rect srcDest = new Rect(0, 0, _device.VideoDriver.ScreenSize.Width, _device.VideoDriver.ScreenSize.Height);
_device.VideoDriver.Draw2DImage(_renderTarget, srcDest, srcDest, Color.White, false);
I'm guessing that it has something to do with the way z-buffers for the render target are set up vs. the actual framebuffer, but I really have no idea (or no idea where to start looking). I've even followed the render-to-texture tutorial as it says.
Anyone know what's going on? Any help would be superbly appreciated.