#include <text_context.h>
Nevrax France
Definition at line 44 of file text_context.h.
Public Member Functions | |
void | clear () |
Clear the cache. | |
void | computeString (const ucstring &s, CComputedString &output) |
void | computeString (const std::string &s, CComputedString &output) |
void | computeStringInfo (const ucstring &s, CComputedString &output) |
CTextContext () | |
void | dumpCache (const char *filename) |
Debug : write to the disk the texture cache. | |
void | erase (uint32 index) |
remove a string from the cache | |
NLMISC::CRGBA | getColor () const |
CComputedString * | getComputedString (uint32 index) |
NL3D::CFontGenerator * | getFontGenerator () |
CFontManager * | getFontManager () const |
uint32 | getFontSize () const |
CComputedString::THotSpot | getHotSpot () const |
bool | getKeep800x600Ratio () const |
float | getScaleX () const |
float | getScaleZ () const |
NLMISC::CRGBA | getShadeColor () const |
bool | getShaded () const |
void | init (IDriver *drv, CFontManager *fmg) |
set the driver. | |
CComputedString & | operator[] (uint32 index) |
Get computed string from index. | |
void | printAt (float x, float z, const ucstring &ucstr) |
Directly print a string. | |
void | printAt (float x, float z, uint32 index) |
void | printClipAt (CRenderStringBuffer &rdrBuffer, float x, float z, uint32 index, float xmin, float ymin, float xmax, float ymax) |
void | printClipAtUnProjected (CRenderStringBuffer &renderBuffer, class NL3D::CFrustum &frustum, const NLMISC::CMatrix &scaleMatrix, float x, float y, float depth, uint32 index, float xmin, float ymin, float xmax, float ymax) |
void | printfAt (float x, float z, const char *format,...) |
Directly print a string. | |
void | setColor (NLMISC::CRGBA color) |
void | setFontGenerator (const std::string fontFileName, const std::string fontExFileName="") |
Must be called before any print. | |
void | setFontSize (uint32 fontSize) |
void | setHotSpot (CComputedString::THotSpot hotSpot) |
void | setKeep800x600Ratio (bool keep) |
void | setScaleX (float scaleX) |
void | setScaleZ (float scaleZ) |
void | setShadeColor (NLMISC::CRGBA color) |
void | setShaded (bool b) |
void | setShadeExtent (float shext) |
uint32 | textPush (const ucstring &str) |
computes an ucstring and adds the result to the cache (return the index) | |
uint32 | textPush (const char *format,...) |
compute and add a string to the cache (return the index) | |
~CTextContext () | |
Destructor. | |
Private Attributes | |
std::vector< uint32 > | _CacheFreePlaces |
uint32 | _CacheNbFreePlaces |
std::vector< CComputedString > | _CacheStrings |
Cache to manipulate strings with indexes. | |
NLMISC::CRGBA | _Color |
Current text color. | |
IDriver * | _Driver |
Driver. | |
NL3D::CFontGenerator * | _FontGen |
Font generator. | |
NL3D::CFontManager * | _FontManager |
Font manager. | |
uint32 | _FontSize |
Font size;. | |
CComputedString::THotSpot | _HotSpot |
Hotspot. | |
bool | _Keep800x600Ratio |
resize the font to keep the same aspect ratio than in 800x600 | |
float | _ScaleX |
X scale. | |
float | _ScaleZ |
Z scale. | |
NLMISC::CRGBA | _ShadeColor |
Shade color (default is black). | |
bool | _Shaded |
true if text is shaded | |
float | _ShadeExtent |
shade's extent (shadow size) | |
CComputedString | _TempString |
|
Constructor defaults : fontsize=12, color=(0,0,0,255), hotspot=bottomleft, scale=1, shaded=false, shadeExtent=0.001f shadecolor=(0,0,0,255), 800x600ratio=true Definition at line 36 of file text_context.cpp. References _CacheNbFreePlaces, _FontGen, _FontSize, _Keep800x600Ratio, _ScaleX, _ScaleZ, _ShadeColor, _Shaded, and _ShadeExtent.
00037 { 00038 _Driver = NULL; 00039 _FontManager = NULL; 00040 _FontGen = NULL; 00041 00042 _FontSize = 12; 00043 00044 _Color = NLMISC::CRGBA(0,0,0); 00045 00046 _HotSpot = CComputedString::BottomLeft; 00047 00048 _ScaleX = 1.0f; 00049 _ScaleZ = 1.0f; 00050 00051 _Shaded = false; 00052 _ShadeExtent = 0.001f; 00053 _ShadeColor = NLMISC::CRGBA(0,0,0); 00054 00055 _Keep800x600Ratio= true; 00056 00057 _CacheNbFreePlaces = 0; 00058 } |
|
Destructor.
Definition at line 61 of file text_context.cpp. References _FontGen.
|
|
Clear the cache.
Definition at line 140 of file text_context.cpp. References _CacheFreePlaces, _CacheNbFreePlaces, and _CacheStrings. Referenced by NL3D::CTextContextUser::clear().
00141 { 00142 _CacheFreePlaces.clear(); 00143 _CacheNbFreePlaces = 0; 00144 _CacheStrings.clear(); 00145 } |
|
Compute a ucstring as primitive blocks using the font manager's method computeString
Definition at line 274 of file text_context.h. References _FontGen, _FontSize, _Keep800x600Ratio, NL3D::CFontManager::computeString(), and s.
00275 { 00276 _FontManager->computeString (s, _FontGen, _Color, _FontSize, _Driver, output, _Keep800x600Ratio); 00277 } |
|
Compute a string as primitive blocks using the font manager's method computeString
Definition at line 263 of file text_context.h. References _FontGen, _FontSize, _Keep800x600Ratio, NL3D::CFontManager::computeString(), and s. Referenced by NL3D::CTextContextUser::render3D().
00264 { 00265 _FontManager->computeString (s, _FontGen, _Color, _FontSize, _Driver, output, _Keep800x600Ratio); 00266 } |
|
Definition at line 279 of file text_context.h. References _FontGen, _FontSize, _Keep800x600Ratio, NL3D::CFontManager::computeStringInfo(), and s. Referenced by NL3D::CTextContextUser::getStringInfo().
00280 { 00281 _FontManager->computeStringInfo (s, _FontGen, _Color, _FontSize, _Driver, output, _Keep800x600Ratio); 00282 } |
|
Debug : write to the disk the texture cache.
Definition at line 285 of file text_context.h. References NL3D::CFontManager::dumpCache(). Referenced by NL3D::CTextContextUser::dumpCacheTexture().
00286 { 00287 _FontManager->dumpCache (filename); 00288 } |
|
remove a string from the cache
Definition at line 125 of file text_context.cpp. References _CacheFreePlaces, _CacheNbFreePlaces, and uint32. Referenced by NL3D::CTextContextUser::erase().
00126 { 00127 if (_CacheFreePlaces.size() == _CacheNbFreePlaces) 00128 { 00129 _CacheFreePlaces.push_back (i); 00130 } 00131 else 00132 { 00133 _CacheFreePlaces[_CacheNbFreePlaces] = i; 00134 } 00135 _CacheNbFreePlaces++; 00136 } |
|
Accessors GET Definition at line 105 of file text_context.h.
00105 { return _Color; } |
|
Definition at line 248 of file text_context.h. References _CacheStrings, index, and uint32. Referenced by NL3D::CTextContextUser::getStringInfo(), NL3D::CTextContextUser::resetStringSelection(), NL3D::CTextContextUser::setStringColor(), and NL3D::CTextContextUser::setStringSelection().
00249 { 00250 if (index < _CacheStrings.size()) 00251 return &_CacheStrings[index]; 00252 else 00253 return NULL; 00254 } |
|
Definition at line 75 of file text_context.h. References _FontGen.
00075 { return _FontGen; } |
|
Definition at line 71 of file text_context.h. Referenced by NL3D::CTextContextUser::flushRenderBuffer(), and NL3D::CTextContextUser::flushRenderBufferUnProjected().
00071 {return _FontManager;} |
|
Definition at line 107 of file text_context.h. References _FontSize, and uint32. Referenced by NL3D::CTextContextUser::getFontSize().
00107 { return _FontSize; } |
|
Definition at line 109 of file text_context.h. Referenced by NL3D::CTextContextUser::getHotSpot().
00109 { return _HotSpot; } |
|
Definition at line 117 of file text_context.h. References _Keep800x600Ratio. Referenced by NL3D::CTextContextUser::getKeep800x600Ratio().
00117 {return _Keep800x600Ratio;} |
|
Definition at line 111 of file text_context.h. References _ScaleX. Referenced by NL3D::CTextContextUser::getScaleX().
00111 { return _ScaleX; } |
|
Definition at line 113 of file text_context.h. References _ScaleZ. Referenced by NL3D::CTextContextUser::getScaleY().
00113 { return _ScaleZ; } |
|
Definition at line 119 of file text_context.h. References _ShadeColor. Referenced by NL3D::CTextContextUser::getShadeColor().
00119 { return _ShadeColor; } |
|
Definition at line 115 of file text_context.h. References _Shaded. Referenced by NL3D::CTextContextUser::getShaded().
00115 { return _Shaded; } |
|
set the driver. Inits Definition at line 63 of file text_context.h. References nlassert. Referenced by NL3D::CTextContextUser::CTextContextUser().
00064 { 00065 nlassert(drv && fmg); 00066 _Driver= drv; 00067 _FontManager= fmg; 00068 } |
|
Get computed string from index.
Definition at line 242 of file text_context.h. References _CacheStrings, index, nlassert, and uint32.
00243 { 00244 nlassert (index < _CacheStrings.size()); 00245 return _CacheStrings[index]; 00246 } |
|
Directly print a string.
Definition at line 196 of file text_context.h. References _FontGen, _FontSize, _Keep800x600Ratio, _ScaleX, _ScaleZ, _ShadeColor, _Shaded, _ShadeExtent, _TempString, NLMISC::CRGBA::A, NL3D::CComputedString::Color, NL3D::CFontManager::computeString(), nlassert, NL3D::CComputedString::render2D(), x, and z.
00197 { 00198 nlassert(_FontGen); 00199 00200 // compute the string just one time 00201 _FontManager->computeString (ucstr, _FontGen, _Color, _FontSize, _Driver, _TempString, _Keep800x600Ratio); 00202 00203 // draw shaded 00204 if(_Shaded) 00205 { 00206 CRGBA bkup = _TempString.Color; 00207 _TempString.Color= _ShadeColor; 00208 _TempString.Color.A = bkup.A; 00209 _TempString.render2D (*_Driver,x+_ShadeExtent,z-_ShadeExtent,_HotSpot,_ScaleX,_ScaleZ); 00210 _TempString.Color= bkup; 00211 } 00212 00213 // draw 00214 _TempString.render2D (*_Driver, x, z, _HotSpot, _ScaleX, _ScaleZ); 00215 } |
|
Print a string that is in the cache from its index (it leaves the string in the cache) z : if the hotspot is bottom z is the position of the line of the string, not the bottom of the string bounding box ! Definition at line 144 of file text_context.h. References _CacheStrings, _ScaleX, _ScaleZ, _ShadeColor, _Shaded, _ShadeExtent, NLMISC::CRGBA::A, NL3D::CComputedString::Color, index, nlassert, NL3D::CComputedString::render2D(), uint32, x, and z. Referenced by NL3D::CTextContextUser::printAt(), and NL3D::CTextContextUser::printfAt().
00145 { 00146 nlassert (index < _CacheStrings.size()); 00147 CComputedString &rCS = _CacheStrings[index]; 00148 if(_Shaded) 00149 { 00150 CRGBA bkup = rCS.Color; 00151 rCS.Color = _ShadeColor; 00152 rCS.Color.A = bkup.A; 00153 rCS.render2D (*_Driver, x+_ShadeExtent, z-_ShadeExtent, _HotSpot, _ScaleX, _ScaleZ); 00154 rCS.Color= bkup; 00155 } 00156 rCS.render2D (*_Driver, x, z, _HotSpot, _ScaleX, _ScaleZ); 00157 } |
|
Clip and print a string that is in the cache (it leaves the string in the cache) z : if the hotspot is bottom z is the position of the line of the string, not the bottom of the string bounding box ! Definition at line 162 of file text_context.h. References _CacheStrings, _ShadeColor, _Shaded, _ShadeExtent, NLMISC::CRGBA::A, NL3D::CComputedString::Color, index, nlassert, NL3D::CComputedString::render2DClip(), uint32, x, and z. Referenced by NL3D::CTextContextUser::printClipAt().
00163 { 00164 nlassert (index < _CacheStrings.size()); 00165 CComputedString &rCS = _CacheStrings[index]; 00166 if(_Shaded) 00167 { 00168 CRGBA bkup = rCS.Color; 00169 rCS.Color= _ShadeColor; 00170 rCS.Color.A = bkup.A; 00171 rCS.render2DClip(*_Driver, rdrBuffer, x+_ShadeExtent, z-_ShadeExtent, xmin, ymin, xmax, ymax); 00172 rCS.Color= bkup; 00173 } 00174 rCS.render2DClip (*_Driver, rdrBuffer, x, z, xmin, ymin, xmax, ymax); 00175 } |
|
Clip and print a string that is in the cache (it leaves the string in the cache) z : if the hotspot is bottom z is the position of the line of the string, not the bottom of the string bounding box ! Definition at line 180 of file text_context.h. References _CacheStrings, _ShadeColor, _Shaded, _ShadeExtent, NLMISC::CRGBA::A, NL3D::CComputedString::Color, depth, index, nlassert, NL3D::CComputedString::render2DUnProjected(), uint32, x, and y. Referenced by NL3D::CTextContextUser::printClipAtUnProjected().
00181 { 00182 nlassert (index < _CacheStrings.size()); 00183 CComputedString &rCS = _CacheStrings[index]; 00184 if(_Shaded) 00185 { 00186 CRGBA bkup = rCS.Color; 00187 rCS.Color= _ShadeColor; 00188 rCS.Color.A = bkup.A; 00189 rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x+_ShadeExtent, y-_ShadeExtent, depth, xmin, ymin, xmax, ymax); 00190 rCS.Color= bkup; 00191 } 00192 rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x, y, depth, xmin, ymin, xmax, ymax); 00193 } |
|
Directly print a string.
Definition at line 218 of file text_context.h. References _FontGen, _FontSize, _Keep800x600Ratio, _ScaleX, _ScaleZ, _ShadeColor, _Shaded, _ShadeExtent, _TempString, NLMISC::CRGBA::A, NL3D::CComputedString::Color, NL3D::CFontManager::computeString(), format, nlassert, NLMISC_CONVERT_VARGS, NL3D::CComputedString::render2D(), x, and z.
00219 { 00220 nlassert(_FontGen); 00221 00222 // compute the string just one time 00223 char *str; 00224 NLMISC_CONVERT_VARGS (str, format, NLMISC::MaxCStringSize); 00225 _FontManager->computeString (str, _FontGen, _Color, _FontSize, _Driver, _TempString, _Keep800x600Ratio); 00226 00227 // draw shaded 00228 if(_Shaded) 00229 { 00230 CRGBA bkup = _TempString.Color; 00231 _TempString.Color = _ShadeColor; 00232 _TempString.Color.A = bkup.A; 00233 _TempString.render2D (*_Driver,x+_ShadeExtent,z-_ShadeExtent,_HotSpot,_ScaleX,_ScaleZ); 00234 _TempString.Color= bkup; 00235 } 00236 00237 // draw 00238 _TempString.render2D (*_Driver, x, z, _HotSpot, _ScaleX, _ScaleZ); 00239 } |
|
Accessors SET Definition at line 81 of file text_context.h. Referenced by NL3D::CTextContextUser::setColor().
00081 { _Color = color; } |
|
Must be called before any print.
Definition at line 149 of file text_context.cpp. References _FontGen. Referenced by NL3D::CTextContextUser::CTextContextUser().
00150 { 00151 _FontGen = new NL3D::CFontGenerator(fontFileName, fontExFileName); 00152 } |
|
Definition at line 83 of file text_context.h. References _FontSize, and uint32. Referenced by NL3D::CTextContextUser::setFontSize().
00083 { _FontSize = fontSize; } |
|
Definition at line 85 of file text_context.h. Referenced by NL3D::CTextContextUser::setHotSpot().
00085 { _HotSpot = hotSpot; } |
|
If true the CFontManager look at Driver window size, and resize fontSize to keep the same size than if it was in 800x600... Definition at line 99 of file text_context.h. References _Keep800x600Ratio. Referenced by NL3D::CTextContextUser::setKeep800x600Ratio().
00099 { _Keep800x600Ratio = keep; } |
|
Definition at line 87 of file text_context.h. References _ScaleX. Referenced by NL3D::CTextContextUser::setScaleX().
00087 { _ScaleX = scaleX; } |
|
Definition at line 89 of file text_context.h. References _ScaleZ. Referenced by NL3D::CTextContextUser::setScaleY().
00089 { _ScaleZ = scaleZ; } |
|
Definition at line 95 of file text_context.h. References _ShadeColor. Referenced by NL3D::CTextContextUser::setShadeColor().
00095 { _ShadeColor = color; } |
|
Definition at line 91 of file text_context.h. References _Shaded. Referenced by NL3D::CTextContextUser::setShaded().
00091 { _Shaded = b; } |
|
Definition at line 93 of file text_context.h. References _ShadeExtent. Referenced by NL3D::CTextContextUser::setShadeExtent().
00093 { _ShadeExtent = shext; } |
|
computes an ucstring and adds the result to the cache (return the index)
Definition at line 98 of file text_context.cpp. References _CacheFreePlaces, _CacheNbFreePlaces, _CacheStrings, _FontGen, _FontSize, _Keep800x600Ratio, NL3D::CFontManager::computeString(), index, nlassert, and uint32.
00099 { 00100 nlassert(_FontGen); 00101 00102 if (_CacheNbFreePlaces == 0) 00103 { 00104 CComputedString csTmp; 00105 00106 _CacheStrings.push_back (csTmp); 00107 if (_CacheFreePlaces.size() == 0) 00108 _CacheFreePlaces.resize (1); 00109 _CacheFreePlaces[0] = _CacheStrings.size()-1; 00110 _CacheNbFreePlaces = 1; 00111 } 00112 00113 // compute the string. 00114 uint32 index = _CacheFreePlaces[_CacheNbFreePlaces-1]; 00115 CComputedString &strToFill = _CacheStrings[index]; 00116 _FontManager->computeString (str, _FontGen, _Color 00117 , _FontSize, _Driver, strToFill, _Keep800x600Ratio); 00118 00119 _CacheNbFreePlaces--; 00120 00121 return index; 00122 } |
|
compute and add a string to the cache (return the index) Cache methods Definition at line 68 of file text_context.cpp. References _CacheFreePlaces, _CacheNbFreePlaces, _CacheStrings, _FontGen, _FontSize, _Keep800x600Ratio, NL3D::CFontManager::computeString(), format, index, nlassert, NLMISC_CONVERT_VARGS, and uint32. Referenced by NL3D::CTextContextUser::textPush().
00069 { 00070 nlassert(_FontGen); 00071 00072 // convert the string. 00073 char *str; 00074 NLMISC_CONVERT_VARGS (str, format, NLMISC::MaxCStringSize); 00075 00076 if (_CacheNbFreePlaces == 0) 00077 { 00078 CComputedString csTmp; 00079 00080 _CacheStrings.push_back (csTmp); 00081 if (_CacheFreePlaces.size() == 0) 00082 _CacheFreePlaces.resize (1); 00083 _CacheFreePlaces[0] = _CacheStrings.size()-1; 00084 _CacheNbFreePlaces = 1; 00085 } 00086 00087 // compute the string. 00088 uint32 index = _CacheFreePlaces[_CacheNbFreePlaces-1]; 00089 CComputedString &strToFill = _CacheStrings[index]; 00090 _FontManager->computeString (str, _FontGen, _Color, _FontSize, _Driver, strToFill, _Keep800x600Ratio); 00091 00092 _CacheNbFreePlaces--; 00093 00094 return index; 00095 } |
|
Definition at line 338 of file text_context.h. Referenced by clear(), erase(), and textPush(). |
|
Definition at line 339 of file text_context.h. Referenced by clear(), CTextContext(), erase(), and textPush(). |
|
Cache to manipulate strings with indexes. Strings Caches Definition at line 337 of file text_context.h. Referenced by clear(), getComputedString(), operator[](), printAt(), printClipAt(), printClipAtUnProjected(), and textPush(). |
|
Current text color.
Definition at line 309 of file text_context.h. |
|
Driver.
Definition at line 293 of file text_context.h. |
|
Font generator.
Definition at line 299 of file text_context.h. Referenced by computeString(), computeStringInfo(), CTextContext(), getFontGenerator(), printAt(), printfAt(), setFontGenerator(), textPush(), and ~CTextContext(). |
|
Font manager.
Definition at line 296 of file text_context.h. |
|
Font size;. Text Style properties Definition at line 306 of file text_context.h. Referenced by computeString(), computeStringInfo(), CTextContext(), getFontSize(), printAt(), printfAt(), setFontSize(), and textPush(). |
|
Hotspot.
Definition at line 312 of file text_context.h. |
|
resize the font to keep the same aspect ratio than in 800x600
Definition at line 330 of file text_context.h. Referenced by computeString(), computeStringInfo(), CTextContext(), getKeep800x600Ratio(), printAt(), printfAt(), setKeep800x600Ratio(), and textPush(). |
|
X scale.
Definition at line 315 of file text_context.h. Referenced by CTextContext(), getScaleX(), printAt(), printfAt(), and setScaleX(). |
|
Z scale.
Definition at line 318 of file text_context.h. Referenced by CTextContext(), getScaleZ(), printAt(), printfAt(), and setScaleZ(). |
|
Shade color (default is black).
Definition at line 327 of file text_context.h. Referenced by CTextContext(), getShadeColor(), printAt(), printClipAt(), printClipAtUnProjected(), printfAt(), and setShadeColor(). |
|
true if text is shaded
Definition at line 321 of file text_context.h. Referenced by CTextContext(), getShaded(), printAt(), printClipAt(), printClipAtUnProjected(), printfAt(), and setShaded(). |
|
shade's extent (shadow size)
Definition at line 324 of file text_context.h. Referenced by CTextContext(), printAt(), printClipAt(), printClipAtUnProjected(), printfAt(), and setShadeExtent(). |
|
Cache for for printAt() and printfAt(). This prevents from creating VBdrvinfos each time they are called (N*each frame!!). Definition at line 344 of file text_context.h. Referenced by printAt(), and printfAt(). |