- enable palette emulation for HUD weapon drawing.

Not correct yet but the basics are in.
This commit is contained in:
Christoph Oelckers 2020-09-13 23:14:44 +02:00
parent 1368c26d22
commit c61a2c3486
7 changed files with 27 additions and 5 deletions

View file

@ -410,9 +410,15 @@ void F2DDrawer::AddTexture(FGameTexture* img, DrawParms& parms)
dg.mVertCount = 4;
dg.mTexture = img;
if (img->isWarped()) dg.mFlags |= DTF_Wrap;
if (parms.indexed) dg.mFlags |= DTF_Indexed;
dg.mTranslationId = 0;
SetStyle(img, parms, vertexcolor, dg);
if (parms.indexed)
{
dg.mLightLevel = vertexcolor.Luminance();
vertexcolor = 0xffffffff;
}
if (!img->isHardwareCanvas() && parms.TranslationId != -1)
{

View file

@ -84,6 +84,7 @@ public:
DTF_Wrap = 1,
DTF_Scissor = 2,
DTF_Burn = 4,
DTF_Indexed = 8,
};

View file

@ -674,6 +674,7 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double
parms->viewport = { 0,0,drawer->GetWidth(), drawer->GetHeight() };
parms->rotateangle = 0;
parms->flipoffsets = false;
parms->indexed = false;
// Parse the tag list for attributes. (For floating point attributes,
// consider that the C ABI dictates that all floats be promoted to
@ -1126,6 +1127,10 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double
if (fortext) return false;
parms->rotateangle = ListGetDouble(tags);
break;
case DTA_Indexed:
parms->indexed = !!ListGetInt(tags);
break;
}
tag = ListGetInt(tags);
}

View file

@ -129,6 +129,7 @@ enum
DTA_Pin, // Pin a non-widescreen image to the left/right edge of the screen.
DTA_Rotate,
DTA_FlipOffsets, // Flips offsets when using DTA_FlipX and DTA_FlipY, this cannot be automatic due to unexpected behavior with unoffsetted graphics.
DTA_Indexed, // Use an indexed texture combined with the given translation.
};
@ -195,6 +196,7 @@ struct DrawParms
bool virtBottom;
bool burn;
bool flipoffsets;
bool indexed;
int8_t fsscalemode;
double srcx, srcy;
double srcwidth, srcheight;

View file

@ -169,13 +169,17 @@ void Draw2D(F2DDrawer *drawer, FRenderState &state)
}
state.SetFog(cmd.mColor1, 0);
state.SetColor(1, 1, 1, 1, cmd.mDesaturate);
state.SetSoftLightLevel(cmd.mLightLevel);
state.SetLightParms(0, 0);
state.AlphaFunc(Alpha_GEqual, 0.f);
if (cmd.mTexture != nullptr && cmd.mTexture->isValid())
{
auto flags = cmd.mTexture->GetUseType() >= ETextureType::Special? UF_None : cmd.mTexture->GetUseType() == ETextureType::FontChar? UF_Font : UF_Texture;
state.SetMaterial(cmd.mTexture, flags, 0, cmd.mFlags & F2DDrawer::DTF_Wrap ? CLAMP_NONE : CLAMP_XY_NOMIP, cmd.mTranslationId, -1);
auto scaleflags = cmd.mFlags & F2DDrawer::DTF_Indexed ? CTF_Indexed : 0;
state.SetMaterial(cmd.mTexture, flags, scaleflags, cmd.mFlags & F2DDrawer::DTF_Wrap ? CLAMP_NONE : CLAMP_XY_NOMIP, cmd.mTranslationId, -1);
state.EnableTexture(true);
// Canvas textures are stored upside down

View file

@ -83,7 +83,7 @@ bool GLInstance::SetTexture(int picnum, FGameTexture* tex, int paletteid, int sa
SetBasepalTint(texpick.basepalTint);
auto &mat = renderState.mMaterial;
int flags = (!notindexed && hw_useindexedcolortextures) ? CTF_Indexed : 0;
int flags = (TextureType == TT_INDEXED) ? CTF_Indexed : 0;
mat.mMaterial = FMaterial::ValidateTexture(texpick.texture, flags); // todo allow scaling
mat.mClampMode = sampler;
mat.mTranslation = texpick.translation;

View file

@ -166,7 +166,6 @@ void PolymostRenderState::Apply(FRenderState& state, GLState& oldState)
state.EnableTexture(gl_texture);
state.SetMaterial(mMaterial.mMaterial, mMaterial.mClampMode, mMaterial.mTranslation, mMaterial.mOverrideShader);
}
/* todo: bind indexed textures */
state.SetColor(Color[0], Color[1], Color[2], Color[3]);
if (StateFlags != oldState.Flags)
@ -548,11 +547,14 @@ void hud_drawsprite(double sx, double sy, int z, double a, int picnum, int dasha
{
double dz = z / 65536.;
alpha *= (dastat & RS_TRANS1)? glblend[0].def[!!(dastat & RS_TRANS2)].alpha : 1.;
TexturePick pick;
int palid = TRANSLATION(Translation_Remap + curbasepal, dapalnum);
if (!PickTexture(picnum, nullptr, palid, pick)) return;
DrawTexture(&twodpsp, tileGetTexture(picnum, true), sx, sy,
DrawTexture(&twodpsp, pick.texture, sx, sy,
DTA_ScaleX, dz, DTA_ScaleY, dz,
DTA_Color, shadeToLight(dashade),
DTA_TranslationIndex, TRANSLATION(Translation_Remap + curbasepal, dapalnum),
DTA_TranslationIndex, pick.translation,
DTA_ViewportX, windowxy1.x, DTA_ViewportY, windowxy1.y,
DTA_ViewportWidth, windowxy2.x - windowxy1.x + 1, DTA_ViewportHeight, windowxy2.y - windowxy1.y + 1,
DTA_FullscreenScale, (dastat & RS_STRETCH)? FSMode_ScaleToScreen: FSMode_ScaleToHeight, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200,
@ -565,6 +567,8 @@ void hud_drawsprite(double sx, double sy, int z, double a, int picnum, int dasha
DTA_Rotate, a * (-360./2048),
DTA_FlipOffsets, !(dastat & (/*RS_TOPLEFT |*/ RS_CENTER)),
DTA_Alpha, alpha,
DTA_Indexed, !!(pick.translation & 0x80000000),
// todo: pass pick.tintFlags and pick.tintColor
TAG_DONE);
}