Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5340 in orxonox.OLD


Ignore:
Timestamp:
Oct 9, 2005, 11:38:38 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: loading of text more modular

Location:
trunk/src/lib/graphics
Files:
2 edited

Legend:

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

    r5339 r5340  
    422422  int value = 1;
    423423
    424   while ( value < input ) {
     424  while ( value < input )
    425425    value <<= 1;
    426   }
    427426  return value;
    428427}
     
    472471
    473472//  this->setSize(fontSize);
    474 
     473  SDL_Surface* image = NULL;
    475474  if (xpmArray != NULL)
    476     this->loadFontFromXPMArray(xpmArray);
     475    image = IMG_ReadXPMFromArray(xpmArray);
     476  if (image != NULL)
     477  {
     478    this->loadFontFromSDL_Surface(image);
     479    SDL_FreeSurface(image);
     480  }
     481  else
     482    PRINTF(1)("loading from surface failed: %s\n", IMG_GetError());
    477483
    478484}
     
    537543 * @param xpmArray the array of the XPM to load the font from.
    538544 */
    539 bool Font::loadFontFromXPMArray(char** xpmArray)
    540 {
    541   if (xpmArray == NULL)
     545bool Font::loadFontFromSDL_Surface(SDL_Surface* surface)
     546{
     547  // loading to a texture.
     548  if(surface == NULL)
    542549    return false;
    543 
    544   // loading to a texture.
    545   SDL_Surface* image = IMG_ReadXPMFromArray(xpmArray);
    546   if(image == NULL)
    547   {
    548     PRINTF(1)("loading from XPM-array failed: %s\n", IMG_GetError());
    549     return false;
    550   }
    551550  TexCoord texCoord;
    552   this->fastTextureID = Text::loadTexture(image, &texCoord);
     551  this->fastTextureID = Text::loadTexture(surface, &texCoord);
    553552
    554553  // initializing the Glyphs.
     
    587586    }
    588587  }
    589   SDL_FreeSurface(image);
    590588  return true;
    591589}
  • trunk/src/lib/graphics/text_engine.h

    r5339 r5340  
    171171  // font
    172172  bool loadFont(const char* fontFile);
    173   bool loadFontFromXPMArray(char** xpmArray);
     173  bool loadFontFromSDL_Surface(SDL_Surface* surface);
    174174
    175175  void setSize(unsigned int fontSize);
Note: See TracChangeset for help on using the changeset viewer.