Mode2D selection

This commit is contained in:
kaetemi 2014-07-31 03:53:38 +02:00
parent a6812f5844
commit 029d9bddfe
3 changed files with 12 additions and 7 deletions

View file

@ -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();

View file

@ -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<ITexture> tex = _TextureTarget ? _TextureTarget : (_RenderTargetFBO ? _RenderTargetFBO : NULL);
if (tex)
{
width = _TextureTarget->getWidth();
height = _TextureTarget->getHeight();
width = tex->getWidth();
height = tex->getHeight();
}
else
{

View file

@ -53,6 +53,7 @@ struct CRenderTargetDescInt
public:
uint Width;
uint Height;
bool Mode2D;
NL3D::CTextureUser *TextureUser;
NLMISC::CSmartPtr<NL3D::ITexture> 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<CRenderTargetDescInt *>::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<CDriverUser *>(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);