Strange problem for RTT...

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
lab_zj
Posts: 26
Joined: Wed May 21, 2008 3:25 am

Strange problem for RTT...

Post by lab_zj »

I have created a Render To Texture used for render a fixed camera's view into it. In render loop, every time I call makeColorKeyTexture() to make background color of RTT to transparent,then call draw2DImage() to paste RTT onto screen. But I have a strange problem: if I call makeColorKeyTexture() in render loop for RTT, then program runs a while will exit automatically. I have traced and found that the memory usage for program from begin render's 38MB will increase quickly and exceed 2.4GB just in several minutes, BUT if I comment out makeColorKeyTexture() call, then everything will be ok.

the using code as follows:
video::ITexture *m_pRTT = m_pDriver->addRenderTargetTexture(core::dimension2du(512,512),"RTT1",video::ECF_A8R8G8B8); //create RTT
... ...

// main render loop
while(m_pDevice->run())
{
m_pDriver->setRenderTarget(m_pRTT, true, true, video::SColor(255,0,0,255)); // set render target
... ... //switch camera and do renderring
m_pDriver->makeColorKeyTexture(m_pRTT,video::SColor(255,0,0,255)); // make blue background to full transparent
m_pDriver->draw2DImage(m_pRTT,core::vector2di(1,1),core::recti(0,0,512,512),0,video::SColor(255,255,255,255),true); //paste RTT to screen
... ... // other stuffs
}
... ...

So I think, makeColorKeyTexture can't used to RTT? In source code of Irrlicht, I can't find any limitation.

I currently using Irrlicht-1.7.1 version, WinXP SP2, GeForce9600GT, 4GB memory.
randomMesh
Posts: 1186
Joined: Fri Dec 29, 2006 12:04 am

Re: Strange problem for RTT...

Post by randomMesh »

I tested the following code with valgrind on Linux:

Code: Select all

#include <irrlicht.h>

int main()
{
	irr::IrrlichtDevice* device = irr::createDevice(irr::video::EDT_OPENGL);
	irr::video::IVideoDriver* driver = device->getVideoDriver();

	irr::video::ITexture* tex = driver->getTexture("irrlicht-svn/media/fireball.bmp");

	driver->makeColorKeyTexture(tex, irr::video::SColor(255, 0, 0, 255));

	device->drop();

	return 0;
}
There indeed is an evil memory leak in /libGL.so.1.2 but makeColorKeyTexture didn't show any problems.

Code: Select all

==3969== 17,096 bytes in 148 blocks are definitely lost in loss record 35 of 35
==3969==    at 0x4020E22: calloc (vg_replace_malloc.c:397)
==3969==    by 0x498E5B4: ???
==3969==    by 0x49311DC: ???
==3969==    by 0x4928AA9: ???
==3969==    by 0x49243C0: ???
==3969==    by 0x40DCEB3: (within /usr/lib/libGL.so.1.2)
==3969==    by 0x40DD31D: glXCreateContext (in /usr/lib/libGL.so.1.2)
==3969==    by 0x80DE737: irr::CIrrDeviceLinux::createWindow() (in development/workspace/Test/Debug/Test)
"Whoops..."
lab_zj
Posts: 26
Joined: Wed May 21, 2008 3:25 am

Post by lab_zj »

I place make makeColorKeyTexture() inside render loop, the memory leaks very obviously, and this problem both exist in OpenGL and D3D9 driver.
Post Reply