mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-07-12 08:55:30 +00:00
Text clipping
This was SVN commit r2527.
This commit is contained in:
+20
-1
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user