Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5179 in orxonox.OLD for trunk/src/lib/graphics/text_engine.cc


Ignore:
Timestamp:
Sep 13, 2005, 11:23:34 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: ShellInput is now almost perfectly extern.
ShellCompletion taken out.
Working again :)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/graphics/text_engine.cc

    r5125 r5179  
    8282
    8383/**
     84 * sets the Font of this Text to font
     85 * @param font the Font (normaly from the ResourceManager) to allocate to this Text
     86 */
     87void Text::setFont(Font* font)
     88{
     89  if (this->font != NULL)
     90    ResourceManager::getInstance()->unload(this->font);
     91  this->font = font;
     92}
     93
     94/**
     95 * sets the Font of this Text to font from fontFile
     96 * @param fontFile the File to load the Font from.
     97 * @param fontSize the Size of the Font
     98 */
     99void Text::setFont(const char* fontFile, unsigned int fontSize)
     100{
     101  Font* tmpFont;
     102  Text* newText;
     103  Vector tmpVec;
     104
     105  tmpFont = (Font*)ResourceManager::getInstance()->load(fontFile, TTF, RP_GAME, &fontSize);
     106  if (!tmpFont)
     107  {
     108    PRINTF(2)("Font %s could not be loaded, probably file not found\n", fontFile);
     109    this->setFont(NULL);
     110  }
     111  else
     112    this->setFont(tmpFont);
     113}
     114
     115/**
    84116 *  sets the Type of this Text
    85117 * @param type the type to set.
     
    87119void Text::setType(TEXT_RENDER_TYPE type)
    88120{
    89   if (this->font->font)
     121  if (this->font != NULL && this->font->font)
    90122    this->type = type;
    91123  else
     
    124156
    125157  // setting up the Text-Width if DYNAMIC
    126   if (this->type & TEXT_RENDER_DYNAMIC && this->getAlignment() != TEXT_ALIGN_LEFT)
     158  if (this->type & TEXT_RENDER_DYNAMIC && this->getAlignment() != TEXT_ALIGN_LEFT && this->font != NULL)
    127159    {
    128160      Glyph** glyphArray = this->font->getGlyphArray();
     
    194226  glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, GL_MODULATE );
    195227
    196   if(likely(type & TEXT_RENDER_DYNAMIC))
     228  if(likely(type & TEXT_RENDER_DYNAMIC && this->font != NULL))
    197229    {
    198230      Glyph** glyphArray = this->font->getGlyphArray();
Note: See TracChangeset for help on using the changeset viewer.