Removes unnecessary z-level from GUI sprite rendering.

Tested By: Imarok
Differential Revision: https://code.wildfiregames.com/D4003
This was SVN commit r25524.
This commit is contained in:
Vladislav Belov 2021-05-22 18:06:18 +00:00
parent 2111f864d4
commit 0728c58a4d
27 changed files with 125 additions and 175 deletions

View File

@ -837,11 +837,6 @@
<ref name="bool"/>
</attribute>
</optional>
<optional>
<attribute name="z_level">
<data type="float"/>
</attribute>
</optional>
<optional>
<attribute name="fixed_h_aspect_ratio">
<data type="decimal"/>

View File

@ -345,7 +345,7 @@ void CGUI::Draw()
visibleObject.object->Draw();
}
void CGUI::DrawSprite(const CGUISpriteInstance& Sprite, const float& Z, const CRect& Rect, const CRect& UNUSED(Clipping))
void CGUI::DrawSprite(const CGUISpriteInstance& Sprite, const CRect& Rect, const CRect& UNUSED(Clipping))
{
// If the sprite doesn't exist (name == ""), don't bother drawing anything
if (!Sprite)
@ -353,7 +353,7 @@ void CGUI::DrawSprite(const CGUISpriteInstance& Sprite, const float& Z, const CR
// TODO: Clipping?
Sprite.Draw(*this, Rect, m_Sprites, Z);
Sprite.Draw(*this, Rect, m_Sprites);
}
void CGUI::UpdateResolution()
@ -1081,14 +1081,6 @@ void CGUI::Xeromyces_ReadImage(const XMBData& xmb, XMBElement element, CGUISprit
else
LOGERROR("GUI: Error parsing '%s' (\"%s\")", attr_name, utf8_from_wstring(attr_value));
}
else if (attr_name == "z_level")
{
float z_level;
if (!ParseString<float>(this, attr_value, z_level))
LOGERROR("GUI: Error parsing '%s' (\"%s\")", attr_name, utf8_from_wstring(attr_value));
else
Image->m_DeltaZ = z_level/100.f;
}
else if (attr_name == "backcolor")
{
if (!ParseString<CGUIColor>(this, attr_value, Image->m_BackColor))

View File

@ -101,11 +101,10 @@ public:
*
* @param Sprite Object referring to the sprite (which also caches
* calculations for faster rendering)
* @param Z Drawing order, depth value
* @param Rect Position and Size
* @param Clipping The sprite shouldn't be drawn outside this rectangle
*/
void DrawSprite(const CGUISpriteInstance& Sprite, const float& Z, const CRect& Rect, const CRect& Clipping = CRect());
void DrawSprite(const CGUISpriteInstance& Sprite, const CRect& Rect, const CRect& Clipping = CRect());
/**
* The replacement of Process(), handles an SDL_Event_

View File

@ -61,7 +61,6 @@ void CGUIScrollBarVertical::Draw()
m_pGUI.DrawSprite(
GetStyle()->m_SpriteBackVertical,
m_Z+0.1f,
CRect(
outline.left,
outline.top + (GetStyle()->m_UseEdgeButtons ? GetStyle()->m_Width : 0),
@ -97,7 +96,6 @@ void CGUIScrollBarVertical::Draw()
m_pGUI.DrawSprite(
*button_top,
m_Z+0.2f,
CRect(
outline.left,
outline.top,
@ -108,7 +106,6 @@ void CGUIScrollBarVertical::Draw()
m_pGUI.DrawSprite(
*button_bottom,
m_Z+0.2f,
CRect(
outline.left,
outline.bottom-GetStyle()->m_Width,
@ -120,7 +117,6 @@ void CGUIScrollBarVertical::Draw()
m_pGUI.DrawSprite(
GetStyle()->m_SpriteBarVertical,
m_Z + 0.2f,
GetBarRect()
);
}

View File

@ -30,14 +30,14 @@ void CGUISprite::AddImage(SGUIImage* image)
m_Images.push_back(image);
}
void CGUISpriteInstance::Draw(CGUI& pGUI, const CRect& Size, std::map<CStr, const CGUISprite*>& Sprites, float Z) const
void CGUISpriteInstance::Draw(CGUI& pGUI, const CRect& Size, std::map<CStr, const CGUISprite*>& Sprites) const
{
if (m_CachedSize != Size)
{
GUIRenderer::UpdateDrawCallCache(pGUI, m_DrawCallCache, m_SpriteName, Size, Sprites);
m_CachedSize = Size;
}
GUIRenderer::Draw(m_DrawCallCache, Z);
GUIRenderer::Draw(m_DrawCallCache);
}
// Plus a load of constructors / assignment operators, which don't copy the

View File

@ -56,7 +56,6 @@ public:
m_WrapMode(GL_REPEAT),
m_Effects(),
m_Border(false),
m_DeltaZ(0.f),
m_Size(CGUISize::Full()),
m_TextureSize(CGUISize::Full())
{
@ -102,13 +101,6 @@ public:
// 0 or 1 pixel border is the only option
bool m_Border;
/**
* Z value modification of the image.
* Inputted in XML as x-level, although it just an easier and safer
* way of declaring delta-z.
*/
float m_DeltaZ;
};
/**
@ -150,7 +142,7 @@ public:
CGUISpriteInstance();
CGUISpriteInstance(const CStr& SpriteName);
void Draw(CGUI& pGUI, const CRect& Size, std::map<CStr, const CGUISprite*>& Sprites, float Z) const;
void Draw(CGUI& pGUI, const CRect& Size, std::map<CStr, const CGUISprite*>& Sprites) const;
/**
* Whether this Sprite has no texture name set.

View File

@ -428,7 +428,7 @@ bool CGUIText::AssembleCalls(
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);
@ -447,7 +447,7 @@ void CGUIText::Draw(CGUI& pGUI, const CGUIColor& DefaultColor, const CVector2D&
CTextRenderer textRenderer(tech->GetShader());
textRenderer.SetClippingRect(clipping);
textRenderer.Translate(0.0f, 0.0f, z);
textRenderer.Translate(0.0f, 0.0f, 0.0f);
for (const STextCall& tc : m_TextCalls)
{
@ -463,7 +463,7 @@ void CGUIText::Draw(CGUI& pGUI, const CGUIColor& DefaultColor, const CVector2D&
textRenderer.Render();
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)
glDisable(GL_SCISSOR_TEST);

View File

@ -168,7 +168,7 @@ public:
/**
* Draw this CGUIText object
*/
void Draw(CGUI& pGUI, const CGUIColor& DefaultColor, const CVector2D& pos, const float z, const CRect& clipping) const;
void Draw(CGUI& pGUI, const CGUIColor& DefaultColor, const CVector2D& pos, const CRect& clipping) const;
const CSize2D& GetSize() const { return m_Size; }

View File

@ -229,7 +229,6 @@ void GUIRenderer::UpdateDrawCallCache(const CGUI& pGUI, DrawCalls& Calls, const
Call.m_BackColor = &(*cit)->m_BackColor;
Call.m_BorderColor = (*cit)->m_Border ? &(*cit)->m_BorderColor : nullptr;
Call.m_DeltaZ = (*cit)->m_DeltaZ;
if (!Call.m_HasTexture)
{
@ -329,7 +328,7 @@ CRect SDrawCall::ComputeTexCoords() const
return TexCoords;
}
void GUIRenderer::Draw(DrawCalls& Calls, float Z)
void GUIRenderer::Draw(DrawCalls& Calls)
{
if (Calls.empty())
return;
@ -377,13 +376,13 @@ void GUIRenderer::Draw(DrawCalls& Calls, float Z)
std::vector<float> data;
#define ADD(u, v, x, y, z) STMT(data.push_back(u); data.push_back(v); data.push_back(x); data.push_back(y); data.push_back(z))
ADD(TexCoords.left, TexCoords.bottom, Verts.left, Verts.bottom, Z + cit->m_DeltaZ);
ADD(TexCoords.right, TexCoords.bottom, Verts.right, Verts.bottom, Z + cit->m_DeltaZ);
ADD(TexCoords.right, TexCoords.top, Verts.right, Verts.top, Z + cit->m_DeltaZ);
ADD(TexCoords.left, TexCoords.bottom, Verts.left, Verts.bottom, 0.0f);
ADD(TexCoords.right, TexCoords.bottom, Verts.right, Verts.bottom, 0.0f);
ADD(TexCoords.right, TexCoords.top, Verts.right, Verts.top, 0.0f);
ADD(TexCoords.right, TexCoords.top, Verts.right, Verts.top, Z + cit->m_DeltaZ);
ADD(TexCoords.left, TexCoords.top, Verts.left, Verts.top, Z + cit->m_DeltaZ);
ADD(TexCoords.left, TexCoords.bottom, Verts.left, Verts.bottom, Z + cit->m_DeltaZ);
ADD(TexCoords.right, TexCoords.top, Verts.right, Verts.top, 0.0f);
ADD(TexCoords.left, TexCoords.top, Verts.left, Verts.top, 0.0f);
ADD(TexCoords.left, TexCoords.bottom, Verts.left, Verts.bottom, 0.0f);
#undef ADD
shader->TexCoordPointer(GL_TEXTURE0, 2, GL_FLOAT, 5*sizeof(float), &data[0]);
@ -409,13 +408,13 @@ void GUIRenderer::Draw(DrawCalls& Calls, float Z)
std::vector<float> data;
#define ADD(x, y, z) STMT(data.push_back(x); data.push_back(y); data.push_back(z))
ADD(Verts.left, Verts.bottom, Z + cit->m_DeltaZ);
ADD(Verts.right, Verts.bottom, Z + cit->m_DeltaZ);
ADD(Verts.right, Verts.top, Z + cit->m_DeltaZ);
ADD(Verts.left, Verts.bottom, 0.0f);
ADD(Verts.right, Verts.bottom, 0.0f);
ADD(Verts.right, Verts.top, 0.0f);
ADD(Verts.right, Verts.top, Z + cit->m_DeltaZ);
ADD(Verts.left, Verts.top, Z + cit->m_DeltaZ);
ADD(Verts.left, Verts.bottom, Z + cit->m_DeltaZ);
ADD(Verts.right, Verts.top, 0.0f);
ADD(Verts.left, Verts.top, 0.0f);
ADD(Verts.left, Verts.bottom, 0.0f);
shader->VertexPointer(3, GL_FLOAT, 3*sizeof(float), &data[0]);
glDrawArrays(GL_TRIANGLES, 0, 6);
@ -425,10 +424,10 @@ void GUIRenderer::Draw(DrawCalls& Calls, float Z)
shader->Uniform(str_color, *cit->m_BorderColor);
data.clear();
ADD(Verts.left + 0.5f, Verts.top + 0.5f, Z + cit->m_DeltaZ);
ADD(Verts.right - 0.5f, Verts.top + 0.5f, Z + cit->m_DeltaZ);
ADD(Verts.right - 0.5f, Verts.bottom - 0.5f, Z + cit->m_DeltaZ);
ADD(Verts.left + 0.5f, Verts.bottom - 0.5f, Z + cit->m_DeltaZ);
ADD(Verts.left + 0.5f, Verts.top + 0.5f, 0.0f);
ADD(Verts.right - 0.5f, Verts.top + 0.5f, 0.0f);
ADD(Verts.right - 0.5f, Verts.bottom - 0.5f, 0.0f);
ADD(Verts.left + 0.5f, Verts.bottom - 0.5f, 0.0f);
shader->VertexPointer(3, GL_FLOAT, 3*sizeof(float), &data[0]);
glDrawArrays(GL_LINE_LOOP, 0, 4);

View File

@ -53,7 +53,6 @@ namespace GUIRenderer
CColor m_ShaderColorParameter;
CRect m_Vertices;
float m_DeltaZ;
CGUIColor* m_BorderColor; // == nullptr for no border
CGUIColor* m_BackColor;
@ -70,7 +69,7 @@ namespace GUIRenderer
void UpdateDrawCallCache(const CGUI& pGUI, DrawCalls& Calls, const CStr8& SpriteName, const CRect& Size, std::map<CStr8, const CGUISprite*>& Sprites);
void Draw(DrawCalls& Calls, float Z);
void Draw(DrawCalls& Calls);
}
#endif // INCLUDED_GUIRENDERER

View File

@ -91,13 +91,13 @@ void IGUITextOwner::UpdateText()
}
}
void IGUITextOwner::DrawText(size_t index, const CGUIColor& color, const CVector2D& pos, float z, const CRect& clipping)
void IGUITextOwner::DrawText(size_t index, const CGUIColor& color, const CVector2D& pos, const CRect& clipping)
{
UpdateText();
ENSURE(index < m_GeneratedTexts.size() && "Trying to draw a Text Index within a IGUITextOwner that doesn't exist");
m_GeneratedTexts.at(index).Draw(m_pObject.GetGUI(), color, pos, z, clipping);
m_GeneratedTexts.at(index).Draw(m_pObject.GetGUI(), color, pos, clipping);
}
void IGUITextOwner::CalculateTextPosition(CRect& ObjSize, CVector2D& TextPos, CGUIText& Text)

