mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 14:38:18 +00:00
fix text color if opengl3.3 is off
This commit is contained in:
parent
43bb77af05
commit
15f0efc2bd
|
@ -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)
|
void CGraphics_Threaded::SetColor(CCommandBuffer::SVertex *pVertex, int ColorIndex)
|
||||||
{
|
{
|
||||||
CCommandBuffer::SVertex *pVert = (CCommandBuffer::SVertex*)pVertex;
|
CCommandBuffer::SVertex *pVert = (CCommandBuffer::SVertex*)pVertex;
|
||||||
|
|
|
@ -152,20 +152,12 @@ public:
|
||||||
WRAP_REPEAT = 0,
|
WRAP_REPEAT = 0,
|
||||||
WRAP_CLAMP,
|
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
|
typedef GL_SPoint SPoint;
|
||||||
{
|
typedef GL_STexCoord STexCoord;
|
||||||
SPoint m_Pos;
|
typedef GL_SColorf SColorf;
|
||||||
STexCoord m_Tex;
|
typedef GL_SColor SColor;
|
||||||
SColor m_Color;
|
typedef GL_SVertex SVertex;
|
||||||
};
|
|
||||||
|
|
||||||
struct SCommand
|
struct SCommand
|
||||||
{
|
{
|
||||||
|
@ -749,6 +741,7 @@ public:
|
||||||
|
|
||||||
// go through all vertices and change their color (only works for quads)
|
// 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 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);
|
void SetColor(CCommandBuffer::SVertex *pVertex, int ColorIndex);
|
||||||
|
|
||||||
|
|
|
@ -1570,13 +1570,27 @@ public:
|
||||||
Graphics()->TextureSet(pFont->m_aTextures[0]);
|
Graphics()->TextureSet(pFont->m_aTextures[0]);
|
||||||
if(pTextColor->m_A != 0)
|
if(pTextColor->m_A != 0)
|
||||||
{
|
{
|
||||||
STextCharQuad& TextCharQuad = TextContainer.m_StringInfo.m_CharacterQuads[0];
|
for(size_t i = 0; i < TextContainer.m_StringInfo.m_QuadNum; ++i)
|
||||||
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);
|
{
|
||||||
|
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
|
else
|
||||||
{
|
{
|
||||||
STextCharQuad& TextCharQuad = TextContainer.m_StringInfo.m_CharacterQuads[0];
|
for(size_t i = 0; i < TextContainer.m_StringInfo.m_QuadNum; ++i)
|
||||||
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);
|
{
|
||||||
|
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
|
// render non outlined
|
||||||
|
|
|
@ -76,6 +76,19 @@ public:
|
||||||
int m_Red, m_Green, m_Blue;
|
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);
|
typedef void(*WINDOW_RESIZE_FUNC)(void *pUser);
|
||||||
|
|
||||||
|
@ -226,6 +239,7 @@ public:
|
||||||
virtual void SetColorVertex(const CColorVertex *pArray, int Num) = 0;
|
virtual void SetColorVertex(const CColorVertex *pArray, int Num) = 0;
|
||||||
virtual void SetColor(float r, float g, float b, float a) = 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 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 TakeScreenshot(const char *pFilename) = 0;
|
||||||
virtual void TakeCustomScreenshot(const char *pFilename) = 0;
|
virtual void TakeCustomScreenshot(const char *pFilename) = 0;
|
||||||
|
|
Loading…
Reference in a new issue