mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-10 14:51:46 +00:00
- added colorization for untranslated fonts. This uses the light color of the vertices. The software rendered 2D code will ignore this infomation.
- added a virtual OnRetrun method to menus.
This commit is contained in:
parent
d36f656caf
commit
01b095c911
10 changed files with 53 additions and 7 deletions
|
@ -140,6 +140,7 @@ void F2DDrawer::AddTexture(FTexture *img, DrawParms &parms)
|
|||
color = PalEntry(light, light, light);
|
||||
}
|
||||
color.a = (uint8_t)(parms.Alpha * 255);
|
||||
color = PalEntry((color.a * parms.color.a) / 255, (color.r * parms.color.r) / 255, (color.g * parms.color.g) / 255, (color.b * parms.color.b) / 255);
|
||||
|
||||
// scissor test doesn't use the current viewport for the coordinates, so use real screen coordinates
|
||||
dg.mScissor[0] = GLRenderer->ScreenToWindowX(parms.lclip);
|
||||
|
|
|
@ -2773,6 +2773,12 @@ void OpenGLSWFrameBuffer::DrawTextureParms(FTexture *img, DrawParms &parms)
|
|||
|
||||
vert = &VertexData[VertexPos];
|
||||
|
||||
{
|
||||
PalEntry color = color1;
|
||||
color = PalEntry((color.a * parms.color.a) / 255, (color.r * parms.color.r) / 255, (color.g * parms.color.g) / 255, (color.b * parms.color.b) / 255);
|
||||
color1 = color;
|
||||
}
|
||||
|
||||
// Fill the vertex buffer.
|
||||
vert[0].x = float(x0);
|
||||
vert[0].y = float(y0);
|
||||
|
|
|
@ -243,6 +243,12 @@ void DMenu::Close ()
|
|||
if (CurrentMenu != nullptr)
|
||||
{
|
||||
GC::WriteBarrier(CurrentMenu);
|
||||
IFVIRTUALPTR(CurrentMenu, DMenu, OnReturn)
|
||||
{
|
||||
VMValue params[] = { CurrentMenu };
|
||||
GlobalVMStack.Call(func, params, 1, nullptr, 0, nullptr);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -366,6 +366,7 @@ bool DCanvas::ParseDrawTextureTags(FTexture *img, double x, double y, uint32_t t
|
|||
parms->colorOverlay = 0;
|
||||
parms->alphaChannel = false;
|
||||
parms->flipX = false;
|
||||
parms->color = 0xffffffff;
|
||||
//parms->shadowAlpha = 0;
|
||||
parms->shadowColor = 0;
|
||||
parms->virtWidth = this->GetWidth();
|
||||
|
@ -542,6 +543,10 @@ bool DCanvas::ParseDrawTextureTags(FTexture *img, double x, double y, uint32_t t
|
|||
parms->colorOverlay = ListGetInt(tags);
|
||||
break;
|
||||
|
||||
case DTA_Color:
|
||||
parms->color = ListGetInt(tags);
|
||||
break;
|
||||
|
||||
case DTA_FlipX:
|
||||
parms->flipX = ListGetInt(tags);
|
||||
break;
|
||||
|
|
|
@ -756,9 +756,18 @@ void FFont::BuildTranslations (const double *luminosity, const uint8_t *identity
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
FRemapTable *FFont::GetColorTranslation (EColorRange range) const
|
||||
FRemapTable *FFont::GetColorTranslation (EColorRange range, PalEntry *color) const
|
||||
{
|
||||
if (ActiveColors == 0 || noTranslate)
|
||||
if (noTranslate)
|
||||
{
|
||||
PalEntry retcolor = PalEntry(255, 255, 255, 255);
|
||||
if (range >= 0 && range < NumTextColors && range != CR_UNTRANSLATED)
|
||||
{
|
||||
retcolor = TranslationColors[range];
|
||||
}
|
||||
if (color != nullptr) *color = retcolor;
|
||||
}
|
||||
if (ActiveColors == 0)
|
||||
return NULL;
|
||||
else if (range >= NumTextColors)
|
||||
range = CR_UNTRANSLATED;
|
||||
|
|
|
@ -80,7 +80,7 @@ public:
|
|||
|
||||
virtual FTexture *GetChar (int code, int *const width) const;
|
||||
virtual int GetCharWidth (int code) const;
|
||||
FRemapTable *GetColorTranslation (EColorRange range) const;
|
||||
FRemapTable *GetColorTranslation (EColorRange range, PalEntry *color = nullptr) const;
|
||||
int GetLump() const { return Lump; }
|
||||
int GetSpaceWidth () const { return SpaceWidth; }
|
||||
int GetHeight () const { return FontHeight; }
|
||||
|
|
|
@ -80,7 +80,9 @@ void DCanvas::DrawChar (FFont *font, int normalcolor, double x, double y, int ch
|
|||
{
|
||||
return;
|
||||
}
|
||||
parms.remap = font->GetColorTranslation((EColorRange)normalcolor);
|
||||
PalEntry color;
|
||||
parms.remap = font->GetColorTranslation((EColorRange)normalcolor, &color);
|
||||
parms.color = PalEntry((color.a * parms.color.a) / 255, (color.r * parms.color.r) / 255, (color.g * parms.color.g) / 255, (color.b * parms.color.b) / 255);
|
||||
DrawTextureParms(pic, parms);
|
||||
}
|
||||
}
|
||||
|
@ -102,7 +104,9 @@ void DCanvas::DrawChar(FFont *font, int normalcolor, double x, double y, int cha
|
|||
uint32_t tag = ListGetInt(args);
|
||||
bool res = ParseDrawTextureTags(pic, x, y, tag, args, &parms, false);
|
||||
if (!res) return;
|
||||
parms.remap = font->GetColorTranslation((EColorRange)normalcolor);
|
||||
PalEntry color;
|
||||
parms.remap = font->GetColorTranslation((EColorRange)normalcolor, &color);
|
||||
parms.color = PalEntry((color.a * parms.color.a) / 255, (color.r * parms.color.r) / 255, (color.g * parms.color.g) / 255, (color.b * parms.color.b) / 255);
|
||||
DrawTextureParms(pic, parms);
|
||||
}
|
||||
}
|
||||
|
@ -151,7 +155,10 @@ void DCanvas::DrawTextCommon(FFont *font, int normalcolor, double x, double y, c
|
|||
normalcolor = CR_UNTRANSLATED;
|
||||
boldcolor = normalcolor ? normalcolor - 1 : NumTextColors - 1;
|
||||
|
||||
range = font->GetColorTranslation((EColorRange)normalcolor);
|
||||
PalEntry colorparm = parms.color;
|
||||
PalEntry color;
|
||||
range = font->GetColorTranslation((EColorRange)normalcolor, &color);
|
||||
parms.color = PalEntry((color.a * colorparm.a) / 255, (color.r * colorparm.r) / 255, (color.g * colorparm.g) / 255, (color.b * colorparm.b) / 255);
|
||||
|
||||
kerning = font->GetDefaultKerning();
|
||||
|
||||
|
@ -171,7 +178,8 @@ void DCanvas::DrawTextCommon(FFont *font, int normalcolor, double x, double y, c
|
|||
EColorRange newcolor = V_ParseFontColor(ch, normalcolor, boldcolor);
|
||||
if (newcolor != CR_UNDEFINED)
|
||||
{
|
||||
range = font->GetColorTranslation(newcolor);
|
||||
range = font->GetColorTranslation(newcolor, &color);
|
||||
parms.color = PalEntry((color.a * colorparm.a) / 255, (color.r * colorparm.r) / 255, (color.g * colorparm.g) / 255, (color.b * colorparm.b) / 255);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -125,6 +125,9 @@ enum
|
|||
DTA_TextLen, // stop after this many characters, even if \0 not hit
|
||||
DTA_CellX, // horizontal size of character cell
|
||||
DTA_CellY, // vertical size of character cell
|
||||
|
||||
// New additions.
|
||||
DTA_Color,
|
||||
};
|
||||
|
||||
enum
|
||||
|
@ -161,6 +164,7 @@ struct DrawParms
|
|||
uint32_t fillcolor;
|
||||
FRemapTable *remap;
|
||||
uint32_t colorOverlay;
|
||||
PalEntry color;
|
||||
INTBOOL alphaChannel;
|
||||
INTBOOL flipX;
|
||||
//float shadowAlpha;
|
||||
|
|
|
@ -2942,6 +2942,12 @@ void D3DFB::DrawTextureParms (FTexture *img, DrawParms &parms)
|
|||
|
||||
vert = &VertexData[VertexPos];
|
||||
|
||||
{
|
||||
PalEntry color = color1;
|
||||
color = PalEntry((color.a * parms.color.a) / 255, (color.r * parms.color.r) / 255, (color.g * parms.color.g) / 255, (color.b * parms.color.b) / 255);
|
||||
color1 = color;
|
||||
}
|
||||
|
||||
// Fill the vertex buffer.
|
||||
vert[0].x = float(x0);
|
||||
vert[0].y = float(y0);
|
||||
|
|
|
@ -271,6 +271,7 @@ class Menu : Object native ui version("2.4")
|
|||
virtual void ResetColor() {}
|
||||
virtual bool MouseEvent(int type, int mx, int my) { return true; }
|
||||
virtual void Ticker() {}
|
||||
virtual void OnReturn() {}
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue