Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Nov 24, 2005, 8:24:52 PM (20 years ago)
Author:
bensch
Message:

orxonox/trunk: font is a Texture now (this is a procedural texture)

File:
1 edited

Legend:

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

    r5427 r5768  
    132132  this->fontTTF = NULL;
    133133  this->glyphArray = NULL;
    134   this->fastTextureID = 0;
    135134}
    136135
     
    149148    this->fontTTF = NULL;
    150149  }
    151   if (this->fastTextureID != 0)
    152   {
    153     if(glIsTexture(this->fastTextureID))
    154       glDeleteTextures(1, &this->fastTextureID);
    155     this->fastTextureID = 0;
    156   }
     150
    157151
    158152  this->setName(fontFile);
     
    161155  if(this->fontTTF != NULL)
    162156  {
    163     this->fastTextureID = this->createFastTexture();
    164     if (this->fastTextureID != 0)
    165       return true;
    166     else
    167       return false;
     157    this->createFastTexture();
     158    return (this->getTexture() != 0);
    168159  }
    169160  else
     
    190181    this->fontTTF = NULL;
    191182  }
    192   if (this->fastTextureID != 0)
    193   {
    194     if(glIsTexture(this->fastTextureID))
    195       glDeleteTextures(1, &this->fastTextureID);
    196     this->fastTextureID = 0;
    197   }
    198 
    199   this->fastTextureID = Text::loadTexture(surface, NULL);
     183  if (this->prepareSurface(surface))
     184    this->loadTexToGL( );
    200185
    201186  // initializing the Glyphs.
     
    251236Font* Font::defaultFont = NULL;
    252237
     238/**
     239 * creates and exports an Image, that has all the characters
     240 * stored in a Array (as an image)
     241 * @param fileName the File to write the image into.
     242 */
    253243void Font::createAsciiImage(const char* fileName)
    254244{
     
    400390 * creates a Fast-Texture of this Font
    401391 */
    402 GLuint Font::createFastTexture()
     392bool Font::createFastTexture()
    403393{
    404394  /* interesting GLYPHS:
     
    500490  //   SDL_SaveBMP(tmpSurf, outName);
    501491
    502   GLuint texture;
    503   glGenTextures(1, &texture);
    504   glBindTexture(GL_TEXTURE_2D, texture);
    505   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    506   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    507   glTexImage2D(GL_TEXTURE_2D,
    508                0,
    509                GL_RGBA,
    510                tmpSurf->w, tmpSurf->h,
    511                0,
    512                GL_RGBA,
    513                GL_UNSIGNED_BYTE,
    514                tmpSurf->pixels);
    515   SDL_FreeSurface(tmpSurf);
    516   return texture;
     492  if (this->setSurface(tmpSurf))
     493    loadTexToGL();
    517494}
    518495
Note: See TracChangeset for help on using the changeset viewer.