From 22d03c5f79031313c599c1f139386179d3e6aaf5 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Thu, 31 Jul 2014 03:53:38 +0200 Subject: [PATCH] Mode2D selection --HG-- branch : multipass-stereo --- code/nel/include/nel/3d/render_target_manager.h | 2 +- .../nel/src/3d/driver/opengl/driver_opengl_texture.cpp | 7 ++++--- code/nel/src/3d/render_target_manager.cpp | 10 +++++++--- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/code/nel/include/nel/3d/render_target_manager.h b/code/nel/include/nel/3d/render_target_manager.h index c341de3f2..9203a5f3d 100644 --- a/code/nel/include/nel/3d/render_target_manager.h +++ b/code/nel/include/nel/3d/render_target_manager.h @@ -64,7 +64,7 @@ public: CRenderTargetManager(); ~CRenderTargetManager(); - NL3D::CTextureUser *getRenderTarget(uint width, uint height); + NL3D::CTextureUser *getRenderTarget(uint width, uint height, bool mode2D = false); void recycleRenderTarget(NL3D::CTextureUser *renderTarget); void cleanup(); diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_texture.cpp b/code/nel/src/3d/driver/opengl/driver_opengl_texture.cpp index f26b53254..10dea6d7e 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_texture.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_texture.cpp @@ -2401,10 +2401,11 @@ bool CDriverGL::copyTargetToTexture (ITexture *tex, bool CDriverGL::getRenderTargetSize (uint32 &width, uint32 &height) { H_AUTO_OGL(CDriverGL_getRenderTargetSize) - if (_TextureTarget) + NLMISC::CSmartPtr tex = _TextureTarget ? _TextureTarget : (_RenderTargetFBO ? _RenderTargetFBO : NULL); + if (tex) { - width = _TextureTarget->getWidth(); - height = _TextureTarget->getHeight(); + width = tex->getWidth(); + height = tex->getHeight(); } else { diff --git a/code/nel/src/3d/render_target_manager.cpp b/code/nel/src/3d/render_target_manager.cpp index 7939ba542..ba6172ac6 100644 --- a/code/nel/src/3d/render_target_manager.cpp +++ b/code/nel/src/3d/render_target_manager.cpp @@ -53,6 +53,7 @@ struct CRenderTargetDescInt public: uint Width; uint Height; + bool Mode2D; NL3D::CTextureUser *TextureUser; NLMISC::CSmartPtr TextureInterface; bool InUse; @@ -71,13 +72,13 @@ CRenderTargetManager::~CRenderTargetManager() cleanup(); } -NL3D::CTextureUser *CRenderTargetManager::getRenderTarget(uint width, uint height) +NL3D::CTextureUser *CRenderTargetManager::getRenderTarget(uint width, uint height, bool mode2D) { // Find or create a render target, short loop so no real optimization for (std::vector::iterator it(m_RenderTargets.begin()), end(m_RenderTargets.end()); it != end; ++it) { CRenderTargetDescInt *desc = *it; - if (!desc->InUse && desc->Width == width && desc->Height == height) + if (!desc->InUse && desc->Width == width && desc->Height == height && desc->Mode2D == mode2D) { desc->InUse = true; desc->Used = true; @@ -88,7 +89,9 @@ NL3D::CTextureUser *CRenderTargetManager::getRenderTarget(uint width, uint heigh nldebug("3D: Create new render target (%u x %u)", width, height); NL3D::IDriver *drvInternal = (static_cast(m_Driver))->getDriver(); CRenderTargetDescInt *desc = new CRenderTargetDescInt(); - desc->TextureInterface = new CTextureBloom(); // LOL + CTextureBloom *tex = new CTextureBloom(); // LOL + tex->mode2D(mode2D); + desc->TextureInterface = tex; desc->TextureInterface->setRenderTarget(true); desc->TextureInterface->setReleasable(false); desc->TextureInterface->resize(width, height); @@ -100,6 +103,7 @@ NL3D::CTextureUser *CRenderTargetManager::getRenderTarget(uint width, uint heigh nlassert(!drvInternal->isTextureRectangle(desc->TextureInterface)); // Not allowed, we only support NPOT for render targets now. desc->Width = width; desc->Height = height; + desc->Mode2D = mode2D; desc->Used = true; desc->InUse = true; m_RenderTargets.push_back(desc);