1
1
forked from 0ad/0ad

# Fixed self-shadowing in Atlas

(The ShadowMap object was being destroyed/recreated, and thus forgot
that it had been told to use depth textures)

This was SVN commit r3916.
This commit is contained in:
Ykkrosh 2006-05-31 16:42:50 +00:00
parent 5eef6f4951
commit a9dfb016ca
3 changed files with 25 additions and 3 deletions

View File

@ -530,8 +530,7 @@ bool CRenderer::Open(int width, int height, int depth)
void CRenderer::Resize(int width,int height)
{
// need to recreate the shadow map object to resize the shadow texture
delete m->shadow;
m->shadow = new ShadowMap;
m->shadow->RecreateTexture();
m_Width = width;
m_Height = height;

View File

@ -96,6 +96,22 @@ ShadowMap::~ShadowMap()
delete m;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
// Force the texture/buffer/etc to be recreated, particularly when the renderer's
// size has changed
void ShadowMap::RecreateTexture()
{
if (m->Texture)
glDeleteTextures(1, &m->Texture);
if (m->Framebuffer)
pglDeleteFramebuffersEXT(1, &m->Framebuffer);
m->Texture = 0;
m->Framebuffer = 0;
// (Texture will be constructed in next SetupFrame)
}
//////////////////////////////////////////////////////////////////////////////
// SetupFrame: camera and light direction for this frame
void ShadowMap::SetupFrame(const CCamera& camera, const CVector3D& lightdir)
@ -234,7 +250,7 @@ void ShadowMapInternals::CalcShadowMatrices()
///////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
// Create the shadow map
void ShadowMapInternals::CreateTexture()
{

View File

@ -35,6 +35,13 @@ public:
ShadowMap();
~ShadowMap();
/**
* RecreateTexture: Destroy the current shadow texture and force creation of
* a new one. Useful when the renderer's size has changed and the texture
* should be resized too.
*/
void RecreateTexture();
/**
* GetUseDepthTexture: Return whether rendering uses a depth texture (instead of
* a luminance texture).