I have a problem with rendering the same scene using 2 cameras and 2 render targets (one is texture, one is frame buffer).
My code is as follows:
Code: Select all
void Device::draw()
{
TRACK;
irr::IrrlichtDevice &irrDevice = getIrrlichtDevice();
irrDevice.getVideoDriver()->beginScene(true, true, irr::video::SColor(255, 0, 0, 255));
irrDevice.getSceneManager()->setActiveCamera(m_irrSunCamera);
irrDevice.getVideoDriver()->setRenderTarget(m_sunDepth, true, true);
irrDevice.getSceneManager()->drawAll();
irrDevice.getVideoDriver()->setRenderTarget(irr::video::ERT_FRAME_BUFFER, true, true);
irrDevice.getSceneManager()->setActiveCamera(m_irrCamera);
irrDevice.getSceneManager()->drawAll();
irrDevice.getVideoDriver()->draw2DImage(m_sunDepth, irr::core::rect <irr::s32> (0, 0, 300, 300), irr::core::rect <irr::s32> (0, 0, 1024, 768));
getGUIManager().draw();
irrDevice.getVideoDriver()->endScene();
}Code: Select all
irrDevice.getSceneManager()->setActiveCamera(m_irrCamera);If I comment out setting second camera as active. First RTT has correct content (drawn with first camera).
Here are some screenshots:
If I comment setting second camera as active, I get this result:
https://dl.dropboxusercontent.com/u/12301540/misc/1.jpg
Top left RTT is drawn correctly, using firrst camera. But main scene is also rendered using the first camera (because I commented out setting second camera as active).
Now if I uncomment setting second camera as active, I get this:
https://dl.dropboxusercontent.com/u/12301540/misc/2.jpg
Top left RTT got overwritten, despite being drawn BEFORE setting second camera as active.
I've tried changing setActiveCamera/setRenderTarget order, nothing helps.
Is it a bug or a feature?