mirror of
https://github.com/smartcmd/MinecraftConsoles.git
synced 2026-08-20 09:57:09 +00:00
Use per-vertex coloring in a single batch
Signed-off-by: Ayush Thoren <ayushthoren@gmail.com>
This commit is contained in:
parent
1f8f90894b
commit
ced36874bc
|
|
@ -289,7 +289,7 @@ static bool isSectionFormatCode(wchar_t ca)
|
|||
return l == L'l' || l == L'o' || l == L'n' || l == L'm' || l == L'r' || l == L'k';
|
||||
}
|
||||
|
||||
void Font::draw(const wstring &str, bool dropShadow)
|
||||
void Font::draw(const wstring &str, bool dropShadow, int baseColor)
|
||||
{
|
||||
// Bind the texture
|
||||
textures->bindTexture(m_textureLocation);
|
||||
|
|
@ -299,6 +299,7 @@ void Font::draw(const wstring &str, bool dropShadow)
|
|||
|
||||
Tesselator *t = Tesselator::getInstance();
|
||||
t->begin();
|
||||
t->color(baseColor & 0x00ffffff, (baseColor >> 24) & 255);
|
||||
|
||||
for (int i = 0; i < static_cast<int>(cleanStr.length()); ++i)
|
||||
{
|
||||
|
|
@ -310,10 +311,8 @@ void Font::draw(const wstring &str, bool dropShadow)
|
|||
wchar_t ca = cleanStr[i+1];
|
||||
if (!isSectionFormatCode(ca))
|
||||
{
|
||||
t->end();
|
||||
renderCharacter(167);
|
||||
renderCharacter(ca);
|
||||
t->begin();
|
||||
addCharacterQuad(167);
|
||||
addCharacterQuad(ca);
|
||||
i += 1;
|
||||
continue;
|
||||
}
|
||||
|
|
@ -337,10 +336,8 @@ void Font::draw(const wstring &str, bool dropShadow)
|
|||
noise = false;
|
||||
if (colorN < 0 || colorN > 15) colorN = 15;
|
||||
if (dropShadow) colorN += 16;
|
||||
int color = colors[colorN];
|
||||
t->end();
|
||||
glColor3f((color >> 16) / 255.0F, ((color >> 8) & 255) / 255.0F, (color & 255) / 255.0F);
|
||||
t->begin();
|
||||
baseColor = (baseColor & 0xff000000) | colors[colorN];
|
||||
t->color(baseColor & 0x00ffffff, (baseColor >> 24) & 255);
|
||||
}
|
||||
i += 1;
|
||||
continue;
|
||||
|
|
@ -373,11 +370,11 @@ void Font::draw(const wstring& str, int x, int y, int color, bool dropShadow)
|
|||
if (dropShadow) // divide RGB by 4, preserve alpha
|
||||
color = (color & 0xfcfcfc) >> 2 | (color & (-1 << 24));
|
||||
|
||||
glColor4f((color >> 16 & 255) / 255.0F, (color >> 8 & 255) / 255.0F, (color & 255) / 255.0F, (color >> 24 & 255) / 255.0F);
|
||||
glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
xPos = x;
|
||||
yPos = y;
|
||||
draw(str, dropShadow);
|
||||
draw(str, dropShadow, color);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ public:
|
|||
private:
|
||||
wstring reorderBidi(const wstring &str);
|
||||
|
||||
void draw(const wstring &str, bool dropShadow);
|
||||
void draw(const wstring &str, bool dropShadow, int baseColor);
|
||||
void draw(const wstring& str, int x, int y, int color, bool dropShadow);
|
||||
void drawLiteral(const wstring& str, int x, int y, int color); // no § parsing
|
||||
int MapCharacter(wchar_t c); // 4J added
|
||||
|
|
|
|||
Loading…
Reference in a new issue