fix text color if opengl3.3 is off

This commit is contained in:
Jupeyy 2018-04-03 17:40:21 +02:00
parent 43bb77af05
commit 15f0efc2bd
4 changed files with 95 additions and 17 deletions

View file

@ -695,6 +695,63 @@ void CGraphics_Threaded::ChangeColorOfCurrentQuadVertices(float r, float g, floa
}
}
void CGraphics_Threaded::ChangeColorOfQuadVertices(int QuadOffset, unsigned char r, unsigned char g, unsigned char b, unsigned char a) {
if(g_Config.m_GfxQuadAsTriangle && !m_UseOpenGL3_3)
{
m_aVertices[QuadOffset * 6].m_Color.r = r;
m_aVertices[QuadOffset * 6].m_Color.g = g;
m_aVertices[QuadOffset * 6].m_Color.b = b;
m_aVertices[QuadOffset * 6].m_Color.a = a;
m_aVertices[QuadOffset * 6 + 1].m_Color.r = r;
m_aVertices[QuadOffset * 6 + 1].m_Color.g = g;
m_aVertices[QuadOffset * 6 + 1].m_Color.b = b;
m_aVertices[QuadOffset * 6 + 1].m_Color.a = a;
m_aVertices[QuadOffset * 6 + 2].m_Color.r = r;
m_aVertices[QuadOffset * 6 + 2].m_Color.g = g;
m_aVertices[QuadOffset * 6 + 2].m_Color.b = b;
m_aVertices[QuadOffset * 6 + 2].m_Color.a = a;
m_aVertices[QuadOffset * 6 + 3].m_Color.r = r;
m_aVertices[QuadOffset * 6 + 3].m_Color.g = g;
m_aVertices[QuadOffset * 6 + 3].m_Color.b = b;
m_aVertices[QuadOffset * 6 + 3].m_Color.a = a;
m_aVertices[QuadOffset * 6 + 4].m_Color.r = r;
m_aVertices[QuadOffset * 6 + 4].m_Color.g = g;
m_aVertices[QuadOffset * 6 + 4].m_Color.b = b;
m_aVertices[QuadOffset * 6 + 4].m_Color.a = a;
m_aVertices[QuadOffset * 6 + 5].m_Color.r = r;
m_aVertices[QuadOffset * 6 + 5].m_Color.g = g;
m_aVertices[QuadOffset * 6 + 5].m_Color.b = b;
m_aVertices[QuadOffset * 6 + 5].m_Color.a = a;
}
else
{
m_aVertices[QuadOffset * 4].m_Color.r = r;
m_aVertices[QuadOffset * 4].m_Color.g = g;
m_aVertices[QuadOffset * 4].m_Color.b = b;
m_aVertices[QuadOffset * 4].m_Color.a = a;
m_aVertices[QuadOffset * 4 + 1].m_Color.r = r;
m_aVertices[QuadOffset * 4 + 1].m_Color.g = g;
m_aVertices[QuadOffset * 4 + 1].m_Color.b = b;
m_aVertices[QuadOffset * 4 + 1].m_Color.a = a;
m_aVertices[QuadOffset * 4 + 2].m_Color.r = r;
m_aVertices[QuadOffset * 4 + 2].m_Color.g = g;
m_aVertices[QuadOffset * 4 + 2].m_Color.b = b;
m_aVertices[QuadOffset * 4 + 2].m_Color.a = a;
m_aVertices[QuadOffset * 4 + 3].m_Color.r = r;
m_aVertices[QuadOffset * 4 + 3].m_Color.g = g;
m_aVertices[QuadOffset * 4 + 3].m_Color.b = b;
m_aVertices[QuadOffset * 4 + 3].m_Color.a = a;
}
}
void CGraphics_Threaded::SetColor(CCommandBuffer::SVertex *pVertex, int ColorIndex)
{
CCommandBuffer::SVertex *pVert = (CCommandBuffer::SVertex*)pVertex;

View file

@ -153,19 +153,11 @@ public:
WRAP_CLAMP,
};
struct SPoint { float x, y; };
struct STexCoord { float u, v; };
struct SColorf { float r, g, b, a; };
//use normalized color values
struct SColor { unsigned char r, g, b, a; };
struct SVertex
{
SPoint m_Pos;
STexCoord m_Tex;
SColor m_Color;
};
typedef GL_SPoint SPoint;
typedef GL_STexCoord STexCoord;
typedef GL_SColorf SColorf;
typedef GL_SColor SColor;
typedef GL_SVertex SVertex;
struct SCommand
{
@ -749,6 +741,7 @@ public:
// go through all vertices and change their color (only works for quads)
virtual void ChangeColorOfCurrentQuadVertices(float r, float g, float b, float a);
virtual void ChangeColorOfQuadVertices(int QuadOffset, unsigned char r, unsigned char g, unsigned char b, unsigned char a);
void SetColor(CCommandBuffer::SVertex *pVertex, int ColorIndex);

View file

@ -1570,13 +1570,27 @@ public:
Graphics()->TextureSet(pFont->m_aTextures[0]);
if(pTextColor->m_A != 0)
{
STextCharQuad& TextCharQuad = TextContainer.m_StringInfo.m_CharacterQuads[0];
Graphics()->ChangeColorOfCurrentQuadVertices(TextCharQuad.m_Vertices[0].m_Color.m_R / 255.f * pTextColor->m_R, TextCharQuad.m_Vertices[0].m_Color.m_G / 255.f * pTextColor->m_G, TextCharQuad.m_Vertices[0].m_Color.m_B / 255.f * pTextColor->m_B, TextCharQuad.m_Vertices[0].m_Color.m_A / 255.f * pTextColor->m_A);
for(size_t i = 0; i < TextContainer.m_StringInfo.m_QuadNum; ++i)
{
STextCharQuad& TextCharQuad = TextContainer.m_StringInfo.m_CharacterQuads[i];
unsigned char CR = (unsigned char)((float)(TextCharQuad.m_Vertices[0].m_Color.m_R) * pTextColor->m_R);
unsigned char CG = (unsigned char)((float)(TextCharQuad.m_Vertices[0].m_Color.m_G) * pTextColor->m_G);
unsigned char CB = (unsigned char)((float)(TextCharQuad.m_Vertices[0].m_Color.m_B) * pTextColor->m_B);
unsigned char CA = (unsigned char)((float)(TextCharQuad.m_Vertices[0].m_Color.m_A) * pTextColor->m_A);
Graphics()->ChangeColorOfQuadVertices((int)i, CR, CG, CB, CA);
}
}
else
{
STextCharQuad& TextCharQuad = TextContainer.m_StringInfo.m_CharacterQuads[0];
Graphics()->ChangeColorOfCurrentQuadVertices(TextCharQuad.m_Vertices[0].m_Color.m_R / 255.f, TextCharQuad.m_Vertices[0].m_Color.m_G / 255.f, TextCharQuad.m_Vertices[0].m_Color.m_B / 255.f, TextCharQuad.m_Vertices[0].m_Color.m_A / 255.f);
for(size_t i = 0; i < TextContainer.m_StringInfo.m_QuadNum; ++i)
{
STextCharQuad& TextCharQuad = TextContainer.m_StringInfo.m_CharacterQuads[i];
unsigned char CR = TextCharQuad.m_Vertices[0].m_Color.m_R;
unsigned char CG = TextCharQuad.m_Vertices[0].m_Color.m_G;
unsigned char CB = TextCharQuad.m_Vertices[0].m_Color.m_B;
unsigned char CA = TextCharQuad.m_Vertices[0].m_Color.m_A;
Graphics()->ChangeColorOfQuadVertices((int)i, CR, CG, CB, CA);
}
}
// render non outlined

View file

@ -76,6 +76,19 @@ public:
int m_Red, m_Green, m_Blue;
};
struct GL_SPoint { float x, y; };
struct GL_STexCoord { float u, v; };
struct GL_SColorf { float r, g, b, a; };
//use normalized color values
struct GL_SColor { unsigned char r, g, b, a; };
struct GL_SVertex
{
GL_SPoint m_Pos;
GL_STexCoord m_Tex;
GL_SColor m_Color;
};
typedef void(*WINDOW_RESIZE_FUNC)(void *pUser);
@ -226,6 +239,7 @@ public:
virtual void SetColorVertex(const CColorVertex *pArray, int Num) = 0;
virtual void SetColor(float r, float g, float b, float a) = 0;
virtual void ChangeColorOfCurrentQuadVertices(float r, float g, float b, float a) = 0;
virtual void ChangeColorOfQuadVertices(int QuadOffset, unsigned char r, unsigned char g, unsigned char b, unsigned char a) = 0;
virtual void TakeScreenshot(const char *pFilename) = 0;
virtual void TakeCustomScreenshot(const char *pFilename) = 0;