Ah, yes. I used the IGUIImage with setUseAlphaChannel(true) and that worked perfectly.
I have a problem with the render to texture part, though.
I followed tutorial 13 (Render to texture) and created a texture, a fixed camera and an FPS camera. In the main loop I begin the scene, set the target to the texture, select the fixed camera, draw some stuff and call drawAll(), then repeat it for the frame buffer and the FPS camera, calling drawAll() again.
When I do this, however, the screen gets cleared as I expect it to, but thenn all the things in the second part won't get displayed. Additionally, the mouse now moves the camera in the overlaid texture. If I comment out the first drawAll() -- the one in the render to texture part -- then, obvously, there's nothing in the texture (except the fill color) but the controls are okay.
Am I missing some vital thing?
Here's the code:
Code: Select all
void GameEngine::OnSceneLoop(f32 elapsedTime) {
beginScene();
video::IVideoDriver *driver = getDriver();
scene::ISceneManager *smgr = getSceneManager();
// Render to texture
driver->setRenderTarget(renderTarget, true, true, video::SColor(0,0,0,255));
smgr->setActiveCamera(renderTargetCamera);
driver->setMaterial(getUnlitMaterial());
driver->setTransform(video::ETS_WORLD, core::matrix4());
driver->draw3DBox(core::aabbox3d<f32>(-0.5, -0.5, -0.5, 0.5, 0.5, 0.5));
// If I comment this out, I get an empty texture.
// If I leave it in, I get no scene and the FPS controls are messed up.
smgr->drawAll();
// Render to screen
driver->setRenderTarget(video::ERT_FRAME_BUFFER, true, true, video::SColor(255,128,32,0));
smgr->setActiveCamera(mainCamera);
// Draw a cage around the main camera (for orientation)
drawCameraOrientationCage(mainCamera);
smgr->drawAll();
// Display image
gui::IGUIImage *image = getGUIEnvironment()->addImage(core::rect<s32>(5, 5, 55, 55));
image->setUseAlphaChannel(true);
image->setImage(renderTarget);
renderGui();
endScene();
}
Edit:
I fear that there's something f***ed up. If I remove everything except beginScene(), drawAll() and endScene() and add nothing but an FPS camera and a cube node, then all I see is a short flickering cube, followed by fill color for the rest of the time. I don't get it.