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.
Strange problem for RTT...
-
randomMesh
- Posts: 1186
- Joined: Fri Dec 29, 2006 12:04 am
Re: Strange problem for RTT...
I tested the following code with valgrind on Linux:
There indeed is an evil memory leak in /libGL.so.1.2 but makeColorKeyTexture didn't show any problems.
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;
}
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..."