Commit cc4ff80f authored by monstrobishi's avatar monstrobishi

- Floating point render target support.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2399 dfc29bdd-3216-0410-991c-e03cc46cb475
parent c8182987
...@@ -32,7 +32,30 @@ enum ECOLOR_FORMAT ...@@ -32,7 +32,30 @@ enum ECOLOR_FORMAT
ECF_R8G8B8, ECF_R8G8B8,
//! Default 32 bit color format. 8 bits are used for every component: red, green, blue and alpha. //! Default 32 bit color format. 8 bits are used for every component: red, green, blue and alpha.
ECF_A8R8G8B8 ECF_A8R8G8B8,
/** Floating Point formats. The following formats may only be used for render target textures. */
//! 16 bit floating point format using 16 bits for the red channel.
ECF_R16F,
//! 32 bit floating point format using 16 bits for the red channel and 16 bits for the green channel.
ECF_G16R16F,
//! 64 bit floating point format 16 bits are used for the red, green, blue and alpha channels.
ECF_A16B16G16R16F,
//! 32 bit floating point format using 32 bits for the red channel.
ECF_R32F,
//! 64 bit floating point format using 32 bits for the red channel and 32 bits for the green channel.
ECF_G32R32F,
//! 128 bit floating point format. 32 bits are used for the red, green, blue and alpha channels.
ECF_A32B32G32R32F,
//! Unknown color format:
ECF_UNKNOWN
}; };
......
...@@ -322,11 +322,12 @@ namespace video ...@@ -322,11 +322,12 @@ namespace video
and it should not be bigger than the backbuffer, because it and it should not be bigger than the backbuffer, because it
shares the zbuffer with the screen buffer. shares the zbuffer with the screen buffer.
\param name An optional name for the RTT. \param name An optional name for the RTT.
\param format The color format of the render target. Floating point formats are supported.
\return Pointer to the created texture or 0 if the texture \return Pointer to the created texture or 0 if the texture
could not be created. This pointer should not be dropped. See could not be created. This pointer should not be dropped. See
IReferenceCounted::drop() for more information. */ IReferenceCounted::drop() for more information. */
virtual ITexture* addRenderTargetTexture(const core::dimension2d<u32>& size, virtual ITexture* addRenderTargetTexture(const core::dimension2d<u32>& size,
const core::string<c16>& name = "rt" ) =0; const core::string<c16>& name = "rt", const ECOLOR_FORMAT format = ECF_UNKNOWN) =0;
//! Removes a texture from the texture cache and deletes it. //! Removes a texture from the texture cache and deletes it.
/** This method can free a lot of memory! /** This method can free a lot of memory!
......
...@@ -792,7 +792,9 @@ bool CD3D8Driver::setRenderTarget(video::ITexture* texture, ...@@ -792,7 +792,9 @@ bool CD3D8Driver::setRenderTarget(video::ITexture* texture,
//! Creates a render target texture. //! Creates a render target texture.
ITexture* CD3D8Driver::addRenderTargetTexture(const core::dimension2d<u32>& size, const core::string<c16>& name) ITexture* CD3D8Driver::addRenderTargetTexture(const core::dimension2d<u32>& size,
const core::string<c16>& name,
const ECOLOR_FORMAT format)
{ {
ITexture* tex = new CD3D8Texture(this, size, name); ITexture* tex = new CD3D8Texture(this, size, name);
addTexture(tex); addTexture(tex);
......
...@@ -187,7 +187,7 @@ namespace video ...@@ -187,7 +187,7 @@ namespace video
//! Creates a render target texture. //! Creates a render target texture.
virtual ITexture* addRenderTargetTexture(const core::dimension2d<u32>& size, virtual ITexture* addRenderTargetTexture(const core::dimension2d<u32>& size,
const core::string<c16>& name); const core::string<c16>& name, const ECOLOR_FORMAT format = ECF_UNKNOWN);
//! Clears the ZBuffer. //! Clears the ZBuffer.
virtual void clearZBuffer(); virtual void clearZBuffer();
......
...@@ -2595,11 +2595,11 @@ IVideoDriver* CD3D9Driver::getVideoDriver() ...@@ -2595,11 +2595,11 @@ IVideoDriver* CD3D9Driver::getVideoDriver()
//! Creates a render target texture. //! Creates a render target texture.
ITexture* CD3D9Driver::addRenderTargetTexture( ITexture* CD3D9Driver::addRenderTargetTexture(const core::dimension2d<u32>& size,
const core::dimension2d<u32>& size, const core::string<c16>& name,
const core::string<c16>& name) const ECOLOR_FORMAT format)
{ {
ITexture* tex = new CD3D9Texture(this, size, name); ITexture* tex = new CD3D9Texture(this, size, name, format);
if (tex) if (tex)
{ {
checkDepthBuffer(tex); checkDepthBuffer(tex);
...@@ -2774,6 +2774,20 @@ D3DFORMAT CD3D9Driver::getD3DFormatFromColorFormat(ECOLOR_FORMAT format) const ...@@ -2774,6 +2774,20 @@ D3DFORMAT CD3D9Driver::getD3DFormatFromColorFormat(ECOLOR_FORMAT format) const
return D3DFMT_R8G8B8; return D3DFMT_R8G8B8;
case ECF_A8R8G8B8: case ECF_A8R8G8B8:
return D3DFMT_A8R8G8B8; return D3DFMT_A8R8G8B8;
// Floating Point formats. Thanks to Patryk "Nadro" Nadrowski.
case ECF_R16F:
return D3DFMT_R16F;
case ECF_G16R16F:
return D3DFMT_G16R16F;
case ECF_A16B16G16R16F:
return D3DFMT_A16B16G16R16F;
case ECF_R32F:
return D3DFMT_R32F;
case ECF_G32R32F:
return D3DFMT_G32R32F;
case ECF_A32B32G32R32F:
return D3DFMT_A32B32G32R32F;
} }
return D3DFMT_UNKNOWN; return D3DFMT_UNKNOWN;
} }
...@@ -2794,6 +2808,20 @@ ECOLOR_FORMAT CD3D9Driver::getColorFormatFromD3DFormat(D3DFORMAT format) const ...@@ -2794,6 +2808,20 @@ ECOLOR_FORMAT CD3D9Driver::getColorFormatFromD3DFormat(D3DFORMAT format) const
return ECF_R5G6B5; return ECF_R5G6B5;
case D3DFMT_R8G8B8: case D3DFMT_R8G8B8:
return ECF_R8G8B8; return ECF_R8G8B8;
// Floating Point formats. Thanks to Patryk "Nadro" Nadrowski.
case D3DFMT_R16F:
return ECF_R16F;
case D3DFMT_G16R16F:
return ECF_G16R16F;
case D3DFMT_A16B16G16R16F:
return ECF_A16B16G16R16F;
case D3DFMT_R32F:
return ECF_R32F;
case D3DFMT_G32R32F:
return ECF_G32R32F;
case D3DFMT_A32B32G32R32F:
return ECF_A32B32G32R32F;
default: default:
return (ECOLOR_FORMAT)0; return (ECOLOR_FORMAT)0;
}; };
......
...@@ -228,7 +228,7 @@ namespace video ...@@ -228,7 +228,7 @@ namespace video
//! Creates a render target texture. //! Creates a render target texture.
virtual ITexture* addRenderTargetTexture(const core::dimension2d<u32>& size, virtual ITexture* addRenderTargetTexture(const core::dimension2d<u32>& size,
const core::string<c16>& name); const core::string<c16>& name, const ECOLOR_FORMAT format = ECF_UNKNOWN);
//! Clears the ZBuffer. //! Clears the ZBuffer.
virtual void clearZBuffer(); virtual void clearZBuffer();
......
...@@ -30,10 +30,11 @@ namespace video ...@@ -30,10 +30,11 @@ namespace video
{ {
//! rendertarget constructor //! rendertarget constructor
CD3D9Texture::CD3D9Texture(CD3D9Driver* driver, const core::dimension2d<u32>& size, const core::string<c16>& name) CD3D9Texture::CD3D9Texture(CD3D9Driver* driver, const core::dimension2d<u32>& size,
const core::string<c16>& name, const ECOLOR_FORMAT format)
: ITexture(name), Texture(0), RTTSurface(0), Driver(driver), DepthSurface(0), : ITexture(name), Texture(0), RTTSurface(0), Driver(driver), DepthSurface(0),
TextureSize(size), ImageSize(size), Pitch(0), TextureSize(size), ImageSize(size), Pitch(0),
HasMipMaps(false), HardwareMipMaps(false), IsRenderTarget(true) HasMipMaps(false), HardwareMipMaps(false), IsRenderTarget(true), ColorFormat(ECF_UNKNOWN)
{ {
#ifdef _DEBUG #ifdef _DEBUG
setDebugName("CD3D9Texture"); setDebugName("CD3D9Texture");
...@@ -43,7 +44,7 @@ CD3D9Texture::CD3D9Texture(CD3D9Driver* driver, const core::dimension2d<u32>& si ...@@ -43,7 +44,7 @@ CD3D9Texture::CD3D9Texture(CD3D9Driver* driver, const core::dimension2d<u32>& si
if (Device) if (Device)
Device->AddRef(); Device->AddRef();
createRenderTarget(); createRenderTarget(format);
} }
...@@ -115,7 +116,7 @@ CD3D9Texture::~CD3D9Texture() ...@@ -115,7 +116,7 @@ CD3D9Texture::~CD3D9Texture()
} }
void CD3D9Texture::createRenderTarget() void CD3D9Texture::createRenderTarget(const ECOLOR_FORMAT format)
{ {
// are texture size restrictions there ? // are texture size restrictions there ?
if(!Driver->queryFeature(EVDF_TEXTURE_NPOT)) if(!Driver->queryFeature(EVDF_TEXTURE_NPOT))
...@@ -126,11 +127,28 @@ void CD3D9Texture::createRenderTarget() ...@@ -126,11 +127,28 @@ void CD3D9Texture::createRenderTarget()
os::Printer::log("RenderTarget size has to be a power of two", ELL_INFORMATION); os::Printer::log("RenderTarget size has to be a power of two", ELL_INFORMATION);
} }
D3DFORMAT d3dformat = Driver->getD3DColorFormat();
if(ColorFormat == ECF_UNKNOWN)
{
// get irrlicht format from backbuffer // get irrlicht format from backbuffer
// (This will get overwritten by the custom format if it is provided, else kept.)
ColorFormat = Driver->getColorFormat(); ColorFormat = Driver->getColorFormat();
D3DFORMAT d3dformat = Driver->getD3DColorFormat();
setPitch(d3dformat); setPitch(d3dformat);
// Use color format if provided.
if(format != ECF_UNKNOWN)
{
ColorFormat = format;
d3dformat = Driver->getD3DFormatFromColorFormat(format);
setPitch(d3dformat); // This will likely set pitch to 0 for now.
}
}
else
{
d3dformat = Driver->getD3DFormatFromColorFormat(ColorFormat);
}
// create texture // create texture
HRESULT hr; HRESULT hr;
......
...@@ -32,7 +32,8 @@ public: ...@@ -32,7 +32,8 @@ public:
u32 flags, const core::string<c16>& name); u32 flags, const core::string<c16>& name);
//! rendertarget constructor //! rendertarget constructor
CD3D9Texture(CD3D9Driver* driver, const core::dimension2d<u32>& size, const core::string<c16>& name); CD3D9Texture(CD3D9Driver* driver, const core::dimension2d<u32>& size, const core::string<c16>& name,
const ECOLOR_FORMAT format = ECF_UNKNOWN);
//! destructor //! destructor
virtual ~CD3D9Texture(); virtual ~CD3D9Texture();
...@@ -77,7 +78,7 @@ public: ...@@ -77,7 +78,7 @@ public:
private: private:
friend class CD3D9Driver; friend class CD3D9Driver;
void createRenderTarget(); void createRenderTarget(const ECOLOR_FORMAT format = ECF_UNKNOWN);
//! returns the size of a texture which would be the optimize size for rendering it //! returns the size of a texture which would be the optimize size for rendering it
inline s32 getTextureSizeFromSurfaceSize(s32 size) const; inline s32 getTextureSizeFromSurfaceSize(s32 size) const;
......
...@@ -508,6 +508,12 @@ ITexture* CNullDriver::addTexture(const core::string<c16>& name, IImage* image) ...@@ -508,6 +508,12 @@ ITexture* CNullDriver::addTexture(const core::string<c16>& name, IImage* image)
ITexture* CNullDriver::addTexture(const core::dimension2d<u32>& size, ITexture* CNullDriver::addTexture(const core::dimension2d<u32>& size,
const core::string<c16>& name, ECOLOR_FORMAT format) const core::string<c16>& name, ECOLOR_FORMAT format)
{ {
if(getRenderTargetOnlyFormat(format))
{
os::Printer::log("Could not create ITexture, format only supported for render target textures.", ELL_WARNING);
return 0;
}
if ( 0 == name.size () ) if ( 0 == name.size () )
return 0; return 0;
...@@ -1321,6 +1327,12 @@ IImage* CNullDriver::createImageFromData(ECOLOR_FORMAT format, ...@@ -1321,6 +1327,12 @@ IImage* CNullDriver::createImageFromData(ECOLOR_FORMAT format,
void *data, bool ownForeignMemory, void *data, bool ownForeignMemory,
bool deleteMemory) bool deleteMemory)
{ {
if(getRenderTargetOnlyFormat(format))
{
os::Printer::log("Could not create IImage, format only supported for render target textures.", ELL_WARNING);
return 0;
}
return new CImage(format, size, data, ownForeignMemory, deleteMemory); return new CImage(format, size, data, ownForeignMemory, deleteMemory);
} }
...@@ -1328,6 +1340,12 @@ IImage* CNullDriver::createImageFromData(ECOLOR_FORMAT format, ...@@ -1328,6 +1340,12 @@ IImage* CNullDriver::createImageFromData(ECOLOR_FORMAT format,
//! Creates an empty software image. //! Creates an empty software image.
IImage* CNullDriver::createImage(ECOLOR_FORMAT format, const core::dimension2d<u32>& size) IImage* CNullDriver::createImage(ECOLOR_FORMAT format, const core::dimension2d<u32>& size)
{ {
if(getRenderTargetOnlyFormat(format))
{
os::Printer::log("Could not create IImage, format only supported for render target textures.", ELL_WARNING);
return 0;
}
return new CImage(format, size); return new CImage(format, size);
} }
...@@ -1335,6 +1353,12 @@ IImage* CNullDriver::createImage(ECOLOR_FORMAT format, const core::dimension2d<u ...@@ -1335,6 +1353,12 @@ IImage* CNullDriver::createImage(ECOLOR_FORMAT format, const core::dimension2d<u
//! Creates a software image from another image. //! Creates a software image from another image.
IImage* CNullDriver::createImage(ECOLOR_FORMAT format, IImage *imageToCopy) IImage* CNullDriver::createImage(ECOLOR_FORMAT format, IImage *imageToCopy)
{ {
if(getRenderTargetOnlyFormat(format))
{
os::Printer::log("Could not create IImage, format only supported for render target textures.", ELL_WARNING);
return 0;
}
return new CImage(format, imageToCopy); return new CImage(format, imageToCopy);
} }
...@@ -1927,7 +1951,7 @@ s32 CNullDriver::addShaderMaterialFromFiles(const core::string<c16>& vertexShade ...@@ -1927,7 +1951,7 @@ s32 CNullDriver::addShaderMaterialFromFiles(const core::string<c16>& vertexShade
//! Creates a render target texture. //! Creates a render target texture.
ITexture* CNullDriver::addRenderTargetTexture(const core::dimension2d<u32>& size, ITexture* CNullDriver::addRenderTargetTexture(const core::dimension2d<u32>& size,
const core::string<c16>&name) const core::string<c16>&name, const ECOLOR_FORMAT format)
{ {
return 0; return 0;
} }
......
...@@ -293,7 +293,7 @@ namespace video ...@@ -293,7 +293,7 @@ namespace video
//! Creates a render target texture. //! Creates a render target texture.
virtual ITexture* addRenderTargetTexture(const core::dimension2d<u32>& size, virtual ITexture* addRenderTargetTexture(const core::dimension2d<u32>& size,
const core::string<c16>& name); const core::string<c16>& name, const ECOLOR_FORMAT format = ECF_UNKNOWN);
//! Creates an 1bit alpha channel of the texture based of an color key. //! Creates an 1bit alpha channel of the texture based of an color key.
virtual void makeColorKeyTexture(video::ITexture* texture, video::SColor color, bool zeroTexels) const; virtual void makeColorKeyTexture(video::ITexture* texture, video::SColor color, bool zeroTexels) const;
...@@ -571,6 +571,20 @@ namespace video ...@@ -571,6 +571,20 @@ namespace video
//! THIS METHOD HAS TO BE OVERRIDDEN BY DERIVED DRIVERS WITH OWN TEXTURES //! THIS METHOD HAS TO BE OVERRIDDEN BY DERIVED DRIVERS WITH OWN TEXTURES
virtual video::ITexture* createDeviceDependentTexture(IImage* surface, const core::string<c16>& name); virtual video::ITexture* createDeviceDependentTexture(IImage* surface, const core::string<c16>& name);
virtual bool getRenderTargetOnlyFormat(const ECOLOR_FORMAT format) const
{
switch(format)
{
case ECF_A1R5G5B5:
case ECF_R5G6B5:
case ECF_R8G8B8:
case ECF_A8R8G8B8:
return false;
default:
return true;
}
}
//! checks triangle count and print warning if wrong //! checks triangle count and print warning if wrong
bool checkPrimitiveCount(u32 prmcnt) const; bool checkPrimitiveCount(u32 prmcnt) const;
......
...@@ -2941,7 +2941,9 @@ IGPUProgrammingServices* COpenGLDriver::getGPUProgrammingServices() ...@@ -2941,7 +2941,9 @@ IGPUProgrammingServices* COpenGLDriver::getGPUProgrammingServices()
} }
ITexture* COpenGLDriver::addRenderTargetTexture(const core::dimension2d<u32>& size, const core::string<c16>& name) ITexture* COpenGLDriver::addRenderTargetTexture(const core::dimension2d<u32>& size,
const core::string<c16>& name,
const ECOLOR_FORMAT format)
{ {
//disable mip-mapping //disable mip-mapping
bool generateMipLevels = getTextureCreationFlag(ETCF_CREATE_MIP_MAPS); bool generateMipLevels = getTextureCreationFlag(ETCF_CREATE_MIP_MAPS);
...@@ -2952,7 +2954,7 @@ ITexture* COpenGLDriver::addRenderTargetTexture(const core::dimension2d<u32>& si ...@@ -2952,7 +2954,7 @@ ITexture* COpenGLDriver::addRenderTargetTexture(const core::dimension2d<u32>& si
// if driver supports FrameBufferObjects, use them // if driver supports FrameBufferObjects, use them
if (queryFeature(EVDF_FRAMEBUFFER_OBJECT)) if (queryFeature(EVDF_FRAMEBUFFER_OBJECT))
{ {
rtt = new COpenGLFBOTexture(size, name, this); rtt = new COpenGLFBOTexture(size, name, this, format);
if (rtt) if (rtt)
{ {
bool success = false; bool success = false;
......
...@@ -259,7 +259,7 @@ namespace video ...@@ -259,7 +259,7 @@ namespace video
virtual u32 getMaximalPrimitiveCount() const; virtual u32 getMaximalPrimitiveCount() const;
virtual ITexture* addRenderTargetTexture(const core::dimension2d<u32>& size, virtual ITexture* addRenderTargetTexture(const core::dimension2d<u32>& size,
const core::string<c16>& name); const core::string<c16>& name, const ECOLOR_FORMAT format = ECF_UNKNOWN);
//! set or reset render target //! set or reset render target
virtual bool setRenderTarget(video::E_RENDER_TARGET target, bool clearTarget, virtual bool setRenderTarget(video::E_RENDER_TARGET target, bool clearTarget,
......
...@@ -450,7 +450,8 @@ static bool checkFBOStatus(COpenGLDriver* Driver); ...@@ -450,7 +450,8 @@ static bool checkFBOStatus(COpenGLDriver* Driver);
//! RTT ColorFrameBuffer constructor //! RTT ColorFrameBuffer constructor
COpenGLFBOTexture::COpenGLFBOTexture(const core::dimension2d<u32>& size, COpenGLFBOTexture::COpenGLFBOTexture(const core::dimension2d<u32>& size,
const core::string<c16>& name, const core::string<c16>& name,
COpenGLDriver* driver) COpenGLDriver* driver,
const ECOLOR_FORMAT format)
: COpenGLTexture(name, driver), DepthTexture(0), ColorFrameBuffer(0) : COpenGLTexture(name, driver), DepthTexture(0), ColorFrameBuffer(0)
{ {
#ifdef _DEBUG #ifdef _DEBUG
...@@ -459,9 +460,10 @@ COpenGLFBOTexture::COpenGLFBOTexture(const core::dimension2d<u32>& size, ...@@ -459,9 +460,10 @@ COpenGLFBOTexture::COpenGLFBOTexture(const core::dimension2d<u32>& size,
ImageSize = size; ImageSize = size;
TextureSize = size; TextureSize = size;
InternalFormat = GL_RGBA;
PixelFormat = GL_RGBA; GLint FilteringType;
PixelType = GL_UNSIGNED_BYTE; InternalFormat = getOpenGLFormatAndParametersFromColorFormat(format, FilteringType, PixelFormat, PixelType);
HasMipMaps = false; HasMipMaps = false;
IsRenderTarget = true; IsRenderTarget = true;
...@@ -473,7 +475,7 @@ COpenGLFBOTexture::COpenGLFBOTexture(const core::dimension2d<u32>& size, ...@@ -473,7 +475,7 @@ COpenGLFBOTexture::COpenGLFBOTexture(const core::dimension2d<u32>& size,
// generate color texture // generate color texture
glGenTextures(1, &TextureName); glGenTextures(1, &TextureName);
Driver->setTexture(0, this); Driver->setTexture(0, this);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, FilteringType);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D(GL_TEXTURE_2D, 0, InternalFormat, ImageSize.Width, glTexImage2D(GL_TEXTURE_2D, 0, InternalFormat, ImageSize.Width,
...@@ -489,6 +491,73 @@ COpenGLFBOTexture::COpenGLFBOTexture(const core::dimension2d<u32>& size, ...@@ -489,6 +491,73 @@ COpenGLFBOTexture::COpenGLFBOTexture(const core::dimension2d<u32>& size,
unbindRTT(); unbindRTT();
} }
GLint COpenGLFBOTexture::getOpenGLFormatAndParametersFromColorFormat(ECOLOR_FORMAT format,
GLint& filtering,
GLenum& colorformat,
GLenum& type)
{
switch(format)
{
// Floating Point texture formats. Thanks to Patryk "Nadro" Nadrowski.
case ECF_R16F:
{
filtering = GL_NEAREST;
colorformat = GL_RED;
type = GL_FLOAT;
return GL_RGB16F_ARB;
}
case ECF_G16R16F:
{
// We haven't got support for this type specifically, so we should use RGB for a close match.
filtering = GL_NEAREST;
colorformat = GL_RGB;
type = GL_FLOAT;
return GL_RGB16F_ARB;
}
case ECF_A16B16G16R16F:
{
filtering = GL_NEAREST;
colorformat = GL_RGBA;
type = GL_FLOAT;
return GL_RGBA16F_ARB;
}
case ECF_R32F:
{
filtering = GL_NEAREST;
colorformat = GL_RED;
type = GL_FLOAT;
return GL_RGB32F_ARB;
}
case ECF_G32R32F:
{
// We haven't got support for this type specifically, so we should use RGB for a close match.
filtering = GL_NEAREST;
colorformat = GL_RGB;
type = GL_FLOAT;
return GL_RGB32F_ARB;
}
case ECF_A32B32G32R32F:
{
filtering = GL_NEAREST;
colorformat = GL_RGBA;
type = GL_FLOAT;
return GL_RGBA32F_ARB;
}
}
filtering = GL_LINEAR;
colorformat = GL_RGBA;
type = GL_UNSIGNED_BYTE;
return GL_RGBA8;
}
//! destructor //! destructor
COpenGLFBOTexture::~COpenGLFBOTexture() COpenGLFBOTexture::~COpenGLFBOTexture()
......
...@@ -140,7 +140,8 @@ class COpenGLFBOTexture : public COpenGLTexture ...@@ -140,7 +140,8 @@ class COpenGLFBOTexture : public COpenGLTexture
public: public:
//! FrameBufferObject constructor //! FrameBufferObject constructor
COpenGLFBOTexture(const core::dimension2d<u32>& size, const core::string<c16>& name, COpenGLDriver* driver=0); COpenGLFBOTexture(const core::dimension2d<u32>& size, const core::string<c16>& name,
COpenGLDriver* driver = 0, const ECOLOR_FORMAT format = ECF_UNKNOWN);
//! destructor //! destructor
virtual ~COpenGLFBOTexture(); virtual ~COpenGLFBOTexture();
...@@ -156,6 +157,9 @@ public: ...@@ -156,6 +157,9 @@ public:
ITexture* DepthTexture; ITexture* DepthTexture;
protected: protected:
GLint getOpenGLFormatAndParametersFromColorFormat(
ECOLOR_FORMAT format, GLint& filtering, GLenum& colorformat, GLenum& type);
GLuint ColorFrameBuffer; GLuint ColorFrameBuffer;
}; };
......
...@@ -895,7 +895,9 @@ const core::matrix4& CSoftwareDriver::getTransform(E_TRANSFORMATION_STATE state) ...@@ -895,7 +895,9 @@ const core::matrix4& CSoftwareDriver::getTransform(E_TRANSFORMATION_STATE state)
//! Creates a render target texture. //! Creates a render target texture.
ITexture* CSoftwareDriver::addRenderTargetTexture(const core::dimension2d<u32>& size, const core::string<c16>& name) ITexture* CSoftwareDriver::addRenderTargetTexture(const core::dimension2d<u32>& size,
const core::string<c16>& name,
const ECOLOR_FORMAT format)
{ {
CImage* img = new CImage(video::ECF_A1R5G5B5, size); CImage* img = new CImage(video::ECF_A1R5G5B5, size);
ITexture* tex = new CSoftwareTexture(img, name, true); ITexture* tex = new CSoftwareTexture(img, name, true);
......
...@@ -105,7 +105,7 @@ namespace video ...@@ -105,7 +105,7 @@ namespace video
//! Creates a render target texture. //! Creates a render target texture.
virtual ITexture* addRenderTargetTexture(const core::dimension2d<u32>& size, virtual ITexture* addRenderTargetTexture(const core::dimension2d<u32>& size,
const core::string<c16>& name); const core::string<c16>& name, const ECOLOR_FORMAT format = ECF_UNKNOWN);
//! Clears the ZBuffer. //! Clears the ZBuffer.
virtual void clearZBuffer(); virtual void clearZBuffer();
......
...@@ -1954,7 +1954,7 @@ const core::matrix4& CBurningVideoDriver::getTransform(E_TRANSFORMATION_STATE st ...@@ -1954,7 +1954,7 @@ const core::matrix4& CBurningVideoDriver::getTransform(E_TRANSFORMATION_STATE st
//! Creates a render target texture. //! Creates a render target texture.
ITexture* CBurningVideoDriver::addRenderTargetTexture(const core::dimension2d<u32>& size, ITexture* CBurningVideoDriver::addRenderTargetTexture(const core::dimension2d<u32>& size,
const core::string<c16>& name) const core::string<c16>& name, const ECOLOR_FORMAT format)
{ {
CImage* img = new CImage(BURNINGSHADER_COLOR_FORMAT, size); CImage* img = new CImage(BURNINGSHADER_COLOR_FORMAT, size);
ITexture* tex = new CSoftwareTexture2(img, name, CSoftwareTexture2::IS_RENDERTARGET ); ITexture* tex = new CSoftwareTexture2(img, name, CSoftwareTexture2::IS_RENDERTARGET );
......
...@@ -123,7 +123,8 @@ namespace video ...@@ -123,7 +123,8 @@ namespace video
virtual const core::matrix4& getTransform(E_TRANSFORMATION_STATE state) const; virtual const core::matrix4& getTransform(E_TRANSFORMATION_STATE state) const;
//! Creates a render target texture. //! Creates a render target texture.
virtual ITexture* addRenderTargetTexture(const core::dimension2d<u32>& size, const core::string<c16>& name); virtual ITexture* addRenderTargetTexture(const core::dimension2d<u32>& size,
const core::string<c16>& name, const ECOLOR_FORMAT format = ECF_UNKNOWN);
//! Clears the DepthBuffer. //! Clears the DepthBuffer.
virtual void clearZBuffer(); virtual void clearZBuffer();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment