mirror of
https://github.com/ZDoom/gzdoom-last-svn.git
synced 2025-05-30 17:00:48 +00:00
- changed the screen wipe code to use the global render state instead of disabling it and doing its own thing.
- fixed: When a hardware texture gets deleted it must unbind itself from all texture units. Otherwise the code may assume that a deleted texture is still bound. This was most obvious with the burn wiper if it was called twice in a row with no textures being created in between. - fixed: The render state must be applied for a sky dome's cap and the actual walls separately. - fixed: Light on side calculation for shader based dynamic lights on 3D floors was wrong. git-svn-id: http://mancubus.net/svn/hosted/gzdoom/trunk@538 b0f79afe-0144-0410-b225-9a4edf0717df
This commit is contained in:
parent
cbeab447fd
commit
a3df4aba14
10 changed files with 46 additions and 32 deletions
|
@ -116,18 +116,6 @@ void FGLRenderer::SetupLevel()
|
|||
mVBO->CreateVBO();
|
||||
}
|
||||
|
||||
|
||||
void FGLRenderer::SetPaused()
|
||||
{
|
||||
mShaderManager->SetActiveShader(NULL);
|
||||
gl_RenderState.SetTextureMode(-1); // something invalid
|
||||
}
|
||||
|
||||
void FGLRenderer::UnsetPaused()
|
||||
{
|
||||
gl_RenderState.SetTextureMode(TM_MODULATE);
|
||||
}
|
||||
|
||||
void FGLRenderer::Begin2D()
|
||||
{
|
||||
gl_RenderState.EnableFog(false);
|
||||
|
|
|
@ -95,8 +95,6 @@ public:
|
|||
void SetupView(fixed_t viewx, fixed_t viewy, fixed_t viewz, angle_t viewangle, bool mirror, bool planemirror);
|
||||
|
||||
void Initialize();
|
||||
void SetPaused();
|
||||
void UnsetPaused();
|
||||
|
||||
void CreateScene();
|
||||
void RenderScene(int recursion);
|
||||
|
|
|
@ -120,7 +120,8 @@ public:
|
|||
|
||||
void Reset()
|
||||
{
|
||||
mTextureEnabled = mBrightmapEnabled = mFogEnabled = mGlowEnabled = mLightEnabled = false;
|
||||
mTextureEnabled = true;
|
||||
mBrightmapEnabled = mFogEnabled = mGlowEnabled = mLightEnabled = false;
|
||||
ffTextureEnabled = ffFogEnabled = false;
|
||||
mSpecialEffect = ffSpecialEffect = EFF_NONE;
|
||||
mFogColor.d = ffFogColor.d = -1;
|
||||
|
|
|
@ -192,7 +192,7 @@ bool GLFlat::SetupSubsectorLights(bool lightsapplied, subsector_t * sub)
|
|||
}
|
||||
|
||||
p.Set(plane.plane);
|
||||
gl_GetLight(p, light, Colormap.colormap, true, foggy, lightdata);
|
||||
gl_GetLight(p, light, Colormap.colormap, false, foggy, lightdata);
|
||||
node = node->nextLight;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -165,7 +165,6 @@ static void RenderSkyHemisphere(int hemi)
|
|||
return;
|
||||
}
|
||||
|
||||
gl_RenderState.Apply(true);
|
||||
|
||||
// Draw the cap as one solid color polygon
|
||||
if (!foglayer)
|
||||
|
@ -173,6 +172,7 @@ static void RenderSkyHemisphere(int hemi)
|
|||
columns = 4 * (gl_sky_detail > 0 ? gl_sky_detail : 1);
|
||||
foglayer=true;
|
||||
gl_RenderState.EnableTexture(false);
|
||||
gl_RenderState.Apply(true);
|
||||
|
||||
|
||||
if (!secondlayer)
|
||||
|
@ -192,6 +192,7 @@ static void RenderSkyHemisphere(int hemi)
|
|||
}
|
||||
else
|
||||
{
|
||||
gl_RenderState.Apply(true);
|
||||
columns=4; // no need to do more!
|
||||
gl.Begin(GL_TRIANGLE_FAN);
|
||||
for(c = 0; c < columns; c++)
|
||||
|
|
|
@ -470,7 +470,7 @@ void FShaderManager::SetActiveShader(FShader *sh)
|
|||
|
||||
FShader *FShaderManager::BindEffect(int effect)
|
||||
{
|
||||
if (effect > 0 && effect <= NUM_EFFECTS)
|
||||
if (effect > 0 && effect <= NUM_EFFECTS && mEffectShaders[effect-1] != NULL)
|
||||
{
|
||||
mEffectShaders[effect-1]->Bind(0);
|
||||
return mEffectShaders[effect-1];
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
#include "vectors.h"
|
||||
|
||||
#include "gl/renderer/gl_renderer.h"
|
||||
#include "gl/renderer/gl_renderstate.h"
|
||||
#include "gl/system/gl_framebuffer.h"
|
||||
#include "gl/textures/gl_translate.h"
|
||||
#include "gl/textures/gl_material.h"
|
||||
|
@ -189,9 +190,10 @@ bool OpenGLFrameBuffer::WipeDo(int ticks)
|
|||
{
|
||||
return true;
|
||||
}
|
||||
// This code does all rendering itself so the renderer object needs to switch off
|
||||
// all its current settings
|
||||
GLRenderer->SetPaused();
|
||||
|
||||
gl_RenderState.EnableTexture(true);
|
||||
gl_RenderState.EnableFog(false);
|
||||
|
||||
bool done = ScreenWipe->Run(ticks, this);
|
||||
//DrawLetterbox();
|
||||
return done;
|
||||
|
@ -222,7 +224,6 @@ void OpenGLFrameBuffer::WipeCleanup()
|
|||
delete wipeendscreen;
|
||||
wipeendscreen = NULL;
|
||||
}
|
||||
GLRenderer->UnsetPaused();
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -260,7 +261,8 @@ bool OpenGLFrameBuffer::Wiper_Crossfade::Run(int ticks, OpenGLFrameBuffer *fb)
|
|||
{
|
||||
Clock += ticks;
|
||||
|
||||
gl.SetTextureMode(TM_OPAQUE);
|
||||
gl_RenderState.SetTextureMode(TM_OPAQUE);
|
||||
gl_RenderState.Apply();
|
||||
gl.Disable(GL_ALPHA_TEST);
|
||||
fb->wipestartscreen->Bind(0, CM_DEFAULT);
|
||||
gl.Color4f(1.f, 1.f, 1.f, 1.f);
|
||||
|
@ -288,7 +290,7 @@ bool OpenGLFrameBuffer::Wiper_Crossfade::Run(int ticks, OpenGLFrameBuffer *fb)
|
|||
gl.Vertex2i(fb->Width, fb->Height);
|
||||
gl.End();
|
||||
gl.Enable(GL_ALPHA_TEST);
|
||||
gl.SetTextureMode(TM_MODULATE);
|
||||
gl_RenderState.SetTextureMode(TM_MODULATE);
|
||||
|
||||
return Clock >= 32;
|
||||
}
|
||||
|
@ -325,7 +327,8 @@ bool OpenGLFrameBuffer::Wiper_Melt::Run(int ticks, OpenGLFrameBuffer *fb)
|
|||
{
|
||||
|
||||
// Draw the new screen on the bottom.
|
||||
gl.SetTextureMode(TM_OPAQUE);
|
||||
gl_RenderState.SetTextureMode(TM_OPAQUE);
|
||||
gl_RenderState.Apply();
|
||||
fb->wipeendscreen->Bind(0, CM_DEFAULT);
|
||||
gl.Color4f(1.f, 1.f, 1.f, 1.f);
|
||||
gl.Begin(GL_TRIANGLE_STRIP);
|
||||
|
@ -390,7 +393,7 @@ bool OpenGLFrameBuffer::Wiper_Melt::Run(int ticks, OpenGLFrameBuffer *fb)
|
|||
}
|
||||
}
|
||||
}
|
||||
gl.SetTextureMode(TM_MODULATE);
|
||||
gl_RenderState.SetTextureMode(TM_MODULATE);
|
||||
return done;
|
||||
}
|
||||
|
||||
|
@ -462,7 +465,8 @@ bool OpenGLFrameBuffer::Wiper_Burn::Run(int ticks, OpenGLFrameBuffer *fb)
|
|||
}
|
||||
|
||||
// Put the initial screen back to the buffer.
|
||||
gl.SetTextureMode(TM_OPAQUE);
|
||||
gl_RenderState.SetTextureMode(TM_OPAQUE);
|
||||
gl_RenderState.Apply();
|
||||
gl.Disable(GL_ALPHA_TEST);
|
||||
fb->wipestartscreen->Bind(0, CM_DEFAULT);
|
||||
gl.Color4f(1.f, 1.f, 1.f, 1.f);
|
||||
|
@ -477,7 +481,8 @@ bool OpenGLFrameBuffer::Wiper_Burn::Run(int ticks, OpenGLFrameBuffer *fb)
|
|||
gl.Vertex2i(fb->Width, fb->Height);
|
||||
gl.End();
|
||||
|
||||
gl.SetTextureMode(TM_MODULATE);
|
||||
gl_RenderState.SetTextureMode(TM_MODULATE);
|
||||
gl_RenderState.Apply(true);
|
||||
gl.ActiveTexture(GL_TEXTURE1);
|
||||
gl.Enable(GL_TEXTURE_2D);
|
||||
|
||||
|
|
|
@ -219,6 +219,26 @@ FHardwareTexture::FHardwareTexture(int _width, int _height, bool _mipmap, bool w
|
|||
}
|
||||
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// Deletes a texture id and unbinds it from the texture units
|
||||
//
|
||||
//===========================================================================
|
||||
void FHardwareTexture::DeleteTexture(unsigned int texid)
|
||||
{
|
||||
if (texid != 0)
|
||||
{
|
||||
for(int i = 0; i < MAX_TEXTURES; i++)
|
||||
{
|
||||
if (lastbound[i] == texid)
|
||||
{
|
||||
lastbound[i] = 0;
|
||||
}
|
||||
}
|
||||
gl.DeleteTextures(1, &texid);
|
||||
}
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// Frees all associated resources
|
||||
|
@ -232,7 +252,7 @@ void FHardwareTexture::Clean(bool all)
|
|||
{
|
||||
for (int i=0;i<cm_arraysize;i++)
|
||||
{
|
||||
if (glTexID[i]!=0) gl.DeleteTextures(1, &glTexID[i]);
|
||||
DeleteTexture(glTexID[i]);
|
||||
}
|
||||
//gl.DeleteTextures(cm_arraysize,glTexID);
|
||||
memset(glTexID,0,sizeof(unsigned int)*cm_arraysize);
|
||||
|
@ -241,14 +261,14 @@ void FHardwareTexture::Clean(bool all)
|
|||
{
|
||||
for (int i=1;i<cm_arraysize;i++)
|
||||
{
|
||||
if (glTexID[i]!=0) gl.DeleteTextures(1, &glTexID[i]);
|
||||
DeleteTexture(glTexID[i]);
|
||||
}
|
||||
//gl.DeleteTextures(cm_arraysize-1,glTexID+1);
|
||||
memset(glTexID+1,0,sizeof(unsigned int)*(cm_arraysize-1));
|
||||
}
|
||||
for(unsigned int i=0;i<glTexID_Translated.Size();i++)
|
||||
{
|
||||
gl.DeleteTextures(1,&glTexID_Translated[i].glTexID);
|
||||
DeleteTexture(glTexID_Translated[i].glTexID);
|
||||
}
|
||||
glTexID_Translated.Clear();
|
||||
if (glDepthID != 0) gl.DeleteRenderbuffers(1, &glDepthID);
|
||||
|
|
|
@ -58,6 +58,7 @@ private:
|
|||
unsigned * GetTexID(int cm, int translation);
|
||||
|
||||
int GetDepthBuffer();
|
||||
void DeleteTexture(unsigned int texid);
|
||||
|
||||
public:
|
||||
FHardwareTexture(int w, int h, bool mip, bool wrap);
|
||||
|
|
|
@ -136,7 +136,7 @@ public:
|
|||
float C() { return m_normal.Z(); }
|
||||
float D() { return m_d; }
|
||||
|
||||
Vector Normal() { return m_normal; }
|
||||
const Vector &Normal() const { return m_normal; }
|
||||
protected:
|
||||
Vector m_normal;
|
||||
float m_d;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue