- made DTA_SpecialColormap work, both for GL3+ and GL2 render paths.

This will only be used for HUD sprites. At the moment it will ignore sprite translations, though, when running in OpenGL 2 legacy mode.
This commit is contained in:
Christoph Oelckers 2018-03-30 21:14:49 +02:00
parent 832df6d43a
commit 00c66f42d3
3 changed files with 18 additions and 9 deletions

View file

@ -14,6 +14,7 @@ enum EColorManipulation
CM_INVALID=-1,
CM_DEFAULT=0, // untranslated
CM_FIRSTSPECIALCOLORMAP, // first special fixed colormap
CM_FIRSTSPECIALCOLORMAPFORCED= 0x08000000, // first special fixed colormap, application forced (for 2D overlays)
CM_FOGLAYER = 0x10000000, // Sprite shaped fog layer
@ -23,6 +24,7 @@ enum EColorManipulation
};
#define CM_MAXCOLORMAP int(CM_FIRSTSPECIALCOLORMAP + SpecialColormaps.Size())
#define CM_MAXCOLORMAPFORCED int(CM_FIRSTSPECIALCOLORMAPFORCED + SpecialColormaps.Size())
#endif

View file

@ -546,7 +546,7 @@ void FGLRenderer::Draw2D(F2DDrawer *drawer)
if (index < 0 || (unsigned)index >= SpecialColormaps.Size()) index = 0; // if it isn't in the table FBitmap cannot use it. Shouldn't happen anyway.
if (!gl.legacyMode)
{
gl_RenderState.SetFixedColormap(CM_FIRSTSPECIALCOLORMAP + int(index));
gl_RenderState.SetFixedColormap(CM_FIRSTSPECIALCOLORMAPFORCED + int(index));
}
else
{

View file

@ -253,9 +253,9 @@ bool FRenderState::ApplyShader()
{
activeShader->muFixedColormap.Set(0);
}
else if (mColormapState > CM_DEFAULT && mColormapState < CM_MAXCOLORMAP)
else if ((mColormapState >= CM_FIRSTSPECIALCOLORMAP && mColormapState < CM_MAXCOLORMAPFORCED))
{
if (FGLRenderBuffers::IsEnabled())
if (FGLRenderBuffers::IsEnabled() && mColormapState < CM_FIRSTSPECIALCOLORMAPFORCED)
{
// When using postprocessing to apply the colormap, we must render the image fullbright here.
activeShader->muFixedColormap.Set(2);
@ -263,13 +263,20 @@ bool FRenderState::ApplyShader()
}
else
{
FSpecialColormap *scm = &SpecialColormaps[mColormapState - 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 (mColormapState >= CM_FIRSTSPECIALCOLORMAPFORCED)
{
auto colormapState = mColormapState + CM_FIRSTSPECIALCOLORMAP - CM_FIRSTSPECIALCOLORMAPFORCED;
if (colormapState < CM_MAXCOLORMAP)
{
FSpecialColormap *scm = &SpecialColormaps[colormapState - CM_FIRSTSPECIALCOLORMAP];
float m[] = { scm->ColorizeEnd[0] - scm->ColorizeStart[0],
scm->ColorizeEnd[1] - scm->ColorizeStart[1], scm->ColorizeEnd[2] - scm->ColorizeStart[2], 0.f };
activeShader->muFixedColormap.Set(1);
activeShader->muColormapStart.Set(scm->ColorizeStart[0], scm->ColorizeStart[1], scm->ColorizeStart[2], 0.f);
activeShader->muColormapRange.Set(m);
activeShader->muFixedColormap.Set(1);
activeShader->muColormapStart.Set(scm->ColorizeStart[0], scm->ColorizeStart[1], scm->ColorizeStart[2], 0.f);
activeShader->muColormapRange.Set(m);
}
}
}
}
else if (mColormapState == CM_FOGLAYER)