Render target format (for alpha)

--HG--
branch : multipass-stereo
This commit is contained in:
kaetemi 2014-07-31 18:25:50 +02:00
parent 61f97fae40
commit 79c6f50054
2 changed files with 10 additions and 4 deletions

View file

@ -36,7 +36,7 @@
#include <nel/misc/geom_ext.h>
// Project includes
// ...
#include <nel/3d/u_texture.h>
namespace NL3D {
@ -64,7 +64,7 @@ public:
CRenderTargetManager();
~CRenderTargetManager();
NL3D::CTextureUser *getRenderTarget(uint width, uint height, bool mode2D = false);
NL3D::CTextureUser *getRenderTarget(uint width, uint height, bool mode2D = false, UTexture::TUploadFormat format = UTexture::Auto);
void recycleRenderTarget(NL3D::CTextureUser *renderTarget);
void cleanup();

View file

@ -51,9 +51,13 @@ namespace NL3D {
struct CRenderTargetDescInt
{
public:
// Options
uint Width;
uint Height;
bool Mode2D;
UTexture::TUploadFormat Format;
// Data
NL3D::CTextureUser *TextureUser;
NLMISC::CSmartPtr<NL3D::ITexture> TextureInterface;
bool InUse;
@ -72,13 +76,13 @@ CRenderTargetManager::~CRenderTargetManager()
cleanup();
}
NL3D::CTextureUser *CRenderTargetManager::getRenderTarget(uint width, uint height, bool mode2D)
NL3D::CTextureUser *CRenderTargetManager::getRenderTarget(uint width, uint height, bool mode2D, UTexture::TUploadFormat format)
{
// 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 && desc->Mode2D == mode2D)
if (!desc->InUse && desc->Width == width && desc->Height == height && desc->Mode2D == mode2D && desc->Format == format)
{
desc->InUse = true;
desc->Used = true;
@ -94,6 +98,7 @@ NL3D::CTextureUser *CRenderTargetManager::getRenderTarget(uint width, uint heigh
desc->TextureInterface = tex;
desc->TextureInterface->setRenderTarget(true);
desc->TextureInterface->setReleasable(false);
desc->TextureInterface->setUploadFormat((ITexture::TUploadFormat)(uint32)format);
desc->TextureInterface->resize(width, height);
desc->TextureInterface->setFilterMode(ITexture::Linear, ITexture::LinearMipMapOff);
desc->TextureInterface->setWrapS(ITexture::Clamp);
@ -104,6 +109,7 @@ NL3D::CTextureUser *CRenderTargetManager::getRenderTarget(uint width, uint heigh
desc->Width = width;
desc->Height = height;
desc->Mode2D = mode2D;
desc->Format = format;
desc->Used = true;
desc->InUse = true;
m_RenderTargets.push_back(desc);