Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/gui/CGUIText.cpp
Show First 20 Lines • Show All 422 Lines • ▼ Show 20 Lines | for (int j = temp_from; j <= i; ++j) | ||||
if (j == static_cast<int>(string.m_Words.size()) - 2) | if (j == static_cast<int>(string.m_Words.size()) - 2) | ||||
done = true; | done = true; | ||||
} | } | ||||
return done; | return done; | ||||
} | } | ||||
void CGUIText::Draw(CGUI& pGUI, const CGUIColor& DefaultColor, const CVector2D& pos, const float z, const CRect& clipping) const | void CGUIText::Draw(CGUI& pGUI, const CGUIColor& DefaultColor, const CVector2D& pos, const CRect& clipping) const | ||||
{ | { | ||||
CShaderTechniquePtr tech = g_Renderer.GetShaderManager().LoadEffect(str_gui_text); | CShaderTechniquePtr tech = g_Renderer.GetShaderManager().LoadEffect(str_gui_text); | ||||
tech->BeginPass(); | tech->BeginPass(); | ||||
bool isClipped = clipping != CRect(); | bool isClipped = clipping != CRect(); | ||||
if (isClipped) | if (isClipped) | ||||
{ | { | ||||
glEnable(GL_SCISSOR_TEST); | glEnable(GL_SCISSOR_TEST); | ||||
glScissor( | glScissor( | ||||
clipping.left * g_GuiScale, | clipping.left * g_GuiScale, | ||||
g_yres - clipping.bottom * g_GuiScale, | g_yres - clipping.bottom * g_GuiScale, | ||||
clipping.GetWidth() * g_GuiScale, | clipping.GetWidth() * g_GuiScale, | ||||
clipping.GetHeight() * g_GuiScale); | clipping.GetHeight() * g_GuiScale); | ||||
} | } | ||||
CTextRenderer textRenderer(tech->GetShader()); | CTextRenderer textRenderer(tech->GetShader()); | ||||
textRenderer.SetClippingRect(clipping); | textRenderer.SetClippingRect(clipping); | ||||
textRenderer.Translate(0.0f, 0.0f, z); | textRenderer.Translate(0.0f, 0.0f, 0.0f); | ||||
for (const STextCall& tc : m_TextCalls) | for (const STextCall& tc : m_TextCalls) | ||||
{ | { | ||||
// If this is just a placeholder for a sprite call, continue | // If this is just a placeholder for a sprite call, continue | ||||
if (tc.m_pSpriteCall) | if (tc.m_pSpriteCall) | ||||
continue; | continue; | ||||
textRenderer.Color(tc.m_UseCustomColor ? tc.m_Color : DefaultColor); | textRenderer.Color(tc.m_UseCustomColor ? tc.m_Color : DefaultColor); | ||||
textRenderer.Font(tc.m_Font); | textRenderer.Font(tc.m_Font); | ||||
textRenderer.Put(floorf(pos.X + tc.m_Pos.X), floorf(pos.Y + tc.m_Pos.Y), &tc.m_String); | textRenderer.Put(floorf(pos.X + tc.m_Pos.X), floorf(pos.Y + tc.m_Pos.Y), &tc.m_String); | ||||
} | } | ||||
textRenderer.Render(); | textRenderer.Render(); | ||||
for (const SSpriteCall& sc : m_SpriteCalls) | for (const SSpriteCall& sc : m_SpriteCalls) | ||||
pGUI.DrawSprite(sc.m_Sprite, z, sc.m_Area + pos); | pGUI.DrawSprite(sc.m_Sprite, sc.m_Area + pos); | ||||
if (isClipped) | if (isClipped) | ||||
glDisable(GL_SCISSOR_TEST); | glDisable(GL_SCISSOR_TEST); | ||||
tech->EndPass(); | tech->EndPass(); | ||||
} | } |
Wildfire Games · Phabricator