View File

@ -82,11 +82,10 @@ public:
* @param index Index value of text. Mostly this will be 0
* @param color
* @param pos Position
* @param z Z value
* @param clipping Clipping rectangle, don't even add a parameter
* to get no clipping.
*/
virtual void DrawText(size_t index, const CGUIColor& color, const CVector2D& pos, float z, const CRect& clipping = CRect());
virtual void DrawText(size_t index, const CGUIColor& color, const CVector2D& pos, const CRect& clipping = CRect());
protected:
/**

View File

@ -82,14 +82,11 @@ void CButton::HandleMessage(SGUIMessage& Message)
void CButton::Draw()
{
const float bz = GetBufferedZ();
m_pGUI.DrawSprite(
GetButtonSprite(m_Sprite, m_SpriteOver, m_SpritePressed, m_SpriteDisabled),
bz,
m_CachedActualSize);
DrawText(0, ChooseColor(), m_TextPos, bz + 0.1f);
DrawText(0, ChooseColor(), m_TextPos);
}
bool CButton::IsMouseOver() const

View File

@ -95,11 +95,10 @@ void CChart::DrawTriangleStrip(const CShaderProgramPtr& shader, const CGUIColor&
void CChart::DrawAxes(const CShaderProgramPtr& shader) const
{
const float bz = GetBufferedZ();
CRect rect = GetChartRect();
std::vector<float> vertices;
vertices.reserve(30);
#define ADD(x, y) vertices.push_back(x); vertices.push_back(y); vertices.push_back(bz + 0.5f);
#define ADD(x, y) vertices.push_back(x); vertices.push_back(y); vertices.push_back(0.0f);
ADD(m_CachedActualSize.right, m_CachedActualSize.bottom);
ADD(rect.right + m_AxisWidth, rect.bottom);
ADD(m_CachedActualSize.left, m_CachedActualSize.bottom);
@ -117,7 +116,6 @@ void CChart::Draw()
if (m_Series.empty())
return;
const float bz = GetBufferedZ();
CRect rect = GetChartRect();
const float width = rect.GetWidth();
const float height = rect.GetHeight();
@ -143,7 +141,7 @@ void CChart::Draw()
{
vertices.push_back(rect.left + (point.X - m_LeftBottom.X) * scale.X);
vertices.push_back(rect.bottom - (point.Y - m_LeftBottom.Y) * scale.Y);
vertices.push_back(bz + 0.5f);
vertices.push_back(0.0f);
}
else
{
@ -161,7 +159,7 @@ void CChart::Draw()
tech->EndPass();
for (size_t i = 0; i < m_TextPositions.size(); ++i)
DrawText(i, CGUIColor(1.f, 1.f, 1.f, 1.f), m_TextPositions[i], bz + 0.5f);
DrawText(i, CGUIColor(1.f, 1.f, 1.f, 1.f), m_TextPositions[i]);
}
CRect CChart::GetChartRect() const

View File

@ -70,6 +70,5 @@ void CCheckBox::Draw()
m_Checked ?
GetButtonSprite(m_SpriteChecked, m_SpriteCheckedOver, m_SpriteCheckedPressed, m_SpriteCheckedDisabled) :
GetButtonSprite(m_SpriteUnchecked, m_SpriteUncheckedOver, m_SpriteUncheckedPressed, m_SpriteUncheckedDisabled),
GetBufferedZ(),
m_CachedActualSize);
}

View File

@ -422,10 +422,9 @@ bool CDropDown::IsMouseOver() const
void CDropDown::Draw()
{
const float bz = GetBufferedZ();
const CGUISpriteInstance& sprite = m_Enabled ? m_Sprite : m_SpriteDisabled;
m_pGUI.DrawSprite(sprite, bz, m_CachedActualSize);
m_pGUI.DrawSprite(sprite, m_CachedActualSize);
if (m_ButtonWidth > 0.f)
{
@ -434,18 +433,18 @@ void CDropDown::Draw()
if (!m_Enabled)
{
m_pGUI.DrawSprite(*m_Sprite2Disabled ? m_Sprite2Disabled : m_Sprite2, bz + 0.05f, rect);
m_pGUI.DrawSprite(*m_Sprite2Disabled ? m_Sprite2Disabled : m_Sprite2, rect);
}
else if (m_Open)
{
m_pGUI.DrawSprite(*m_Sprite2Pressed ? m_Sprite2Pressed : m_Sprite2, bz + 0.05f, rect);
m_pGUI.DrawSprite(*m_Sprite2Pressed ? m_Sprite2Pressed : m_Sprite2, rect);
}
else if (m_MouseHovering)
{
m_pGUI.DrawSprite(*m_Sprite2Over ? m_Sprite2Over : m_Sprite2, bz + 0.05f, rect);
m_pGUI.DrawSprite(*m_Sprite2Over ? m_Sprite2Over : m_Sprite2, rect);
}
else
m_pGUI.DrawSprite(m_Sprite2, bz + 0.05f, rect);
m_pGUI.DrawSprite(m_Sprite2, rect);
}
if (m_Selected != -1) // TODO: Maybe check validity completely?
@ -454,7 +453,7 @@ void CDropDown::Draw()
m_CachedActualSize.right - m_ButtonWidth, m_CachedActualSize.bottom);
CVector2D pos(m_CachedActualSize.left, m_CachedActualSize.top);
DrawText(m_Selected, m_Enabled ? m_TextColorSelected : m_TextColorDisabled, pos, bz + 0.1f, cliparea);
DrawText(m_Selected, m_Enabled ? m_TextColorSelected : m_TextColorDisabled, pos, cliparea);
}
if (m_Open)

View File

@ -33,5 +33,5 @@ CImage::~CImage()
void CImage::Draw()
{
m_pGUI.DrawSprite(m_Sprite, GetBufferedZ(), m_CachedActualSize);
m_pGUI.DrawSprite(m_Sprite, m_CachedActualSize);
}

View File

@ -1188,8 +1188,6 @@ void CInput::UpdateCachedSize()
void CInput::Draw()
{
float bz = GetBufferedZ();
if (m_CursorBlinkRate > 0.0)
{
// check if the cursor visibility state needs to be changed
@ -1214,7 +1212,7 @@ void CInput::Draw()
if (m_Mask && m_MaskChar->length() > 0)
mask_char = (*m_MaskChar)[0];
m_pGUI.DrawSprite(m_Sprite, bz, m_CachedActualSize);
m_pGUI.DrawSprite(m_Sprite, m_CachedActualSize);
float scroll = 0.f;
if (m_ScrollBar && m_MultiLine)
@ -1279,7 +1277,7 @@ void CInput::Draw()
textRenderer.Translate(
(float)(int)(m_CachedActualSize.left) + m_BufferZone,
(float)(int)(m_CachedActualSize.top+h) + m_BufferZone,
bz+0.1f);
0.0f);
// U+FE33: PRESENTATION FORM FOR VERTICAL LOW LINE
// (sort of like a | which is aligned to the left of most characters)
@ -1403,7 +1401,7 @@ void CInput::Draw()
rect.right = m_CachedActualSize.right;
}
m_pGUI.DrawSprite(m_SpriteSelectArea, bz + 0.05f, rect);
m_pGUI.DrawSprite(m_SpriteSelectArea, rect);
}
if (i < (int)it->m_ListOfX.size())
@ -1530,15 +1528,15 @@ void CInput::Draw()
tech->EndPass();
if (m_Caption->empty() && !m_PlaceholderText->GetRawString().empty())
DrawPlaceholderText(bz, cliparea);
DrawPlaceholderText(cliparea);
}
void CInput::DrawPlaceholderText(float z, const CRect& clipping)
void CInput::DrawPlaceholderText(const CRect& clipping)
{
if (!m_GeneratedPlaceholderTextValid)
SetupGeneratedPlaceholderText();
m_GeneratedPlaceholderText.Draw(m_pGUI, m_PlaceholderColor, m_CachedActualSize.TopLeft(), z, clipping);
m_GeneratedPlaceholderText.Draw(m_pGUI, m_PlaceholderColor, m_CachedActualSize.TopLeft(), clipping);
}
void CInput::UpdateText(int from, int to_before, int to_after)

View File

@ -116,7 +116,7 @@ protected:
* @param clipping Clipping rectangle, don't even add a parameter
* to get no clipping.
*/
virtual void DrawPlaceholderText(float z, const CRect& clipping = CRect());
virtual void DrawPlaceholderText(const CRect& clipping = CRect());
/**
* Delete the current selection. Also places the pointer at the

View File

@ -304,71 +304,68 @@ void CList::Draw()
void CList::DrawList(const int& selected, const CGUISpriteInstance& sprite, const CGUISpriteInstance& sprite_selectarea, const CGUIColor& textcolor)
{
float bz = GetBufferedZ();
CRect rect = GetListRect();
m_pGUI.DrawSprite(sprite, rect);
float scroll = 0.f;
if (m_ScrollBar)
scroll = GetScrollBar(0).GetPos();
if (selected >= 0 && selected+1 < (int)m_ItemsYPositions.size())
{
CRect rect = GetListRect();
// Get rectangle of selection:
CRect rect_sel(
rect.left, rect.top + m_ItemsYPositions[selected] - scroll,
rect.right, rect.top + m_ItemsYPositions[selected+1] - scroll);
m_pGUI.DrawSprite(sprite, bz, rect);
float scroll = 0.f;
if (m_ScrollBar)
scroll = GetScrollBar(0).GetPos();
if (selected >= 0 && selected+1 < (int)m_ItemsYPositions.size())
if (rect_sel.top <= rect.bottom &&
rect_sel.bottom >= rect.top)
{
// Get rectangle of selection:
CRect rect_sel(rect.left, rect.top + m_ItemsYPositions[selected] - scroll,
rect.right, rect.top + m_ItemsYPositions[selected+1] - scroll);
if (rect_sel.top <= rect.bottom &&
rect_sel.bottom >= rect.top)
{
if (rect_sel.bottom > rect.bottom)
rect_sel.bottom = rect.bottom;
if (rect_sel.top < rect.top)
rect_sel.top = rect.top;
if (m_ScrollBar)
{
// Remove any overlapping area of the scrollbar.
if (rect_sel.right > GetScrollBar(0).GetOuterRect().left &&
rect_sel.right <= GetScrollBar(0).GetOuterRect().right)
rect_sel.right = GetScrollBar(0).GetOuterRect().left;
if (rect_sel.left >= GetScrollBar(0).GetOuterRect().left &&
rect_sel.left < GetScrollBar(0).GetOuterRect().right)
rect_sel.left = GetScrollBar(0).GetOuterRect().right;
}
m_pGUI.DrawSprite(sprite_selectarea, bz + 0.05f, rect_sel);
}
}
for (size_t i = 0; i < m_List->m_Items.size(); ++i)
{
if (m_ItemsYPositions[i+1] - scroll < 0 ||
m_ItemsYPositions[i] - scroll > rect.GetHeight())
continue;
// Clipping area (we'll have to substract the scrollbar)
CRect cliparea = GetListRect();
if (rect_sel.bottom > rect.bottom)
rect_sel.bottom = rect.bottom;
if (rect_sel.top < rect.top)
rect_sel.top = rect.top;
if (m_ScrollBar)
{
if (cliparea.right > GetScrollBar(0).GetOuterRect().left &&
cliparea.right <= GetScrollBar(0).GetOuterRect().right)
cliparea.right = GetScrollBar(0).GetOuterRect().left;
// Remove any overlapping area of the scrollbar.
if (rect_sel.right > GetScrollBar(0).GetOuterRect().left &&
rect_sel.right <= GetScrollBar(0).GetOuterRect().right)
rect_sel.right = GetScrollBar(0).GetOuterRect().left;
if (cliparea.left >= GetScrollBar(0).GetOuterRect().left &&
cliparea.left < GetScrollBar(0).GetOuterRect().right)
cliparea.left = GetScrollBar(0).GetOuterRect().right;
if (rect_sel.left >= GetScrollBar(0).GetOuterRect().left &&
rect_sel.left < GetScrollBar(0).GetOuterRect().right)
rect_sel.left = GetScrollBar(0).GetOuterRect().right;
}
DrawText(i, textcolor, rect.TopLeft() - CVector2D(0.f, scroll - m_ItemsYPositions[i]), bz + 0.1f, cliparea);
m_pGUI.DrawSprite(sprite_selectarea, rect_sel);
}
}
for (size_t i = 0; i < m_List->m_Items.size(); ++i)
{
if (m_ItemsYPositions[i+1] - scroll < 0 ||
m_ItemsYPositions[i] - scroll > rect.GetHeight())
continue;
// Clipping area (we'll have to substract the scrollbar)
CRect cliparea = GetListRect();
if (m_ScrollBar)
{
if (cliparea.right > GetScrollBar(0).GetOuterRect().left &&
cliparea.right <= GetScrollBar(0).GetOuterRect().right)
cliparea.right = GetScrollBar(0).GetOuterRect().left;
if (cliparea.left >= GetScrollBar(0).GetOuterRect().left &&
cliparea.left < GetScrollBar(0).GetOuterRect().right)
cliparea.left = GetScrollBar(0).GetOuterRect().right;
}
DrawText(i, textcolor, rect.TopLeft() - CVector2D(0.f, scroll - m_ItemsYPositions[i]), cliparea);
}
if (m_ScrollBar)
IGUIScrollBarOwner::Draw();
}

View File

@ -383,7 +383,7 @@ static void inline addVertex(const MinimapUnitVertex& v,
}
void CMiniMap::DrawTexture(CShaderProgramPtr shader, float coordMax, float angle, float x, float y, float x2, float y2, float z) const
void CMiniMap::DrawTexture(CShaderProgramPtr shader, float coordMax, float angle, float x, float y, float x2, float y2) const
{
// Rotate the texture coordinates (0,0)-(coordMax,coordMax) around their center point (m,m)
// Scale square maps to fit in circular minimap area
@ -401,13 +401,13 @@ void CMiniMap::DrawTexture(CShaderProgramPtr shader, float coordMax, float angle
m*(-c + s + 1.f), m*(-c + -s + 1.f)
};
float quadVerts[] = {
x, y, z,
x2, y, z,
x2, y2, z,
x, y, 0.0f,
x2, y, 0.0f,
x2, y2, 0.0f,
x2, y2, z,
x, y2, z,
x, y, z
x2, y2, 0.0f,
x, y2, 0.0f,
x, y, 0.0f
};
shader->TexCoordPointer(GL_TEXTURE0, 2, GL_FLOAT, 0, quadTex);
@ -464,7 +464,6 @@ void CMiniMap::Draw()
const float x = m_CachedActualSize.left, y = m_CachedActualSize.bottom;
const float x2 = m_CachedActualSize.right, y2 = m_CachedActualSize.top;
const float z = GetBufferedZ();
const float texCoordMax = (float)(m_MapSize - 1) / (float)m_TextureSize;
const float angle = GetAngle();
const float unitScale = (cmpRangeManager->GetLosCircular() ? 1.f : m_MapScale/2.f);
@ -506,7 +505,7 @@ void CMiniMap::Draw()
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
DrawTexture(shader, texCoordMax, angle, x, y, x2, y2, z);
DrawTexture(shader, texCoordMax, angle, x, y, x2, y2);
if (!m_Mask)
{
@ -527,7 +526,7 @@ void CMiniMap::Draw()
shader->Uniform(str_transform, baseTransform);
shader->Uniform(str_textureTransform, *territoryTransform);
DrawTexture(shader, 1.0f, angle, x, y, x2, y2, z);
DrawTexture(shader, 1.0f, angle, x, y, x2, y2);
tech->EndPass();
// Draw the LOS quad in black, using alpha values from the LOS texture
@ -544,7 +543,7 @@ void CMiniMap::Draw()
shader->Uniform(str_transform, baseTransform);
shader->Uniform(str_textureTransform, *losTransform);
DrawTexture(shader, 1.0f, angle, x, y, x2, y2, z);
DrawTexture(shader, 1.0f, angle, x, y, x2, y2);
tech->EndPass();
}
@ -571,7 +570,7 @@ void CMiniMap::Draw()
// Move the minimap back to it's starting position.
unitMatrix.Translate((x2 - x) / 2.f, (y2 - y) / 2.f, 0.f);
// Move the minimap to it's final location.
unitMatrix.Translate(x, y, z);
unitMatrix.Translate(x, y, 0.0f);
// Apply the gui matrix.
unitMatrix *= GetDefaultGuiMatrix();
// Load the transform into the shader.

View File

@ -102,7 +102,7 @@ protected:
float m_WaterHeight;
void DrawTexture(CShaderProgramPtr shader, float coordMax, float angle, float x, float y, float x2, float y2, float z) const;
void DrawTexture(CShaderProgramPtr shader, float coordMax, float angle, float x, float y, float x2, float y2) const;
void DrawViewRect(const CMatrix3D& transform) const;

View File

@ -282,14 +282,12 @@ void COList::AdditionalChildrenHandled()
void COList::DrawList(const int& selected, const CGUISpriteInstance& sprite, const CGUISpriteInstance& sprite_selected, const CGUIColor& textcolor)
{
const float bz = GetBufferedZ();
if (m_ScrollBar)
IGUIScrollBarOwner::Draw();
CRect rect = GetListRect();
m_pGUI.DrawSprite(sprite, bz, rect);
m_pGUI.DrawSprite(sprite, rect);
float scroll = 0.f;
if (m_ScrollBar)
@ -325,14 +323,14 @@ void COList::DrawList(const int& selected, const CGUISpriteInstance& sprite, con
}
// Draw item selection
m_pGUI.DrawSprite(sprite_selected, bz + 0.05f, rect_sel);
m_pGUI.DrawSprite(sprite_selected, rect_sel);
}
}
// Draw line above column header
CRect rect_head(m_CachedActualSize.left, m_CachedActualSize.top, m_CachedActualSize.right,
m_CachedActualSize.top + m_HeadingHeight);
m_pGUI.DrawSprite(m_SpriteHeading, bz, rect_head);
m_pGUI.DrawSprite(m_SpriteHeading, rect_head);
// Draw column headers
float xpos = 0;
@ -369,11 +367,11 @@ void COList::DrawList(const int& selected, const CGUISpriteInstance& sprite, con
else
pSprite = &*m_SpriteNotSorted;
m_pGUI.DrawSprite(*pSprite, bz + 0.1f, CRect(leftTopCorner + CVector2D(width - SORT_SPRITE_DIM, 0), leftTopCorner + CVector2D(width, SORT_SPRITE_DIM)));
m_pGUI.DrawSprite(*pSprite, CRect(leftTopCorner + CVector2D(width - SORT_SPRITE_DIM, 0), leftTopCorner + CVector2D(width, SORT_SPRITE_DIM)));
}
// Draw column header text
DrawText(col, textcolor, leftTopCorner + COLUMN_SHIFT, bz + 0.1f, rect_head);
DrawText(col, textcolor, leftTopCorner + COLUMN_SHIFT, rect_head);
xpos += width;
++col;
}
@ -424,7 +422,7 @@ void COList::DrawList(const int& selected, const CGUISpriteInstance& sprite, con
cliparea2.bottom = std::min(cliparea2.bottom, textPos.Y + rowHeight);
// Draw list item
DrawText(objectsCount * (i +/*Heading*/1) + colIdx, column.m_TextColor, textPos, bz + 0.1f, cliparea2);
DrawText(objectsCount * (i +/*Heading*/1) + colIdx, column.m_TextColor, textPos, cliparea2);
xpos += width;
}
}

