Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Oct 12, 2005, 11:07:22 PM (20 years ago)
Author:
bensch
Message:

orxonox/trunk: font do no more handle any displayLists of Glyphs

File:
1 edited

Legend:

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

    r5357 r5367  
    106106      if (this->glyphArray[i] != NULL)
    107107      {
    108         if (this->glyphArray[i]->displayList != 0)
    109           glDeleteLists(this->glyphArray[i]->displayList, 1);
    110108        delete this->glyphArray[i];
    111109      }
     
    204202  {
    205203    float cx,cy;
    206     Glyph* glyph;
     204    Glyph* tmpGlyph;
    207205    this->glyphArray = new Glyph*[FONT_HIGHEST_KNOWN_CHAR];
    208206    for (int i = 0; i < FONT_HIGHEST_KNOWN_CHAR; i++)
    209207    {
    210       glyph = this->glyphArray[i] = new Glyph;
    211       glyph->displayList = glGenLists(1);
    212       if (!glIsList(glyph->displayList))
    213       {
    214         PRINTF(2)("Error creating glList for Font character %c\n", i);
    215         this->glyphArray[i] = NULL;
    216         delete glyph;
    217         continue;
    218       }
     208      tmpGlyph = this->glyphArray[i] = new Glyph;
    219209      cx=(float)(i%16)/16.0f;                  // X Position Of Current Character
    220210      cy=(float)(i/16)/16.0f;                  // Y Position Of Current Character
    221       glNewList(glyph->displayList, GL_COMPILE); // Start Building A List
    222       glBegin(GL_QUADS);                           // Use A Quad For Each Character
    223       glTexCoord2f(cx, cy+0.001f);            // Texture Coord (Bottom Left)
    224       glVertex2d(0,-16);                            // Vertex Coord (Bottom Left)
    225       glTexCoord2f(cx+0.0625f, cy+0.001f);    // Texture Coord (Bottom Right)
    226       glVertex2i(16,-16);                           // Vertex Coord (Bottom Right)
    227       glTexCoord2f(cx+0.0625f, cy+0.0625f);     // Texture Coord (Top Right)
    228       glVertex2i(16,0);                            // Vertex Coord (Top Right)
    229       glTexCoord2f(cx, cy+0.0625f);             // Texture Coord (Top Left)
    230       glVertex2i(0,0);                             // Vertex Coord (Top Left)
    231       glEnd();                                     // Done Building Our Quad (Character)
    232 //       glTranslated(12,0,0);                        // Move To The Right Of The Character
    233       glEndList();                                 // Done Building The Display List
    234       this->glyphArray[i]->width = 12;
     211
     212      tmpGlyph->texCoord[0] = cx;
     213      tmpGlyph->texCoord[1] = cx+0.0625f;
     214      tmpGlyph->texCoord[2] = cy+0.001f;
     215      tmpGlyph->texCoord[3] = cy+0.0625f;
     216      tmpGlyph->width = 16;
     217      tmpGlyph->bearingX = 16;
     218      tmpGlyph->bearingY = 16;
     219      tmpGlyph->height = 16;
    235220    }
    236221  }
     
    292277                                               0xFF000000
    293278#else
    294                                                    0xFF000000,
     279                                               0xFF000000,
    295280                                               0x00FF0000,
    296281                                               0x0000FF00,
     
    322307        SDL_BlitSurface(glyphSurf, NULL, tmpSurf, &tmpRect);
    323308        SDL_FreeSurface(glyphSurf);
    324               // Outputting Glyphs to BMP-files.
    325 /*
    326         char outname[512];
    327         if (i < 10)
    328         sprintf( outname, "%s-glyph-00%d.bmp", this->getName(), i );
    329         else if (i <100)
    330         sprintf( outname, "%s-glyph-0%d.bmp", this->getName(), i );
    331         else
    332         sprintf( outname, "%s-glyph-%d.bmp", this->getName(), i );
    333         SDL_SaveBMP(tmpSurf, outname);*/
    334 
    335309      }
    336310    }
     
    409383{
    410384  Glyph* rg = new Glyph;
    411   rg->displayList = 0;
    412385  rg->character = character;
    413386  if (likely (this->font!= NULL))
     
    485458      if (tmpRect.y + maxLineHeight > tmpSurf->h)
    486459      {
    487         PRINTF(1)("Protection, so font cannot write over the boundraries error (this should not heappen\n");
     460        PRINTF(1)("Protection, so font cannot write over the boundraries (!!this should not heappen!!)\n");
    488461        break;
    489462      }
     
    499472
    500473        SDL_BlitSurface(glyphSurf, NULL, tmpSurf, &tmpRect);
    501         TexCoord tmpTexCoord;
    502         tmpTexCoord.minU = (float)tmpRect.x/(float)tmpSurf->w;
    503         tmpTexCoord.maxU = (float)(tmpRect.x + tmpGlyph->advance)/(float)tmpSurf->w;
    504         tmpTexCoord.minV = (float)(tmpRect.y)/(float)tmpSurf->w;
    505         tmpTexCoord.maxV = (float)(tmpRect.y+tmpGlyph->height)/(float)tmpSurf->w;
    506         tmpGlyph->displayList = glGenLists(1);
    507 
    508         glNewList(tmpGlyph->displayList, GL_COMPILE);
    509         glBegin(GL_QUADS);
    510         glTexCoord2f(tmpTexCoord.minU, tmpTexCoord.minV);
    511         glVertex2d(0, - tmpGlyph->bearingY);
    512         glTexCoord2f(tmpTexCoord.minU, tmpTexCoord.maxV);
    513         glVertex2d(0, tmpGlyph->height - tmpGlyph->bearingY);
    514         glTexCoord2f(tmpTexCoord.maxU, tmpTexCoord.maxV);
    515         glVertex2d(tmpGlyph->width, tmpGlyph->height - tmpGlyph->bearingY);
    516         glTexCoord2f(tmpTexCoord.maxU, tmpTexCoord.minV);
    517         glVertex2d(tmpGlyph->width, - tmpGlyph->bearingY);
    518         glEnd();
    519         glEndList();
     474        tmpGlyph->texCoord[0] = (float)tmpRect.x/(float)tmpSurf->w;
     475        tmpGlyph->texCoord[1] = (float)(tmpRect.x + tmpGlyph->advance)/(float)tmpSurf->w;
     476        tmpGlyph->texCoord[2] = (float)(tmpRect.y)/(float)tmpSurf->w;
     477        tmpGlyph->texCoord[3] = (float)(tmpRect.y+tmpGlyph->height)/(float)tmpSurf->w;
    520478        SDL_FreeSurface(glyphSurf);
    521479
Note: See TracChangeset for help on using the changeset viewer.