irr: Add stencil patch
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@13003 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
f2cca4e5e8
commit
56177bdc93
@ -1,3 +1,4 @@
|
||||
The following changes have been made:
|
||||
- config changes in IrrCompileConfig.h
|
||||
- primary sort by material type
|
||||
- stencil RTT support
|
||||
|
@ -435,11 +435,13 @@ namespace video
|
||||
shares the zbuffer with the screen buffer.
|
||||
\param name An optional name for the RTT.
|
||||
\param format The color format of the render target. Floating point formats are supported.
|
||||
\param useStencil Whether to enable stencil for this RTT. Default false.
|
||||
\return Pointer to the created texture or 0 if the texture
|
||||
could not be created. This pointer should not be dropped. See
|
||||
IReferenceCounted::drop() for more information. */
|
||||
virtual ITexture* addRenderTargetTexture(const core::dimension2d<u32>& size,
|
||||
const io::path& name = "rt", const ECOLOR_FORMAT format = ECF_UNKNOWN) =0;
|
||||
const io::path& name = "rt", const ECOLOR_FORMAT format = ECF_UNKNOWN,
|
||||
const bool useStencil = false) =0;
|
||||
|
||||
//! Removes a texture from the texture cache and deletes it.
|
||||
/** This method can free a lot of memory!
|
||||
|
@ -2315,7 +2315,8 @@ s32 CNullDriver::addShaderMaterialFromFiles(const io::path& vertexShaderProgramF
|
||||
|
||||
//! Creates a render target texture.
|
||||
ITexture* CNullDriver::addRenderTargetTexture(const core::dimension2d<u32>& size,
|
||||
const io::path&name, const ECOLOR_FORMAT format)
|
||||
const io::path&name, const ECOLOR_FORMAT format,
|
||||
const bool useStencil)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -315,7 +315,8 @@ namespace video
|
||||
|
||||
//! Creates a render target texture.
|
||||
virtual ITexture* addRenderTargetTexture(const core::dimension2d<u32>& size,
|
||||
const io::path& name, const ECOLOR_FORMAT format = ECF_UNKNOWN);
|
||||
const io::path& name, const ECOLOR_FORMAT format = ECF_UNKNOWN,
|
||||
const bool useStencil = false);
|
||||
|
||||
//! 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;
|
||||
|
@ -8,7 +8,6 @@
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_OPENGL_
|
||||
|
||||
#include "COpenGLTexture.h"
|
||||
#include "COpenGLMaterialRenderer.h"
|
||||
#include "COpenGLShaderMaterialRenderer.h"
|
||||
#include "COpenGLSLMaterialRenderer.h"
|
||||
@ -3994,7 +3993,8 @@ IVideoDriver* COpenGLDriver::getVideoDriver()
|
||||
|
||||
ITexture* COpenGLDriver::addRenderTargetTexture(const core::dimension2d<u32>& size,
|
||||
const io::path& name,
|
||||
const ECOLOR_FORMAT format)
|
||||
const ECOLOR_FORMAT format,
|
||||
const bool useStencil)
|
||||
{
|
||||
//disable mip-mapping
|
||||
bool generateMipLevels = getTextureCreationFlag(ETCF_CREATE_MIP_MAPS);
|
||||
@ -4010,7 +4010,7 @@ ITexture* COpenGLDriver::addRenderTargetTexture(const core::dimension2d<u32>& si
|
||||
{
|
||||
bool success = false;
|
||||
addTexture(rtt);
|
||||
ITexture* tex = createDepthTexture(rtt);
|
||||
ITexture* tex = createDepthTexture(rtt, useStencil);
|
||||
if (tex)
|
||||
{
|
||||
success = static_cast<video::COpenGLFBODepthTexture*>(tex)->attach(rtt);
|
||||
@ -4566,7 +4566,7 @@ IImage* COpenGLDriver::createScreenShot(video::ECOLOR_FORMAT format, video::E_RE
|
||||
|
||||
|
||||
//! get depth texture for the given render target texture
|
||||
ITexture* COpenGLDriver::createDepthTexture(ITexture* texture, bool shared)
|
||||
ITexture* COpenGLDriver::createDepthTexture(ITexture* texture, const bool useStencil, const bool shared)
|
||||
{
|
||||
if ((texture->getDriverType() != EDT_OPENGL) || (!texture->isRenderTarget()))
|
||||
return 0;
|
||||
@ -4579,16 +4579,17 @@ ITexture* COpenGLDriver::createDepthTexture(ITexture* texture, bool shared)
|
||||
{
|
||||
for (u32 i=0; i<DepthTextures.size(); ++i)
|
||||
{
|
||||
if (DepthTextures[i]->getSize()==texture->getSize())
|
||||
if (DepthTextures[i]->getSize()==texture->getSize() &&
|
||||
useStencil == DepthTextures[i]->hasStencil())
|
||||
{
|
||||
DepthTextures[i]->grab();
|
||||
return DepthTextures[i];
|
||||
}
|
||||
}
|
||||
DepthTextures.push_back(new COpenGLFBODepthTexture(texture->getSize(), "depth1", this));
|
||||
DepthTextures.push_back(new COpenGLFBODepthTexture(texture->getSize(), "depth1", this, useStencil));
|
||||
return DepthTextures.getLast();
|
||||
}
|
||||
return (new COpenGLFBODepthTexture(texture->getSize(), "depth1", this));
|
||||
return (new COpenGLFBODepthTexture(texture->getSize(), "depth1", this, useStencil));
|
||||
}
|
||||
|
||||
|
||||
|
@ -23,6 +23,7 @@ namespace irr
|
||||
#include "IMaterialRendererServices.h"
|
||||
// also includes the OpenGL stuff
|
||||
#include "COpenGLExtensionHandler.h"
|
||||
#include "COpenGLTexture.h"
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_CG_
|
||||
#include "Cg/cg.h"
|
||||
@ -344,7 +345,8 @@ namespace video
|
||||
virtual u32 getMaximalPrimitiveCount() const;
|
||||
|
||||
virtual ITexture* addRenderTargetTexture(const core::dimension2d<u32>& size,
|
||||
const io::path& name, const ECOLOR_FORMAT format = ECF_UNKNOWN);
|
||||
const io::path& name, const ECOLOR_FORMAT format = ECF_UNKNOWN,
|
||||
const bool useStencil = false);
|
||||
|
||||
//! set or reset render target
|
||||
virtual bool setRenderTarget(video::E_RENDER_TARGET target, bool clearTarget,
|
||||
@ -390,7 +392,8 @@ namespace video
|
||||
//! Returns the maximum texture size supported.
|
||||
virtual core::dimension2du getMaxTextureSize() const;
|
||||
|
||||
ITexture* createDepthTexture(ITexture* texture, bool shared=true);
|
||||
ITexture* createDepthTexture(ITexture* texture, const bool useStencil = false,
|
||||
const bool shared = true);
|
||||
void removeDepthTexture(ITexture* texture);
|
||||
|
||||
//! Removes a texture from the texture cache and deletes it, freeing lot of memory.
|
||||
@ -543,7 +546,7 @@ namespace video
|
||||
}
|
||||
};
|
||||
STextureStageCache CurrentTexture;
|
||||
core::array<ITexture*> DepthTextures;
|
||||
core::array<COpenGLFBODepthTexture*> DepthTextures;
|
||||
struct SUserClipPlane
|
||||
{
|
||||
SUserClipPlane() : Enabled(false) {}
|
||||
|
@ -893,6 +893,11 @@ void COpenGLFBODepthTexture::unbindRTT()
|
||||
{
|
||||
}
|
||||
|
||||
bool COpenGLFBODepthTexture::hasStencil()
|
||||
{
|
||||
return UseStencil;
|
||||
}
|
||||
|
||||
|
||||
bool checkFBOStatus(COpenGLDriver* Driver)
|
||||
{
|
||||
|
@ -190,6 +190,8 @@ public:
|
||||
|
||||
bool attach(ITexture*);
|
||||
|
||||
bool hasStencil();
|
||||
|
||||
protected:
|
||||
GLuint DepthRenderBuffer;
|
||||
GLuint StencilRenderBuffer;
|
||||
|
Loading…
Reference in New Issue
Block a user