Currently I have been playing with rendering scenes in textures but I think I might have run smack center into a bug. Hopefully it's in my code so then it's a much easier fix
When I create a EDT_BURNINGSVIDEO device the scene that should be rendered in the actual texture is transparent (material type is EMT_TRANSPARENT_ALPHA_CHANNEL). But when I use the EDT_DIRECT3D9 device, everything works perfectly (scene is not transparent).
This is done with the Irrlicht 1.3 engine.
The best illustration of this is some hacked up code I have attached form Example 13 RenderToTexture. Simply replace the code in main.cpp with the code below to illustrate the problem.
Code: Select all
/*
This tutorial shows how to render to a texture using Irrlicht. Render to texture is a feature with which
it is possible to create nice special effects. In addition, this tutorial shows how to enable specular
highlights.
In the beginning, everything as usual. Include the needed headers, ask the user for the rendering
driver, create the Irrlicht Device:
*/
#include <irrlicht.h>
#include <iostream>
using namespace irr;
#pragma comment(lib, "Irrlicht.lib")
int main()
{
// create device and exit if creation failed
IrrlichtDevice *device =
createDevice(video::EDT_DIRECT3D9 EDT_BURNINGSVIDEO, core::dimension2d<s32>(640, 480), 32, false, false);
if (device == 0)
return 1; // could not create selected driver.
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgrRender = device->getSceneManager();
scene::ISceneManager* smgrTexture = smgrRender->createNewSceneManager();
// load and display animated fairy mesh
scene::IAnimatedMeshSceneNode* fairy = smgrTexture->addAnimatedMeshSceneNode(smgrTexture->getMesh("../../media/faerie.md2"));
if (fairy)
{
fairy->setMaterialTexture(0, driver->getTexture("../../media/faerie2.bmp")); // set diffuse texture
fairy->setMaterialFlag(video::EMF_LIGHTING, false); // disable dynamic lighting
fairy->setPosition(core::vector3df(-10,0,-100));
}
// add fps camera
scene::ICameraSceneNode* fpsCamera = smgrRender->addCameraSceneNodeFPS();
fpsCamera->setPosition(core::vector3df(-50,50,-150));
// disable mouse cursor
device->getCursorControl()->setVisible(false);
// Add skybox
smgrRender->addSkyBoxSceneNode(
driver->getTexture("../../media/irrlicht2_up.jpg"),
driver->getTexture("../../media/irrlicht2_dn.jpg"),
driver->getTexture("../../media/irrlicht2_lf.jpg"),
driver->getTexture("../../media/irrlicht2_rt.jpg"),
driver->getTexture("../../media/irrlicht2_ft.jpg"),
driver->getTexture("../../media/irrlicht2_bk.jpg"));
// create test cube
scene::ISceneNode* testCube = smgrRender->addCubeSceneNode(60);
testCube->setPosition(core::vector3df(-100,0,-100));
testCube->setMaterialFlag(video::EMF_LIGHTING, false); // disable dynamic lighting
// set window caption
device->setWindowCaption(L"Irrlicht Engine - Render to Texture and Specular Highlights example");
// create render target
video::ITexture* rt = 0;
scene::ICameraSceneNode* fixedCam = 0;
if (driver->queryFeature(video::EVDF_RENDER_TO_TARGET))
{
rt = driver->createRenderTargetTexture(core::dimension2d<s32>(256,256));
// add fixed camera
fixedCam = smgrTexture->addCameraSceneNode(0, core::vector3df(10,10,-80), core::vector3df(-10,10,-100));
smgrTexture->setActiveCamera(fixedCam);
testCube->setMaterialTexture(0, rt); // set material of cube to render target
testCube->setMaterialType(irr::video::EMT_TRANSPARENT_ALPHA_CHANNEL);
}
while(device->run())
{
if (device->isWindowActive())
{
driver->beginScene(true, true, 0);
if (rt)
{
// draw scene into render target
// set render target texture
driver->setRenderTarget(rt, true, true, video::SColor(255,0,0,255));
// draw whole scene into render buffer
smgrTexture->drawAll();
// set back old render target
driver->setRenderTarget(0);
}
// draw scene normally
smgrRender->drawAll();
driver->endScene();
}
}
if (rt)
rt->drop(); // drop render target because we created if with a create() method
if (NULL != device)
{
device->drop(); // drop device
}
if (NULL != smgrTexture)
{
smgrTexture->drop();
}
return 0;
}
Obviously if you want to see everything working as designed, change the device to EDT_DIRECT3D9.