diff --git a/src/gl/scene/gl_drawinfo.h b/src/gl/scene/gl_drawinfo.h index f4b1043923..780be6f368 100644 --- a/src/gl/scene/gl_drawinfo.h +++ b/src/gl/scene/gl_drawinfo.h @@ -15,8 +15,8 @@ enum DrawListType { GLDL_PLAIN, GLDL_MASKED, - GLDL_FOG, - GLDL_FOGMASKED, + GLDL_MASKEDOFS, + GLDL_MODELS, GLDL_TRANSLUCENT, GLDL_TRANSLUCENTBORDER, @@ -96,6 +96,11 @@ public: Reset(); } + unsigned int Size() + { + return drawitems.Size(); + } + void AddWall(GLWall * wall); void AddFlat(GLFlat * flat); void AddSprite(GLSprite * sprite); diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 110a364203..1d1cfd29c7 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -376,6 +376,18 @@ void FGLRenderer::RenderScene(int recursion) gl_drawinfo->drawlists[GLDL_MASKED].Sort(); gl_drawinfo->drawlists[GLDL_MASKED].Draw(pass); + // this list is empty most of the time so only waste time on it when in use. + if (gl_drawinfo->drawlists[GLDL_MASKEDOFS].Size() > 0) + { + glEnable(GL_POLYGON_OFFSET_FILL); + glPolygonOffset(-1.0f, -128.0f); + gl_drawinfo->drawlists[GLDL_MASKEDOFS].Sort(); + gl_drawinfo->drawlists[GLDL_MASKEDOFS].Draw(pass); + glDisable(GL_POLYGON_OFFSET_FILL); + glPolygonOffset(0, 0); + } + + gl_drawinfo->drawlists[GLDL_MODELS].Draw(pass); gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 554b8ff1f5..9ce6856b09 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -315,13 +315,9 @@ inline void GLSprite::PutSprite(bool translucent) { list = GLDL_TRANSLUCENT; } - else if ((!gl_isBlack (Colormap.FadeColor) || level.flags&LEVEL_HASFADETABLE)) - { - list = GLDL_FOGMASKED; - } else { - list = GLDL_MASKED; + list = GLDL_MODELS; } gl_drawinfo->drawlists[list].AddSprite(this); } diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index fe2ec6e8e0..fafd5ccb85 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -97,11 +97,9 @@ public: //GLWF_CLAMPX=1, use GLT_* for these! //GLWF_CLAMPY=2, GLWF_SKYHACK=4, - GLWF_FOGGY=8, - GLWF_GLOW=16, // illuminated by glowing flats - GLWF_NOSHADER=32, // cannot be drawn with shaders. - GLWF_NOSPLITUPPER=64, - GLWF_NOSPLITLOWER=128, + GLWF_GLOW=8, // illuminated by glowing flats + GLWF_NOSPLITUPPER=16, + GLWF_NOSPLITLOWER=32, }; enum diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index 60e9287bf6..e665eeb894 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -148,14 +148,22 @@ void GLWall::PutWall(bool translucent) bool masked; masked = passflag[type]==1? false : (gltexture && gltexture->isMasked()); - list = masked ? GLDL_MASKED : GLDL_PLAIN; + + if ((flags&GLWF_SKYHACK && type == RENDERWALL_M2S)) + { + list = GLDL_MASKEDOFS; + } + else + { + list = masked ? GLDL_MASKED : GLDL_PLAIN; + } gl_drawinfo->drawlists[list].AddWall(this); } else switch (type) { case RENDERWALL_COLORLAYER: - gl_drawinfo->drawlists[GLDL_TRANSLUCENT].AddWall(this); + gl_drawinfo->drawlists[GLDL_TRANSLUCENTBORDER].AddWall(this); break; // portals don't go into the draw list. diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index 8cdae097a2..932451298e 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -369,14 +369,10 @@ void GLWall::Draw(int pass) #endif - // This allows mid textures to be drawn on lines that might overlap a sky wall - if ((flags&GLWF_SKYHACK && type==RENDERWALL_M2S) || type == RENDERWALL_COLORLAYER) + if (type == RENDERWALL_COLORLAYER) { - if (pass != GLPASS_DECALS) - { - glEnable(GL_POLYGON_OFFSET_FILL); - glPolygonOffset(-1.0f, -128.0f); - } + glEnable(GL_POLYGON_OFFSET_FILL); + glPolygonOffset(-1.0f, -128.0f); } switch (pass) @@ -426,12 +422,9 @@ void GLWall::Draw(int pass) } } - if ((flags&GLWF_SKYHACK && type==RENDERWALL_M2S) || type == RENDERWALL_COLORLAYER) + if (type == RENDERWALL_COLORLAYER) { - if (pass!=GLPASS_DECALS) - { - glDisable(GL_POLYGON_OFFSET_FILL); - glPolygonOffset(0, 0); - } + glDisable(GL_POLYGON_OFFSET_FILL); + glPolygonOffset(0, 0); } }