Code: Select all
video::ITexture* mirr = video->getTexture("mirrorbgr.tga");
.
.
.
// draw scene into render target
// set render target texture
video->setRenderTarget(rt, true, true, video::SColor(255,255,255,255));
// make cube invisible and set fixed camera as active camera
mirror->setVisible(false);
video->draw2DImage(mirr,
core::position2d<s32>(0,0),
core::rect<s32>(0,0,258,258), 0,
video::SColor(255,255,255,255), true);
scene->setActiveCamera(fixedCam);
// draw whole scene into render buffer
scene->drawAll();
// set back old render target
video->setRenderTarget(0);
// make the cube visible and set the user controlled camera as active one
mirror->setVisible(true);
scene->setActiveCamera(camera);
If you look at the cube, you will notice, that on the edges you can see a thin edge-line in a colour given by the setrendertarget line.
I used the CSamplescenenode example too and had the same thing.
I modified the engine in COpenGLDriver.cpp.
Under this function:
Code: Select all
//! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted.
void COpenGLDriver::draw2DImage(video::ITexture* texture, const core::position2d<s32>& pos,
const core::rect<s32>& sourceRect,
const core::rect<s32>* clipRect, SColor color,
bool useAlphaChannelOfTexture)
Code: Select all
if (targetPos.Y + sourceSize.Height > renderTargetSize.Height)
{
sourceSize.Height -= (targetPos.Y + sourceSize.Height) - renderTargetSize.Height;
if (sourceSize.Height <= 0)
return;
}
Code: Select all
if (targetPos.Y + sourceSize.Height > renderTargetSize.Height+2)
Just look at the pictures
BEFORE (with the thin edge)
http://www.kokany.atw.hu/irr/1.jpg
and
AFTER (with the modified source)
http://www.kokany.atw.hu/irr/2.jpg
I don't know why this works, it was the first time I look at the source and spent only 10 minutes with it... maybe Niko will explode of rage seeing such a lame solution, but it works, or at least something is wrong with the v1.1 source here (+SVN on the 06/aug/26). Maybe someone will be able to understand this...
Ok, I found a solution. Even the original Tutorial file works now well with a background on the rotating cube.
Still in COpenGLDriver.cpp:
Code: Select all
int diff=(targetPos.Y + sourceSize.Height)-renderTargetSize.Height;
if (targetPos.Y + sourceSize.Height > renderTargetSize.Height+diff)
{
sourceSize.Height -= (targetPos.Y + sourceSize.Height) - renderTargetSize.Height;
if (sourceSize.Height <= 0)
return;
}
Code: Select all
video->draw2DImage(mirr,
core::position2d<s32>(0,0),
core::rect<s32>(0,0,255,255),
0,
video::SColor(255,255,255,255), true);
Could, please, someone try this? If it works, I will add a patch.