mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-30 15:45:58 +00:00
Render target format (for alpha)
This commit is contained in:
parent
dade08fd31
commit
f07994a8d4
2 changed files with 10 additions and 4 deletions
|
@ -36,7 +36,7 @@
|
||||||
#include <nel/misc/geom_ext.h>
|
#include <nel/misc/geom_ext.h>
|
||||||
|
|
||||||
// Project includes
|
// Project includes
|
||||||
// ...
|
#include <nel/3d/u_texture.h>
|
||||||
|
|
||||||
namespace NL3D {
|
namespace NL3D {
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ public:
|
||||||
CRenderTargetManager();
|
CRenderTargetManager();
|
||||||
~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 recycleRenderTarget(NL3D::CTextureUser *renderTarget);
|
||||||
|
|
||||||
void cleanup();
|
void cleanup();
|
||||||
|
|
|
@ -51,9 +51,13 @@ namespace NL3D {
|
||||||
struct CRenderTargetDescInt
|
struct CRenderTargetDescInt
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
// Options
|
||||||
uint Width;
|
uint Width;
|
||||||
uint Height;
|
uint Height;
|
||||||
bool Mode2D;
|
bool Mode2D;
|
||||||
|
UTexture::TUploadFormat Format;
|
||||||
|
|
||||||
|
// Data
|
||||||
NL3D::CTextureUser *TextureUser;
|
NL3D::CTextureUser *TextureUser;
|
||||||
NLMISC::CSmartPtr<NL3D::ITexture> TextureInterface;
|
NLMISC::CSmartPtr<NL3D::ITexture> TextureInterface;
|
||||||
bool InUse;
|
bool InUse;
|
||||||
|
@ -72,13 +76,13 @@ CRenderTargetManager::~CRenderTargetManager()
|
||||||
cleanup();
|
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
|
// 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)
|
for (std::vector<CRenderTargetDescInt *>::iterator it(m_RenderTargets.begin()), end(m_RenderTargets.end()); it != end; ++it)
|
||||||
{
|
{
|
||||||
CRenderTargetDescInt *desc = *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->InUse = true;
|
||||||
desc->Used = true;
|
desc->Used = true;
|
||||||
|
@ -94,6 +98,7 @@ NL3D::CTextureUser *CRenderTargetManager::getRenderTarget(uint width, uint heigh
|
||||||
desc->TextureInterface = tex;
|
desc->TextureInterface = tex;
|
||||||
desc->TextureInterface->setRenderTarget(true);
|
desc->TextureInterface->setRenderTarget(true);
|
||||||
desc->TextureInterface->setReleasable(false);
|
desc->TextureInterface->setReleasable(false);
|
||||||
|
desc->TextureInterface->setUploadFormat((ITexture::TUploadFormat)(uint32)format);
|
||||||
desc->TextureInterface->resize(width, height);
|
desc->TextureInterface->resize(width, height);
|
||||||
desc->TextureInterface->setFilterMode(ITexture::Linear, ITexture::LinearMipMapOff);
|
desc->TextureInterface->setFilterMode(ITexture::Linear, ITexture::LinearMipMapOff);
|
||||||
desc->TextureInterface->setWrapS(ITexture::Clamp);
|
desc->TextureInterface->setWrapS(ITexture::Clamp);
|
||||||
|
@ -104,6 +109,7 @@ NL3D::CTextureUser *CRenderTargetManager::getRenderTarget(uint width, uint heigh
|
||||||
desc->Width = width;
|
desc->Width = width;
|
||||||
desc->Height = height;
|
desc->Height = height;
|
||||||
desc->Mode2D = mode2D;
|
desc->Mode2D = mode2D;
|
||||||
|
desc->Format = format;
|
||||||
desc->Used = true;
|
desc->Used = true;
|
||||||
desc->InUse = true;
|
desc->InUse = true;
|
||||||
m_RenderTargets.push_back(desc);
|
m_RenderTargets.push_back(desc);
|
||||||
|
|
Loading…
Reference in a new issue