Text clipping

This was SVN commit r2527.
This commit is contained in:
Gee 2005-07-24 00:01:41 +00:00
parent 77c0ab074e
commit 74e1c8a772
4 changed files with 25 additions and 5 deletions

View File

@ -864,7 +864,7 @@ SGUIText CGUI::GenerateText(const CGUIString &string,
}
void CGUI::DrawText(SGUIText &Text, const CColor &DefaultColor,
const CPos &pos, const float &z)
const CPos &pos, const float &z, const CRect &clipping)
{
// TODO Gee: All these really necessary? Some
// are defaults and if you changed them
@ -879,6 +879,23 @@ void CGUI::DrawText(SGUIText &Text, const CColor &DefaultColor,
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
if (clipping != CRect())
{
double eq[4][4] =
{
{ 0.0, 1.0, 0.0, -clipping.top },
{ 1.0, 0.0, 0.0, -clipping.left },
{ 0.0, -1.0, 0.0, clipping.bottom },
{ -1.0, 0.0, 0.0, clipping.right }
};
for (int i=0; i<4; ++i)
{
glClipPlane(GL_CLIP_PLANE0+i, eq[i]);
glEnable(GL_CLIP_PLANE0+i);
}
}
CFont* font = NULL;
CStr LastFontName;
@ -924,6 +941,8 @@ void CGUI::DrawText(SGUIText &Text, const CColor &DefaultColor,
// TODO To whom it may concern: Thing were not reset, so
// I added this line, modify if incorrect --
for (int i=0; i<4; ++i)
glDisable(GL_CLIP_PLANE0+i);
glDisable(GL_TEXTURE_2D);
// -- GL
}

View File

@ -133,7 +133,7 @@ public:
* @param z z value.
*/
void DrawText(SGUIText &Text, const CColor &DefaultColor,
const CPos &pos, const float &z);
const CPos &pos, const float &z, const CRect &clipping);
/**
* Clean up, call this to clean up all memory allocated

View File

@ -380,7 +380,8 @@ void CList::DrawList(const int &selected,
m_ItemsYPositions[i] - scroll > rect.GetHeight())
continue;
IGUITextOwner::Draw(i, color, rect.TopLeft() - CPos(0.f, scroll - m_ItemsYPositions[i]), bz+0.1f);
IGUITextOwner::Draw(i, color, rect.TopLeft() - CPos(0.f, scroll - m_ItemsYPositions[i]), bz+0.1f,
GetListRect());
}
}
}

View File

@ -60,7 +60,7 @@ void IGUITextOwner::HandleMessage(const SGUIMessage &Message)
}
void IGUITextOwner::Draw(const int &index, const CColor &color, const CPos &pos,
const float &z, const CRect &UNUSEDPARAM(clipping))
const float &z, const CRect &clipping)
{
if (index < 0 || index >= (int)m_GeneratedTexts.size())
{
@ -70,7 +70,7 @@ void IGUITextOwner::Draw(const int &index, const CColor &color, const CPos &pos,
if (GetGUI())
{
GetGUI()->DrawText(*m_GeneratedTexts[index], color, pos, z);
GetGUI()->DrawText(*m_GeneratedTexts[index], color, pos, z, clipping);
}
}