View File

@ -55,12 +55,10 @@ void CProgressBar::HandleMessage(SGUIMessage& Message)
void CProgressBar::Draw()
{
float bz = GetBufferedZ();
m_pGUI.DrawSprite(m_SpriteBackground, bz, m_CachedActualSize);
m_pGUI.DrawSprite(m_SpriteBackground, m_CachedActualSize);
// Get size of bar (notice it is drawn slightly closer, to appear above the background)
CRect size = m_CachedActualSize;
size.right = size.left + m_CachedActualSize.GetWidth() * (m_Progress / 100.f),
m_pGUI.DrawSprite(m_SpriteBar, bz + 0.01f, size);
m_pGUI.DrawSprite(m_SpriteBar, size);
}

View File

@ -107,9 +107,8 @@ void CSlider::Draw()
CRect slider_line(m_CachedActualSize);
slider_line.left += m_ButtonSide / 2.0f;
slider_line.right -= m_ButtonSide / 2.0f;
float bz = GetBufferedZ();
m_pGUI.DrawSprite(m_SpriteBar, bz, slider_line);
m_pGUI.DrawSprite(m_Sprite, bz, GetButtonRect());
m_pGUI.DrawSprite(m_SpriteBar, slider_line);
m_pGUI.DrawSprite(m_Sprite, GetButtonRect());
}
void CSlider::UpdateValue()

