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
|
uint32 cubeFace = 0
|
||||||
) = 0 ;
|
) = 0 ;
|
||||||
|
|
||||||
|
virtual ITexture *getRenderTarget() const = 0;
|
||||||
|
|
||||||
/** Trick method : copy the current texture target into another texture without updating the current texture.
|
/** Trick method : copy the current texture target into another texture without updating the current texture.
|
||||||
*
|
*
|
||||||
* This method copies the current texture into another texture.
|
* This method copies the current texture into another texture.
|
||||||
|
|
|
@ -855,6 +855,7 @@ public:
|
||||||
// todo hulud d3d buffers
|
// todo hulud d3d buffers
|
||||||
virtual void getZBufferPart (std::vector<float> &zbuffer, NLMISC::CRect &rect);
|
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 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,
|
virtual bool copyTargetToTexture (ITexture *tex, uint32 offsetx, uint32 offsety, uint32 x, uint32 y, uint32 width,
|
||||||
uint32 height, uint32 mipmapLevel);
|
uint32 height, uint32 mipmapLevel);
|
||||||
virtual bool getRenderTargetSize (uint32 &width, uint32 &height);
|
virtual bool getRenderTargetSize (uint32 &width, uint32 &height);
|
||||||
|
|
|
@ -1187,6 +1187,11 @@ bool CDriverD3D::setRenderTarget (ITexture *tex, uint32 /* x */, uint32 /* y */,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ITexture *CDriverD3D::getRenderTarget() const
|
||||||
|
{
|
||||||
|
return _RenderTarget.Texture;
|
||||||
|
}
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
|
|
||||||
bool CDriverD3D::copyTargetToTexture (ITexture * /* tex */, uint32 /* offsetx */, uint32 /* offsety */, uint32 /* x */, uint32 /* y */, uint32 /* width */,
|
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[2]= 0;
|
||||||
_CurrentFogColor[3]= 0;
|
_CurrentFogColor[3]= 0;
|
||||||
|
|
||||||
_RenderTargetFBO = false;
|
|
||||||
|
|
||||||
_LightSetupDirty= false;
|
_LightSetupDirty= false;
|
||||||
_ModelViewMatrixDirty= false;
|
_ModelViewMatrixDirty= false;
|
||||||
_RenderSetupDirty= false;
|
_RenderSetupDirty= false;
|
||||||
|
|
|
@ -564,6 +564,8 @@ public:
|
||||||
virtual bool setRenderTarget (ITexture *tex, uint32 x, uint32 y, uint32 width, uint32 height,
|
virtual bool setRenderTarget (ITexture *tex, uint32 x, uint32 y, uint32 width, uint32 height,
|
||||||
uint32 mipmapLevel, uint32 cubeFace);
|
uint32 mipmapLevel, uint32 cubeFace);
|
||||||
|
|
||||||
|
virtual ITexture *getRenderTarget() const;
|
||||||
|
|
||||||
virtual bool copyTargetToTexture (ITexture *tex, uint32 offsetx, uint32 offsety, uint32 x, uint32 y,
|
virtual bool copyTargetToTexture (ITexture *tex, uint32 offsetx, uint32 offsety, uint32 x, uint32 y,
|
||||||
uint32 width, uint32 height, uint32 mipmapLevel);
|
uint32 width, uint32 height, uint32 mipmapLevel);
|
||||||
|
|
||||||
|
@ -889,7 +891,7 @@ private:
|
||||||
// viewport before call to setRenderTarget, if BFO extension is supported
|
// viewport before call to setRenderTarget, if BFO extension is supported
|
||||||
CViewport _OldViewport;
|
CViewport _OldViewport;
|
||||||
|
|
||||||
bool _RenderTargetFBO;
|
CSmartPtr<ITexture> _RenderTargetFBO;
|
||||||
|
|
||||||
|
|
||||||
// Num lights return by GL_MAX_LIGHTS
|
// 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));
|
newVP.init(0, 0, ((float)width/(float)w), ((float)height/(float)h));
|
||||||
setupViewport(newVP);
|
setupViewport(newVP);
|
||||||
|
|
||||||
_RenderTargetFBO = true;
|
_RenderTargetFBO = tex;
|
||||||
|
|
||||||
return activeFrameBufferObject(tex);
|
return activeFrameBufferObject(tex);
|
||||||
}
|
}
|
||||||
|
@ -2334,7 +2334,7 @@ bool CDriverGL::setRenderTarget (ITexture *tex, uint32 x, uint32 y, uint32 width
|
||||||
setupViewport(_OldViewport);
|
setupViewport(_OldViewport);
|
||||||
_OldViewport = _CurrViewport;
|
_OldViewport = _CurrViewport;
|
||||||
|
|
||||||
_RenderTargetFBO = false;
|
_RenderTargetFBO = NULL;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2347,12 +2347,17 @@ bool CDriverGL::setRenderTarget (ITexture *tex, uint32 x, uint32 y, uint32 width
|
||||||
// Update the scissor
|
// Update the scissor
|
||||||
setupScissor (_CurrScissor);
|
setupScissor (_CurrScissor);
|
||||||
|
|
||||||
_RenderTargetFBO = false;
|
_RenderTargetFBO = NULL;
|
||||||
_OldViewport = _CurrViewport;
|
_OldViewport = _CurrViewport;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ITexture *CDriverGL::getRenderTarget() const
|
||||||
|
{
|
||||||
|
return _RenderTargetFBO ? _RenderTargetFBO : _TextureTarget;
|
||||||
|
}
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
|
|
||||||
bool CDriverGL::copyTargetToTexture (ITexture *tex,
|
bool CDriverGL::copyTargetToTexture (ITexture *tex,
|
||||||
|
|
|
@ -244,11 +244,12 @@ void CShadowMapManager::addShadowReceiver(CTransform *model)
|
||||||
void CShadowMapManager::renderGenerate(CScene *scene)
|
void CShadowMapManager::renderGenerate(CScene *scene)
|
||||||
{
|
{
|
||||||
H_AUTO( NL3D_ShadowManager_Generate );
|
H_AUTO( NL3D_ShadowManager_Generate );
|
||||||
|
|
||||||
// Each frame, do a small garbage collector for unused free textures.
|
// Each frame, do a small garbage collector for unused free textures.
|
||||||
garbageShadowTextures(scene);
|
garbageShadowTextures(scene);
|
||||||
|
|
||||||
IDriver *driverForShadowGeneration= scene->getRenderTrav().getAuxDriver();
|
IDriver *driverForShadowGeneration= scene->getRenderTrav().getAuxDriver();
|
||||||
|
CSmartPtr<NL3D::ITexture> previousRenderTarget = driverForShadowGeneration->getRenderTarget();
|
||||||
|
|
||||||
// Init
|
// Init
|
||||||
// ********
|
// ********
|
||||||
|
@ -488,7 +489,7 @@ void CShadowMapManager::renderGenerate(CScene *scene)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set default render target
|
// Set default render target
|
||||||
driverForShadowGeneration->setRenderTarget (NULL);
|
driverForShadowGeneration->setRenderTarget (previousRenderTarget);
|
||||||
|
|
||||||
// Allow Writing on all.
|
// Allow Writing on all.
|
||||||
driverForShadowGeneration->setColorMask(true, true, true, true);
|
driverForShadowGeneration->setColorMask(true, true, true, true);
|
||||||
|
|
Loading…
Reference in a new issue