Implement text shade outline

This commit is contained in:
kaetemi 2014-10-08 23:20:34 +02:00
parent da982ab0ca
commit 523761d7b7
5 changed files with 88 additions and 27 deletions

View file

@ -82,6 +82,8 @@ public:
void setShaded (bool b) { _Shaded = b; }
void setShadeOutline (bool b) { _ShadeOutline = b; }
void setShadeExtent (float shext) { _ShadeExtent = shext; }
/// The alpha of the shade is multiplied at each draw with the alpha of the color. Default: (0,0,0,255)
@ -107,6 +109,8 @@ public:
bool getShaded() const { return _Shaded; }
bool getShadeOutline() const { return _ShadeOutline; }
bool getKeep800x600Ratio() const {return _Keep800x600Ratio;}
NLMISC::CRGBA getShadeColor () const { return _ShadeColor; }
@ -144,6 +148,12 @@ public:
rCS.Color = _ShadeColor;
rCS.Color.A = (uint8)((uint(bkup.A) * uint(_ShadeColor.A)+1)>>8);
rCS.render2D(*_Driver, x+_ShadeExtent, z-_ShadeExtent, _HotSpot, _ScaleX, _ScaleZ);
if (_ShadeOutline)
{
rCS.render2D(*_Driver, x-_ShadeExtent, z-_ShadeExtent, _HotSpot, _ScaleX, _ScaleZ);
rCS.render2D(*_Driver, x-_ShadeExtent, z+_ShadeExtent, _HotSpot, _ScaleX, _ScaleZ);
rCS.render2D(*_Driver, x+_ShadeExtent, z+_ShadeExtent, _HotSpot, _ScaleX, _ScaleZ);
}
rCS.Color= bkup;
}
rCS.render2D(*_Driver, x, z, _HotSpot, _ScaleX, _ScaleZ);
@ -162,6 +172,12 @@ public:
rCS.Color= _ShadeColor;
rCS.Color.A = (uint8)((uint(bkup.A) * uint(_ShadeColor.A)+1)>>8);
rCS.render2DClip(*_Driver, rdrBuffer, x+_ShadeExtent, z-_ShadeExtent, xmin, ymin, xmax, ymax);
if (_ShadeOutline)
{
rCS.render2DClip(*_Driver, rdrBuffer, x-_ShadeExtent, z-_ShadeExtent, xmin, ymin, xmax, ymax);
rCS.render2DClip(*_Driver, rdrBuffer, x-_ShadeExtent, z+_ShadeExtent, xmin, ymin, xmax, ymax);
rCS.render2DClip(*_Driver, rdrBuffer, x+_ShadeExtent, z+_ShadeExtent, xmin, ymin, xmax, ymax);
}
rCS.Color= bkup;
}
rCS.render2DClip (*_Driver, rdrBuffer, x, z, xmin, ymin, xmax, ymax);
@ -180,6 +196,12 @@ public:
rCS.Color= _ShadeColor;
rCS.Color.A = (uint8)((uint(bkup.A) * uint(_ShadeColor.A)+1)>>8);
rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x+_ShadeExtent, y-_ShadeExtent, depth, xmin, ymin, xmax, ymax);
if (_ShadeOutline)
{
rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x-_ShadeExtent, y-_ShadeExtent, depth, xmin, ymin, xmax, ymax);
rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x-_ShadeExtent, y+_ShadeExtent, depth, xmin, ymin, xmax, ymax);
rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x+_ShadeExtent, y+_ShadeExtent, depth, xmin, ymin, xmax, ymax);
}
rCS.Color= bkup;
}
rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x, y, depth, xmin, ymin, xmax, ymax);
@ -200,6 +222,12 @@ public:
_TempString.Color = _ShadeColor;
_TempString.Color.A = (uint8)((uint(bkup.A) * uint(_ShadeColor.A)+1)>>8);
_TempString.render2D(*_Driver,x+_ShadeExtent,z-_ShadeExtent,_HotSpot,_ScaleX,_ScaleZ);
if (_ShadeOutline)
{
_TempString.render2D(*_Driver,x-_ShadeExtent,z-_ShadeExtent,_HotSpot,_ScaleX,_ScaleZ);
_TempString.render2D(*_Driver,x-_ShadeExtent,z+_ShadeExtent,_HotSpot,_ScaleX,_ScaleZ);
_TempString.render2D(*_Driver,x+_ShadeExtent,z+_ShadeExtent,_HotSpot,_ScaleX,_ScaleZ);
}
_TempString.Color = bkup;
}
@ -224,6 +252,12 @@ public:
_TempString.Color = _ShadeColor;
_TempString.Color.A = (uint8)((uint(bkup.A) * uint(_ShadeColor.A)+1)>>8);
_TempString.render2D(*_Driver,x+_ShadeExtent,z-_ShadeExtent,_HotSpot,_ScaleX,_ScaleZ);
if (_ShadeOutline)
{
_TempString.render2D(*_Driver,x-_ShadeExtent,z-_ShadeExtent,_HotSpot,_ScaleX,_ScaleZ);
_TempString.render2D(*_Driver,x-_ShadeExtent,z+_ShadeExtent,_HotSpot,_ScaleX,_ScaleZ);
_TempString.render2D(*_Driver,x+_ShadeExtent,z+_ShadeExtent,_HotSpot,_ScaleX,_ScaleZ);
}
_TempString.Color = bkup;
}
@ -317,6 +351,9 @@ private:
/// true if text is shaded
bool _Shaded;
/// true if shade appears as an outline
bool _ShadeOutline;
/// shade's extent (shadow size)
float _ShadeExtent;

View file

@ -74,6 +74,8 @@ public:
float getScaleY() const;
void setShaded(bool b);
bool getShaded() const;
void setShadeOutline(bool b);
bool getShadeOutline() const;
void setShadeExtent(float shext) ;
void setShadeColor (NLMISC::CRGBA sc);
NLMISC::CRGBA getShadeColor () const;

View file

@ -174,6 +174,15 @@ public:
* \return the shade state
*/
virtual bool getShaded () const = 0;
/**
* set the shade states
* \param the shade state
*/
virtual void setShadeOutline (bool b) = 0;
/**
* \return the shade state
*/
virtual bool getShadeOutline () const = 0;
/**
* set the shadow's size
* \param the shade extent

View file

@ -40,6 +40,7 @@ CTextContext::CTextContext()
_ScaleZ = 1.0f;
_Shaded = false;
_ShadeOutline = false;
_ShadeExtent = 0.001f;
_ShadeColor = NLMISC::CRGBA(0,0,0);

View file

@ -148,6 +148,18 @@ bool CTextContextUser::getShaded() const
return _TextContext.getShaded();
}
void CTextContextUser::setShadeOutline(bool b)
{
H_AUTO2;
_TextContext.setShadeOutline(b);
}
bool CTextContextUser::getShadeOutline() const
{
H_AUTO2;
return _TextContext.getShadeOutline();
}
void CTextContextUser::setShadeExtent(float shext)
{
H_AUTO2;