Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4536 in orxonox.OLD


Ignore:
Timestamp:
Jun 7, 2005, 10:33:17 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: saver font: now the implementation of NON-loading font must be done

Location:
orxonox/trunk/src/lib/graphics
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/graphics/graphics_engine.cc

    r4519 r4536  
    302302      if( unlikely(this->currentFPS < this->minFPS)) this->minFPS = this->currentFPS;
    303303     
     304#ifndef NO_TEXT
    304305      char tmpChar1[20];
    305306      sprintf(tmpChar1, "Current:  %4.0f", this->currentFPS);
     
    311312      sprintf(tmpChar3, "Min:    %4.0f", this->minFPS);
    312313      this->geTextMinFPS->setText(tmpChar3);
     314#endif /* NO_TEXT */
    313315    }
    314316}
     
    324326  if( display)
    325327    {
     328#ifndef NO_TEXT
    326329      this->geTextCFPS = TextEngine::getInstance()->createText("fonts/druid.ttf", 35, TEXT_DYNAMIC, 0, 255, 0);
    327330      this->geTextCFPS->setAlignment(TEXT_ALIGN_LEFT);
     
    333336      this->geTextMinFPS->setAlignment(TEXT_ALIGN_LEFT);
    334337      this->geTextMinFPS->setPosition(5, 560); 
     338#endif /* NO_TEXT */
    335339    }
    336340  this->bDisplayFPS = display;
  • orxonox/trunk/src/lib/graphics/graphics_engine.h

    r4519 r4536  
    7676  float          minFPS;          //!< minimal frame rate we ever got since start
    7777
     78#ifndef NO_TEXT
    7879  Text*          geTextCFPS;      //!< Text for the current FPS
    7980  Text*          geTextMaxFPS;    //!< Text for the max FPS
    8081  Text*          geTextMinFPS;    //!< Text for the min FPS
    81 
     82#endif /* NO_TEXT */
    8283};
    8384
  • orxonox/trunk/src/lib/graphics/text_engine.cc

    r4519 r4536  
    9191void Text::setType(int type)
    9292{
    93   this->type = type;
    94 }
    95 
     93  if (this->font->font)
     94    this->type = type;
     95  else
     96    this->type = TEXT_DYNAMIC;
     97}
    9698
    9799/**
     
    163165
    164166   this has to be called every time by the user, to if changes were made.
     167   this is only for TEXT_STATIC-mode
    165168*/
    166169void Text::createTexture(void)
     
    169172  if (this->texture)
    170173    glDeleteTextures(1, &this->texture);
    171   tmpSurf = TTF_RenderText_Blended(this->font->font,
    172                                    this->text,
    173                                    this->color);
     174  if (likely(this->font != NULL))
     175    tmpSurf = TTF_RenderText_Blended(this->font->font,
     176                                     this->text,
     177                                     this->color);
    174178  if (tmpSurf)
    175179    this->texture = loadTexture(tmpSurf, &this->texCoord);
     
    424428
    425429  // erease this font out of the memory.
    426   if (this->font)
     430  if (likely(this->font != NULL))
    427431    TTF_CloseFont(this->font);
    428432}
     
    441445     
    442446      this->font = TTF_OpenFont(this->fontFile, this->fontSize);
    443       if(!this->font) 
     447      if(!this->font)
    444448        {
    445449          PRINTF(1)("TTF_OpenFont: %s\n", TTF_GetError());
     
    447451        }
    448452      else
    449         return true;
     453          return true;
    450454    }
    451455  else
     
    473477      this->renderStyle |= TTF_STYLE_UNDERLINE;
    474478
    475   if (this->font)
     479  if (likely(this->font != NULL))
    476480    TTF_SetFontStyle(this->font, this->renderStyle);
    477481  else
    478482    PRINTF(2)("Font was not initialized, please do so before setting the Font-Style.\n");
    479483}
    480 
    481 
    482484
    483485/**
     
    508510int Font::getMaxHeight(void)
    509511{
    510   if (this->font)
     512  if (likely (this->font != NULL))
    511513    return TTF_FontHeight(this->font);
    512514  else
     
    521523int Font::getMaxAscent(void)
    522524{
    523   if (this->font)
     525  if (likely(this->font != NULL))
    524526    return TTF_FontAscent(this->font);
    525527  else
     
    534536int Font::getMaxDescent(void)
    535537{
    536   if (this->font)
     538  if (likely(this->font != NULL))
    537539    return TTF_FontDescent(this->font);
    538540  else
     
    553555  Glyph* rg = new Glyph;
    554556  rg->character = character;
    555   TTF_GlyphMetrics(this->font, rg->character,
    556                    &rg->minX, &rg->maxX,
    557                    &rg->minY, &rg->maxY,
    558                    &rg->advance);
     557  if (likely (this->font!= NULL))
     558    TTF_GlyphMetrics(this->font, rg->character,
     559                     &rg->minX, &rg->maxX,
     560                     &rg->minY, &rg->maxY,
     561                     &rg->advance);
    559562  rg->height = rg->maxY - rg->minY;
    560563  rg->width = rg->maxX - rg->minX;
     
    605608
    606609  // all the interessting Glyphs
    607   for (int i = 32; i <= 122; i++)
     610  for (int i = 0; i <= 127; i++)
    608611    {
    609612      SDL_Surface* glyphSurf = NULL;
     
    627630            }
    628631          // reading in the new Glyph
    629           glyphSurf = TTF_RenderGlyph_Blended(this->font, i, this->fastColor);
    630           if( glyphSurf )
     632          if (likely(this->font != NULL))
     633            glyphSurf = TTF_RenderGlyph_Blended(this->font, i, this->fastColor);
     634          if( glyphSurf != NULL )
    631635            {
    632636
     
    671675        }
    672676    }
     677  SDL_SaveBMP(tmpSurf, "text");
    673678
    674679  GLuint texture;
     
    723728
    724729   This function searches for a 2^n sizes texture-size, this is for
    725    openGL-version < 1.2 compatibility. and because it is realy easy like this.
     730   openGL-version < 1.2 compatibility ( and because it is realy easy like this :))
    726731*/
    727732int Font::findOptimalFastTextureSize(void)
     
    764769    }
    765770  return size;
    766  
    767771}
    768772
     
    773777void Font::debug(void)
    774778{
    775 
    776779  // print the loaded font's style
    777780  int style;
    778   style = TTF_GetFontStyle(this->font);
     781  if (likely(this->font != NULL))
     782    style = TTF_GetFontStyle(this->font);
    779783  PRINTF(0)("The font style is:");
    780784  if(style==TTF_STYLE_NORMAL)
     
    789793  }
    790794  PRINTF(0)("\n");
    791 
    792 
    793795}
    794796
     
    824826
    825827  TextEngine::singletonRef = NULL;
    826 
    827828}
    828829
  • orxonox/trunk/src/lib/graphics/text_engine.h

    r4519 r4536  
    3030
    3131//! An enumerator for the text alignment.
    32 enum TEXT_ALIGNMENT {TEXT_ALIGN_LEFT, TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER, TEXT_ALIGN_SCREEN_CENTER};
     32enum TEXT_ALIGNMENT { TEXT_ALIGN_LEFT,
     33                      TEXT_ALIGN_RIGHT,
     34                      TEXT_ALIGN_CENTER,
     35                      TEXT_ALIGN_SCREEN_CENTER };
    3336
    3437/* some default values */
     
    8588 
    8689  // OpenGL-specific
    87   //  TexCoord texCoord;         //!< A Texture Coordinate for this glyph.
    88   GLuint displayList;         //!< DiplayList to render this Glyph.
     90  //  TexCoord texCoord;      //!< A Texture Coordinate for this glyph.
     91  GLuint   displayList;       //!< DiplayList to render this Glyph.
    8992};
    9093
Note: See TracChangeset for help on using the changeset viewer.