diff --git a/src/gl/compatibility/gl_20.cpp b/src/gl/compatibility/gl_20.cpp index e27a6fd43a..fc171686bf 100644 --- a/src/gl/compatibility/gl_20.cpp +++ b/src/gl/compatibility/gl_20.cpp @@ -262,25 +262,6 @@ void FRenderState::ApplyFixedFunction() FStateVec4 col = mColor; - if (mColormapState == CM_LITE) - { - if (gl_enhanced_nightvision) - { - col.vec[0] = 0.375f, col.vec[1] = 1.0f, col.vec[2] = 0.375f; - } - else - { - col.vec[0] = col.vec[1] = col.vec[2] = 1.f; - } - } - else if (mColormapState >= CM_TORCH) - { - int flicker = mColormapState - CM_TORCH; - col.vec[0] = (0.8f + (7 - flicker) / 70.0f); - if (col.vec[0] > 1.0f) col.vec[0] = 1.0f; - col.vec[1] = col.vec[2] = col.vec[0]; - if (gl_enhanced_nightvision) col.vec[0] = col.vec[0] * 0.75f; - } col.vec[0] += mDynColor.vec[0]; col.vec[1] += mDynColor.vec[1]; col.vec[2] += mDynColor.vec[2]; @@ -309,3 +290,58 @@ void FRenderState::ApplyFixedFunction() } } + +void gl_FillScreen(); + +void FRenderState::DrawColormapOverlay() +{ + float r, g, b; + if (mColormapState > CM_DEFAULT && mColormapState < CM_MAXCOLORMAP) + { + FSpecialColormap *scm = &SpecialColormaps[gl_fixedcolormap - CM_FIRSTSPECIALCOLORMAP]; + float m[] = { scm->ColorizeEnd[0] - scm->ColorizeStart[0], + scm->ColorizeEnd[1] - scm->ColorizeStart[1], scm->ColorizeEnd[2] - scm->ColorizeStart[2], 0.f }; + + if (m[0] < 0 && m[1] < 0 && m[2] < 0) + { + gl_RenderState.SetColor(1, 1, 1, 1); + gl_RenderState.BlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ZERO); + gl_FillScreen(); + + r = scm->ColorizeStart[0]; + g = scm->ColorizeStart[1]; + b = scm->ColorizeStart[2]; + } + else + { + r = scm->ColorizeEnd[0]; + g = scm->ColorizeEnd[1]; + b = scm->ColorizeEnd[2]; + } + } + else if (mColormapState == CM_LITE) + { + if (gl_enhanced_nightvision) + { + r = 0.375f, g = 1.0f, b = 0.375f; + } + else + { + return; + } + } + else if (mColormapState >= CM_TORCH) + { + int flicker = mColormapState - CM_TORCH; + r = (0.8f + (7 - flicker) / 70.0f); + if (r > 1.0f) r = 1.0f; + b = g = r; + if (gl_enhanced_nightvision) b = g * 0.75f; + } + else return; + + gl_RenderState.SetColor(r, g, b, 1.f); + gl_RenderState.BlendFunc(GL_DST_COLOR, GL_ZERO); + gl_FillScreen(); + gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); +} \ No newline at end of file diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index f5df3b78cb..04142a5827 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -317,6 +317,11 @@ public: mColormapState = cm; } + int GetFixedColormap() + { + return mColormapState; + } + PalEntry GetFogColor() const { return mFogColor; @@ -397,7 +402,7 @@ public: // Backwards compatibility crap follows void ApplyFixedFunction(); - + void DrawColormapOverlay(); }; extern FRenderState gl_RenderState; diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 7062f0cb60..8a7a882bc2 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -524,7 +524,7 @@ void FGLRenderer::DrawScene(bool toscreen) } -static void FillScreen() +void gl_FillScreen() { gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); gl_RenderState.EnableTexture(false); @@ -629,7 +629,7 @@ void FGLRenderer::DrawBlend(sector_t * viewsector) { gl_RenderState.BlendFunc(GL_DST_COLOR, GL_ZERO); gl_RenderState.SetColor(extra_red, extra_green, extra_blue, 1.0f); - FillScreen(); + gl_FillScreen(); } } else if (blendv.a) @@ -659,7 +659,7 @@ void FGLRenderer::DrawBlend(sector_t * viewsector) { gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); gl_RenderState.SetColor(blend[0], blend[1], blend[2], blend[3]); - FillScreen(); + gl_FillScreen(); } } @@ -696,10 +696,17 @@ void FGLRenderer::EndDrawScene(sector_t * viewsector) { DrawPlayerSprites (viewsector, false); } + int cm = gl_RenderState.GetFixedColormap(); gl_RenderState.SetFixedColormap(CM_DEFAULT); gl_RenderState.SetSoftLightLevel(-1); DrawTargeterSprites(); DrawBlend(viewsector); + if (gl.glslversion == 0.0) + { + gl_RenderState.SetFixedColormap(cm); + gl_RenderState.DrawColormapOverlay(); + gl_RenderState.SetFixedColormap(CM_DEFAULT); + } // Restore standard rendering state gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);