MCPcopy Create free account
hub / github.com/ddnet/ddnet / RenderTextContainer

Method RenderTextContainer

src/engine/client/text.cpp:2116–2202  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2114 }
2115
2116 void RenderTextContainer(STextContainerIndex TextContainerIndex, const ColorRGBA &TextColor, const ColorRGBA &TextOutlineColor) override
2117 {
2118 const STextContainer &TextContainer = GetTextContainer(TextContainerIndex);
2119
2120 if(!TextContainer.m_StringInfo.m_vCharacterQuads.empty())
2121 {
2122 if(Graphics()->IsTextBufferingEnabled())
2123 {
2124 Graphics()->TextureClear();
2125 // render buffered text
2126 Graphics()->RenderText(TextContainer.m_StringInfo.m_QuadBufferContainerIndex, TextContainer.m_StringInfo.m_vCharacterQuads.size(), m_pGlyphMap->TextureDimension(), m_pGlyphMap->Texture(CGlyphMap::FONT_TEXTURE_FILL).Id(), m_pGlyphMap->Texture(CGlyphMap::FONT_TEXTURE_OUTLINE).Id(), TextColor, TextOutlineColor);
2127 }
2128 else
2129 {
2130 // render tiles
2131 const float UVScale = 1.0f / m_pGlyphMap->TextureDimension();
2132
2133 Graphics()->FlushVertices();
2134 Graphics()->TextureSet(m_pGlyphMap->Texture(CGlyphMap::FONT_TEXTURE_OUTLINE));
2135
2136 Graphics()->QuadsBegin();
2137
2138 for(const STextCharQuad &TextCharQuad : TextContainer.m_StringInfo.m_vCharacterQuads)
2139 {
2140 Graphics()->SetColor(TextCharQuad.m_aVertices[0].m_Color.r / 255.f * TextOutlineColor.r, TextCharQuad.m_aVertices[0].m_Color.g / 255.f * TextOutlineColor.g, TextCharQuad.m_aVertices[0].m_Color.b / 255.f * TextOutlineColor.b, TextCharQuad.m_aVertices[0].m_Color.a / 255.f * TextOutlineColor.a);
2141 Graphics()->QuadsSetSubset(TextCharQuad.m_aVertices[0].m_U * UVScale, TextCharQuad.m_aVertices[0].m_V * UVScale, TextCharQuad.m_aVertices[2].m_U * UVScale, TextCharQuad.m_aVertices[2].m_V * UVScale);
2142 IGraphics::CQuadItem QuadItem(TextCharQuad.m_aVertices[0].m_X, TextCharQuad.m_aVertices[0].m_Y, TextCharQuad.m_aVertices[1].m_X - TextCharQuad.m_aVertices[0].m_X, TextCharQuad.m_aVertices[2].m_Y - TextCharQuad.m_aVertices[0].m_Y);
2143 Graphics()->QuadsDrawTL(&QuadItem, 1);
2144 }
2145
2146 if(TextColor.a != 0)
2147 {
2148 Graphics()->QuadsEndKeepVertices();
2149 Graphics()->TextureSet(m_pGlyphMap->Texture(CGlyphMap::FONT_TEXTURE_FILL));
2150
2151 int TextCharQuadIndex = 0;
2152 for(const STextCharQuad &TextCharQuad : TextContainer.m_StringInfo.m_vCharacterQuads)
2153 {
2154 unsigned char CR = (unsigned char)((float)(TextCharQuad.m_aVertices[0].m_Color.r) * TextColor.r);
2155 unsigned char CG = (unsigned char)((float)(TextCharQuad.m_aVertices[0].m_Color.g) * TextColor.g);
2156 unsigned char CB = (unsigned char)((float)(TextCharQuad.m_aVertices[0].m_Color.b) * TextColor.b);
2157 unsigned char CA = (unsigned char)((float)(TextCharQuad.m_aVertices[0].m_Color.a) * TextColor.a);
2158 Graphics()->ChangeColorOfQuadVertices(TextCharQuadIndex, CR, CG, CB, CA);
2159 ++TextCharQuadIndex;
2160 }
2161
2162 // render non outlined
2163 Graphics()->QuadsDrawCurrentVertices(false);
2164 }
2165 else
2166 Graphics()->QuadsEnd();
2167
2168 // reset
2169 Graphics()->SetColor(1.f, 1.f, 1.f, 1.f);
2170 }
2171 }
2172
2173 if(TextContainer.m_StringInfo.m_SelectionQuadContainerIndex != -1)

Callers 15

DoLabelStreamedMethod · 0.80
DoButton_MenuMethod · 0.80
RenderServerBroadcastMethod · 0.80
RenderScoreHudMethod · 0.80
RenderTextInfoMethod · 0.80
RenderDDRaceEffectsMethod · 0.80
RenderMethod · 0.80
OnRenderMethod · 0.80
RenderImportantAlertMethod · 0.80
OnRenderMethod · 0.80

Calls 15

GraphicsFunction · 0.85
time_get_nanosecondsFunction · 0.85
round_to_intFunction · 0.85
TextureClearMethod · 0.80
TextureDimensionMethod · 0.80
TextureMethod · 0.80
FlushVerticesMethod · 0.80
TextureSetMethod · 0.80
QuadsBeginMethod · 0.80
QuadsSetSubsetMethod · 0.80
QuadsDrawTLMethod · 0.80

Tested by

no test coverage detected