View File

@ -184,12 +184,10 @@ void CText::HandleMessage(SGUIMessage& Message)
void CText::Draw()
{
float bz = GetBufferedZ();
if (m_ScrollBar)
IGUIScrollBarOwner::Draw();
m_pGUI.DrawSprite(m_Sprite, bz, m_CachedActualSize);
m_pGUI.DrawSprite(m_Sprite, m_CachedActualSize);
float scroll = 0.f;
if (m_ScrollBar)
@ -217,7 +215,7 @@ void CText::Draw()
const CGUIColor& color = m_Enabled ? m_TextColor : m_TextColorDisabled;
if (m_ScrollBar)
DrawText(0, color, m_CachedActualSize.TopLeft() - CVector2D(0.f, scroll), bz + 0.1f, cliparea);
DrawText(0, color, m_CachedActualSize.TopLeft() - CVector2D(0.f, scroll), cliparea);
else
DrawText(0, color, m_TextPos, bz + 0.1f, cliparea);
DrawText(0, color, m_TextPos, cliparea);
}

View File

@ -133,9 +133,8 @@ void CTooltip::Draw()
m_GeneratedTextsValid = true;
}
const float z = GetBufferedZ();
m_pGUI.DrawSprite(m_Sprite, z, m_CachedActualSize);
DrawText(0, m_TextColor, m_CachedActualSize.TopLeft(), z + 0.1f);
m_pGUI.DrawSprite(m_Sprite, m_CachedActualSize);
DrawText(0, m_TextColor, m_CachedActualSize.TopLeft());
}
float CTooltip::GetBufferedZ() const