Commit df3dce71 authored by hybrid's avatar hybrid

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
parent d10bb443
...@@ -2737,9 +2737,12 @@ ITexture* COpenGLDriver::addRenderTargetTexture(const core::dimension2d<s32>& si ...@@ -2737,9 +2737,12 @@ ITexture* COpenGLDriver::addRenderTargetTexture(const core::dimension2d<s32>& si
if (rtt) if (rtt)
{ {
addTexture(rtt); addTexture(rtt);
ITexture* tex = getDepthTexture(rtt); ITexture* tex = createDepthTexture(rtt);
if (tex) if (tex)
{
static_cast<video::COpenGLFBODepthTexture*>(tex)->attach(rtt); static_cast<video::COpenGLFBODepthTexture*>(tex)->attach(rtt);
tex->drop();
}
rtt->drop(); rtt->drop();
} }
} }
...@@ -2753,7 +2756,6 @@ ITexture* COpenGLDriver::addRenderTargetTexture(const core::dimension2d<s32>& si ...@@ -2753,7 +2756,6 @@ ITexture* COpenGLDriver::addRenderTargetTexture(const core::dimension2d<s32>& si
rtt = addTexture(destSize, name, ECF_A8R8G8B8); rtt = addTexture(destSize, name, ECF_A8R8G8B8);
if (rtt) if (rtt)
{ {
rtt->grab();
static_cast<video::COpenGLTexture*>(rtt)->setIsRenderTarget(true); static_cast<video::COpenGLTexture*>(rtt)->setIsRenderTarget(true);
} }
} }
...@@ -2912,7 +2914,7 @@ IImage* COpenGLDriver::createScreenShot() ...@@ -2912,7 +2914,7 @@ IImage* COpenGLDriver::createScreenShot()
//! get depth texture for the given render target texture //! 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())) if ((texture->getDriverType() != EDT_OPENGL) || (!texture->isRenderTarget()))
return 0; return 0;
......
...@@ -338,7 +338,7 @@ namespace video ...@@ -338,7 +338,7 @@ namespace video
//! Returns the graphics card vendor name. //! Returns the graphics card vendor name.
virtual core::stringc getVendorInfo() {return vendorName;} virtual core::stringc getVendorInfo() {return vendorName;}
ITexture* getDepthTexture(ITexture* texture, bool shared=true); ITexture* createDepthTexture(ITexture* texture, bool shared=true);
void removeDepthTexture(ITexture* texture); void removeDepthTexture(ITexture* texture);
private: private:
......
...@@ -633,7 +633,7 @@ void COpenGLFBODepthTexture::attach(ITexture* renderTex) ...@@ -633,7 +633,7 @@ void COpenGLFBODepthTexture::attach(ITexture* renderTex)
os::Printer::log("FBO incomplete"); os::Printer::log("FBO incomplete");
#endif #endif
rtt->DepthTexture=this; rtt->DepthTexture=this;
renderTex->grab(); grab(); // grab the depth buffer, not the RTT
rtt->unbindRTT(); rtt->unbindRTT();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment