mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-28 15:02:39 +00:00
- added workarounds for the invulnerability colormap for non-shader rendering. Unlike the shader based versions these do not decolorize the screen. The advantage to the old texture duplication is that this is far less stressful on performance.
This commit is contained in:
parent
913e3df7e3
commit
924b72b633
3 changed files with 71 additions and 23 deletions
|
@ -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);
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue