Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5337 in orxonox.OLD for trunk/src


Ignore:
Timestamp:
Oct 9, 2005, 1:57:46 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: text-read from XPM works, but there still is an error in displaying them

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

Legend:

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

    r5336 r5337  
    257257  glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, GL_MODULATE );
    258258
    259   if(likely(type & TEXT_RENDER_DYNAMIC && this->font != NULL))
    260     {
    261       Glyph** glyphArray = this->font->getGlyphArray();
    262       glBindTexture(GL_TEXTURE_2D, this->font->getFastTextureID());
    263       //      glEnable(GL_TEXTURE_2D);
    264       glTranslatef(getAbsCoor2D().x, getAbsCoor2D().y, 0);
     259  if(likely(type & TEXT_RENDER_DYNAMIC ))
     260    {
     261      Glyph** glyphArray;
     262      if (false /*likely (this->font != NULL)*/)
     263      {
     264        glyphArray = this->font->getGlyphArray();
     265        glBindTexture(GL_TEXTURE_2D, font->getFastTextureID());
     266      }
     267      else
     268      {
     269        if (unlikely(Font::getDefaultFont() == NULL))
     270          Font::initDefaultFont();
     271        glyphArray = Font::getDefaultFont()->getGlyphArray();
     272        glBindTexture(GL_TEXTURE_2D, Font::getDefaultFont()->getFastTextureID());
     273      }
     274        glTranslatef(getAbsCoor2D().x, getAbsCoor2D().y, 0);
    265275//      glRotatef(this->getAbsDir2D(), 0,0,1);
    266 
    267276      const char* tmpText = this->externText;
    268277      if (this->externText == NULL)
     
    270279      if (likely(tmpText != NULL))
    271280      {
    272         while (*tmpText != '\0')
     281        while (likely(*tmpText != '\0'))
    273282        {
    274           if(glyphArray[*tmpText])
     283          if(likely(glyphArray[*tmpText] != NULL))
    275284          {
    276285            glCallList(glyphArray[*tmpText]->displayList);
     
    473482Font::~Font()
    474483{
    475   // deleting the Lists of all Texts
    476 
    477484  // deleting all Glyphs
    478485  if (this->glyphArray != NULL)
     
    542549
    543550  // initializing the Glyphs.
    544   if (!this->glyphArray)
     551  if (this->glyphArray == NULL)
    545552  {
    546553    float cx,cy;
     554    Glyph* glyph;
    547555    this->glyphArray = new Glyph*[FONT_HIGHEST_KNOWN_CHAR];
    548556    for (int i = 0; i < FONT_HIGHEST_KNOWN_CHAR; i++)
    549557    {
    550       this->glyphArray[i] = new Glyph;
    551       this->glyphArray[i]->displayList = glGenLists(1);
     558      glyph = this->glyphArray[i] = new Glyph;
     559      glyph->displayList = glGenLists(1);
     560      if (!glIsList(glyph->displayList))
     561      {
     562        PRINTF(2)("Error creating glList for Font character %c\n", i);
     563        this->glyphArray[i] = NULL;
     564        delete glyph;
     565        continue;
     566      }
    552567      cx=(float)(i%16)/16.0f;                  // X Position Of Current Character
    553568      cy=(float)(i/16)/16.0f;                  // Y Position Of Current Character
    554       glNewList(this->glyphArray[i]->displayList, GL_COMPILE); // Start Building A List
     569      glNewList(glyph->displayList, GL_COMPILE); // Start Building A List
    555570       glBegin(GL_QUADS);                           // Use A Quad For Each Character
    556571        glTexCoord2f(cx,1.0f-cy-0.0625f);            // Texture Coord (Bottom Left)
     
    565580//       glTranslated(12,0,0);                        // Move To The Right Of The Character
    566581      glEndList();                                 // Done Building The Display List
    567 
    568582      this->glyphArray[i]->width = 12;
    569583    }
     
    9881002
    9891003      TextEngine::checkVersion();
    990       Font::initDefaultFont();
    9911004    }
    9921005  else
  • trunk/src/lib/graphics/text_engine.h

    r5336 r5337  
    177177
    178178  /** @returns a Pointer to the Array of Glyphs */
    179   inline Glyph** getGlyphArray() const { return glyphArray; };
     179  inline Glyph** getGlyphArray() const { return this->glyphArray; };
    180180  /** @returns the texture to the fast-texture */
    181   inline GLuint getFastTextureID() const { return fastTextureID; };
     181  inline GLuint getFastTextureID() const { return this->fastTextureID; };
    182182  /** @returns the default Font */
    183183  inline static Font* getDefaultFont() { return Font::defaultFont; };
Note: See TracChangeset for help on using the changeset viewer.