Fix a render target issue, see #43
This commit is contained in:
parent
ffc91631e7
commit
3b630492aa
7 changed files with 22 additions and 8 deletions
|
@ -859,6 +859,8 @@ public:
|
|||
uint32 cubeFace = 0
|
||||
) = 0 ;
|
||||
|
||||
virtual ITexture *getRenderTarget() const = 0;
|
||||
|
||||
/** Trick method : copy the current texture target into another texture without updating the current texture.
|
||||
*
|
||||
* This method copies the current texture into another texture.
|
||||
|
|
|
@ -855,6 +855,7 @@ public:
|
|||
// todo hulud d3d buffers
|
||||
virtual void getZBufferPart (std::vector<float> &zbuffer, NLMISC::CRect &rect);
|
||||
virtual bool setRenderTarget (ITexture *tex, uint32 x, uint32 y, uint32 width, uint32 height, uint32 mipmapLevel, uint32 cubeFace);
|
||||
virtual ITexture *getRenderTarget() const;
|
||||
virtual bool copyTargetToTexture (ITexture *tex, uint32 offsetx, uint32 offsety, uint32 x, uint32 y, uint32 width,
|
||||
uint32 height, uint32 mipmapLevel);
|
||||
virtual bool getRenderTargetSize (uint32 &width, uint32 &height);
|
||||
|
|
|
@ -1187,6 +1187,11 @@ bool CDriverD3D::setRenderTarget (ITexture *tex, uint32 /* x */, uint32 /* y */,
|
|||
return true;
|
||||
}
|
||||
|
||||
ITexture *CDriverD3D::getRenderTarget() const
|
||||
{
|
||||
return _RenderTarget.Texture;
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
|
||||
bool CDriverD3D::copyTargetToTexture (ITexture * /* tex */, uint32 /* offsetx */, uint32 /* offsety */, uint32 /* x */, uint32 /* y */, uint32 /* width */,
|
||||
|
|
|
@ -263,8 +263,6 @@ CDriverGL::CDriverGL()
|
|||
_CurrentFogColor[2]= 0;
|
||||
_CurrentFogColor[3]= 0;
|
||||
|
||||
_RenderTargetFBO = false;
|
||||
|
||||
_LightSetupDirty= false;
|
||||
_ModelViewMatrixDirty= false;
|
||||
_RenderSetupDirty= false;
|
||||
|
|
|
@ -564,6 +564,8 @@ public:
|
|||
virtual bool setRenderTarget (ITexture *tex, uint32 x, uint32 y, uint32 width, uint32 height,
|
||||
uint32 mipmapLevel, uint32 cubeFace);
|
||||
|
||||
virtual ITexture *getRenderTarget() const;
|
||||
|
||||
virtual bool copyTargetToTexture (ITexture *tex, uint32 offsetx, uint32 offsety, uint32 x, uint32 y,
|
||||
uint32 width, uint32 height, uint32 mipmapLevel);
|
||||
|
||||
|
@ -889,7 +891,7 @@ private:
|
|||
// viewport before call to setRenderTarget, if BFO extension is supported
|
||||
CViewport _OldViewport;
|
||||
|
||||
bool _RenderTargetFBO;
|
||||
CSmartPtr<ITexture> _RenderTargetFBO;
|
||||
|
||||
|
||||
// Num lights return by GL_MAX_LIGHTS
|
||||
|
|
|
@ -2314,7 +2314,7 @@ bool CDriverGL::setRenderTarget (ITexture *tex, uint32 x, uint32 y, uint32 width
|
|||
newVP.init(0, 0, ((float)width/(float)w), ((float)height/(float)h));
|
||||
setupViewport(newVP);
|
||||
|
||||
_RenderTargetFBO = true;
|
||||
_RenderTargetFBO = tex;
|
||||
|
||||
return activeFrameBufferObject(tex);
|
||||
}
|
||||
|
@ -2334,7 +2334,7 @@ bool CDriverGL::setRenderTarget (ITexture *tex, uint32 x, uint32 y, uint32 width
|
|||
setupViewport(_OldViewport);
|
||||
_OldViewport = _CurrViewport;
|
||||
|
||||
_RenderTargetFBO = false;
|
||||
_RenderTargetFBO = NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2347,12 +2347,17 @@ bool CDriverGL::setRenderTarget (ITexture *tex, uint32 x, uint32 y, uint32 width
|
|||
// Update the scissor
|
||||
setupScissor (_CurrScissor);
|
||||
|
||||
_RenderTargetFBO = false;
|
||||
_RenderTargetFBO = NULL;
|
||||
_OldViewport = _CurrViewport;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
ITexture *CDriverGL::getRenderTarget() const
|
||||
{
|
||||
return _RenderTargetFBO ? _RenderTargetFBO : _TextureTarget;
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
|
||||
bool CDriverGL::copyTargetToTexture (ITexture *tex,
|
||||
|
|
|
@ -249,6 +249,7 @@ void CShadowMapManager::renderGenerate(CScene *scene)
|
|||
garbageShadowTextures(scene);
|
||||
|
||||
IDriver *driverForShadowGeneration= scene->getRenderTrav().getAuxDriver();
|
||||
CSmartPtr<NL3D::ITexture> previousRenderTarget = driverForShadowGeneration->getRenderTarget();
|
||||
|
||||
// Init
|
||||
// ********
|
||||
|
@ -488,7 +489,7 @@ void CShadowMapManager::renderGenerate(CScene *scene)
|
|||
}
|
||||
|
||||
// Set default render target
|
||||
driverForShadowGeneration->setRenderTarget (NULL);
|
||||
driverForShadowGeneration->setRenderTarget (previousRenderTarget);
|
||||
|
||||
// Allow Writing on all.
|
||||
driverForShadowGeneration->setColorMask(true, true, true, true);
|
||||
|
|
Loading…
Reference in a new issue