From 9516851beec67d75e93c3dbb10c0c16f40367492 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Wed, 3 Jul 2013 03:21:57 +0200 Subject: [PATCH] Remove unnecessary user render target code from bloom, see #43 --- code/nel/include/nel/3d/bloom_effect.h | 5 +--- code/nel/src/3d/bloom_effect.cpp | 38 ++++---------------------- 2 files changed, 6 insertions(+), 37 deletions(-) diff --git a/code/nel/include/nel/3d/bloom_effect.h b/code/nel/include/nel/3d/bloom_effect.h index b637fe937..77673741c 100644 --- a/code/nel/include/nel/3d/bloom_effect.h +++ b/code/nel/include/nel/3d/bloom_effect.h @@ -83,7 +83,6 @@ public: // If window size exceeds 256*256 the textures used to apply blur are reinitialized with // 256*256 size. If a dimension is less than 256, the texture is initialized with the nearer // power of 2, lower than this window dimension. - void initBloom(UTexture *renderTarget); void initBloom(); // Called at the end of renderAll method in the main loop, recover stretched texture, apply @@ -132,15 +131,13 @@ private: uint8 _DensityBloom; // render target textures - // used to display scene (FIXME: redundant when user render target provided...) + // used to display scene NLMISC::CSmartPtr _InitText; // used as stretched texture from _InitText, as displayed texture in first blur pass, // and as render target in second blur pass. NLMISC::CSmartPtr _BlurFinalTex; // used as render target in first blur pass, and as displayed texture on second blur pass. NLMISC::CSmartPtr _BlurHorizontalTex; - /// User provided render target. - NLMISC::CSmartPtr m_UserRenderTarget; // materials diff --git a/code/nel/src/3d/bloom_effect.cpp b/code/nel/src/3d/bloom_effect.cpp index 60b7d36b7..927f8688c 100644 --- a/code/nel/src/3d/bloom_effect.cpp +++ b/code/nel/src/3d/bloom_effect.cpp @@ -271,18 +271,11 @@ void CBloomEffect::initTexture(CSmartPtr & tex, bool isMode2D, uint32 //----------------------------------------------------------------------------------------------------------- -void CBloomEffect::initBloom() -{ - initBloom(NULL); -} - -void CBloomEffect::initBloom(UTexture *renderTarget) // clientcfg +void CBloomEffect::initBloom() // clientcfg { if(!((CDriverUser *)_Driver)->getDriver()->supportBloomEffect()) return; - m_UserRenderTarget = renderTarget ? dynamic_cast(renderTarget)->getITexture() : NULL; - // don't activate bloom when PolygonMode is different from Filled if (_Driver->getPolygonMode() != UDriver::Filled) return; @@ -355,20 +348,8 @@ void CBloomEffect::initBloom(UTexture *renderTarget) // clientcfg _DisplaySquareBlurMat.getObjectPtr()->setTexture(1, _BlurFinalTex); } } - - // For now the user target must be the window size - // to be compatible with the existing code. - // TODO: Instead, if user render target is provided, - // assume the size of the user render target as - // the screen size to be used. - if (m_UserRenderTarget.getPtr()) - { - nlassert(_WndWidth == m_UserRenderTarget->getWidth()); - nlassert(_WndHeight == m_UserRenderTarget->getHeight()); - _DisplayInitMat.getObjectPtr()->setTexture(0, m_UserRenderTarget); - } - NL3D::CTextureUser txt = (_InitBloomEffect) ? (CTextureUser(m_UserRenderTarget.getPtr() ? m_UserRenderTarget : _InitText)) : (CTextureUser()); + NL3D::CTextureUser txt = (_InitBloomEffect) ? (CTextureUser(_InitText)) : (CTextureUser()); if(!((CDriverUser *) _Driver)->setRenderTarget(txt, 0, 0, _WndWidth, _WndHeight)) { nlwarning("setRenderTarget return false with initial texture for bloom effect\n"); @@ -389,7 +370,7 @@ void CBloomEffect::endBloom() // clientcfg if(_Driver->getWindowWidth()==0 || _Driver->getWindowHeight()==0) return; - CTextureUser txt1 = (_InitBloomEffect) ? (CTextureUser(m_UserRenderTarget.getPtr() ? m_UserRenderTarget : _InitText)) : (CTextureUser()); + CTextureUser txt1 = (_InitBloomEffect) ? (CTextureUser(_InitText)) : (CTextureUser()); CTextureUser txt2(_BlurFinalTex); CRect rect1(0, 0, _WndWidth, _WndHeight); CRect rect2(0, 0, _BlurWidth, _BlurHeight); @@ -416,7 +397,7 @@ void CBloomEffect::applyBlur() // in opengl, display in init texture if(_InitBloomEffect) { - CTextureUser txt(m_UserRenderTarget.getPtr() ? m_UserRenderTarget : _InitText); + CTextureUser txt(_InitText); if(!((CDriverUser *) _Driver)->setRenderTarget(txt, 0, 0, _WndWidth, _WndHeight)) { nlwarning("setRenderTarget return false with initial texture for bloom effect\n"); @@ -478,7 +459,7 @@ void CBloomEffect::endInterfacesDisplayBloom() // clientcfg { // Render from render target to screen if necessary. // Don't do this when the blend was done to the screen or when rendering to a user provided rendertarget. - if (_InitBloomEffect && m_UserRenderTarget.isNull()) + if (_InitBloomEffect) { if(!_Driver->supportBloomEffect() || !_Init) return; @@ -511,15 +492,6 @@ void CBloomEffect::endInterfacesDisplayBloom() // clientcfg _Driver->drawQuad(_DisplayQuad, _DisplayInitMat); _Driver->setMatrixMode3D(pCam); } - - if (m_UserRenderTarget.getPtr()) - { - if (_InitBloomEffect) - { - _DisplayInitMat.getObjectPtr()->setTexture(0, _InitText); - } - m_UserRenderTarget = NULL; - } }