Fix mem leaks with RTTs under OpenGL due to wrong grabs.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1778 dfc29bdd-3216-0410-991c-e03cc46cb475
master
hybrid 2008-11-19 13:01:24 +00:00
parent d10bb4431d
commit df3dce717d
3 changed files with 7 additions and 5 deletions

View File

@ -2737,9 +2737,12 @@ ITexture* COpenGLDriver::addRenderTargetTexture(const core::dimension2d<s32>& si
if (rtt)
{
addTexture(rtt);
ITexture* tex = getDepthTexture(rtt);
ITexture* tex = createDepthTexture(rtt);
if (tex)
{
static_cast<video::COpenGLFBODepthTexture*>(tex)->attach(rtt);
tex->drop();
}
rtt->drop();
}
}
@ -2753,7 +2756,6 @@ ITexture* COpenGLDriver::addRenderTargetTexture(const core::dimension2d<s32>& si
rtt = addTexture(destSize, name, ECF_A8R8G8B8);
if (rtt)
{
rtt->grab();
static_cast<video::COpenGLTexture*>(rtt)->setIsRenderTarget(true);
}
}
@ -2912,7 +2914,7 @@ IImage* COpenGLDriver::createScreenShot()
//! get depth texture for the given render target texture
ITexture* COpenGLDriver::getDepthTexture(ITexture* texture, bool shared)
ITexture* COpenGLDriver::createDepthTexture(ITexture* texture, bool shared)
{
if ((texture->getDriverType() != EDT_OPENGL) || (!texture->isRenderTarget()))
return 0;

View File

@ -338,7 +338,7 @@ namespace video
//! Returns the graphics card vendor name.
virtual core::stringc getVendorInfo() {return vendorName;}
ITexture* getDepthTexture(ITexture* texture, bool shared=true);
ITexture* createDepthTexture(ITexture* texture, bool shared=true);
void removeDepthTexture(ITexture* texture);
private:

View File

@ -633,7 +633,7 @@ void COpenGLFBODepthTexture::attach(ITexture* renderTex)
os::Printer::log("FBO incomplete");
#endif
rtt->DepthTexture=this;
renderTex->grab();
grab(); // grab the depth buffer, not the RTT
rtt->unbindRTT();
}