From 43e2d704a3dbfb777445d88f6078a23c3e5ff90a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 20 Sep 2014 09:04:36 +0200 Subject: [PATCH] - always use glPolygonOffset to render translucent geometry. --- src/gl/dynlights/gl_lightbuffer.cpp | 15 ++++++++------- src/gl/scene/gl_walls_draw.cpp | 25 +++++++++++++------------ 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/gl/dynlights/gl_lightbuffer.cpp b/src/gl/dynlights/gl_lightbuffer.cpp index 1e0ec7e5a..a5b6ee9de 100644 --- a/src/gl/dynlights/gl_lightbuffer.cpp +++ b/src/gl/dynlights/gl_lightbuffer.cpp @@ -100,19 +100,20 @@ void FLightBuffer::Clear() int FLightBuffer::UploadLights(FDynLightData &data) { - unsigned int size0 = data.arrays[0].Size()/4; - unsigned int size1 = data.arrays[1].Size()/4; - unsigned int size2 = data.arrays[2].Size()/4; - unsigned int totalsize = size0 + size1 + size2 + 1; + int size0 = data.arrays[0].Size()/4; + int size1 = data.arrays[1].Size()/4; + int size2 = data.arrays[2].Size()/4; + int totalsize = size0 + size1 + size2 + 1; - if (mBlockAlign > 0 && totalsize + (mIndex % mBlockAlign) > mBlockSize) + // pointless type casting because some compilers can't print enough warnings. + if (mBlockAlign > 0 && (unsigned int)totalsize + (mIndex % mBlockAlign) > mBlockSize) { mIndex = ((mIndex + mBlockAlign) / mBlockAlign) * mBlockAlign; // can't be rendered all at once. - if (totalsize > mBlockSize) + if ((unsigned int)totalsize > mBlockSize) { - int diff = totalsize - mBlockSize; + int diff = totalsize - (int)mBlockSize; size2 -= diff; if (size2 < 0) diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index bad0aa5d1..1644c6605 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -238,7 +238,11 @@ void GLWall::RenderFogBoundary() gl_SetFog(lightlevel, rel, &Colormap, false); gl_RenderState.SetEffect(EFF_FOGBOUNDARY); gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); + glEnable(GL_POLYGON_OFFSET_FILL); + glPolygonOffset(-1.0f, -128.0f); RenderWall(RWF_BLANK); + glPolygonOffset(0.0f, 0.0f); + glDisable(GL_POLYGON_OFFSET_FILL); gl_RenderState.SetEffect(EFF_NONE); } } @@ -368,12 +372,6 @@ void GLWall::Draw(int pass) #endif - if (type == RENDERWALL_COLORLAYER && pass != GLPASS_LIGHTSONLY) - { - glEnable(GL_POLYGON_OFFSET_FILL); - glPolygonOffset(-1.0f, -128.0f); - } - switch (pass) { case GLPASS_LIGHTSONLY: @@ -396,6 +394,8 @@ void GLWall::Draw(int pass) break; case GLPASS_TRANSLUCENT: + + switch (type) { case RENDERWALL_MIRRORSURFACE: @@ -406,15 +406,16 @@ void GLWall::Draw(int pass) RenderFogBoundary(); break; + case RENDERWALL_COLORLAYER: + glEnable(GL_POLYGON_OFFSET_FILL); + glPolygonOffset(-1.0f, -128.0f); + RenderTranslucentWall(); + glDisable(GL_POLYGON_OFFSET_FILL); + glPolygonOffset(0, 0); + default: RenderTranslucentWall(); break; } } - - if (type == RENDERWALL_COLORLAYER && pass != GLPASS_LIGHTSONLY) - { - glDisable(GL_POLYGON_OFFSET_FILL); - glPolygonOffset(0, 0); - } }