Changeset 5337 in orxonox.OLD
- Timestamp:
- Oct 9, 2005, 1:57:46 PM (19 years ago)
- Location:
- trunk/src/lib/graphics
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/graphics/text_engine.cc
r5336 r5337 257 257 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, GL_MODULATE ); 258 258 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); 265 275 // glRotatef(this->getAbsDir2D(), 0,0,1); 266 267 276 const char* tmpText = this->externText; 268 277 if (this->externText == NULL) … … 270 279 if (likely(tmpText != NULL)) 271 280 { 272 while ( *tmpText != '\0')281 while (likely(*tmpText != '\0')) 273 282 { 274 if( glyphArray[*tmpText])283 if(likely(glyphArray[*tmpText] != NULL)) 275 284 { 276 285 glCallList(glyphArray[*tmpText]->displayList); … … 473 482 Font::~Font() 474 483 { 475 // deleting the Lists of all Texts476 477 484 // deleting all Glyphs 478 485 if (this->glyphArray != NULL) … … 542 549 543 550 // initializing the Glyphs. 544 if ( !this->glyphArray)551 if (this->glyphArray == NULL) 545 552 { 546 553 float cx,cy; 554 Glyph* glyph; 547 555 this->glyphArray = new Glyph*[FONT_HIGHEST_KNOWN_CHAR]; 548 556 for (int i = 0; i < FONT_HIGHEST_KNOWN_CHAR; i++) 549 557 { 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 } 552 567 cx=(float)(i%16)/16.0f; // X Position Of Current Character 553 568 cy=(float)(i/16)/16.0f; // Y Position Of Current Character 554 glNewList( this->glyphArray[i]->displayList, GL_COMPILE); // Start Building A List569 glNewList(glyph->displayList, GL_COMPILE); // Start Building A List 555 570 glBegin(GL_QUADS); // Use A Quad For Each Character 556 571 glTexCoord2f(cx,1.0f-cy-0.0625f); // Texture Coord (Bottom Left) … … 565 580 // glTranslated(12,0,0); // Move To The Right Of The Character 566 581 glEndList(); // Done Building The Display List 567 568 582 this->glyphArray[i]->width = 12; 569 583 } … … 988 1002 989 1003 TextEngine::checkVersion(); 990 Font::initDefaultFont();991 1004 } 992 1005 else -
trunk/src/lib/graphics/text_engine.h
r5336 r5337 177 177 178 178 /** @returns a Pointer to the Array of Glyphs */ 179 inline Glyph** getGlyphArray() const { return glyphArray; };179 inline Glyph** getGlyphArray() const { return this->glyphArray; }; 180 180 /** @returns the texture to the fast-texture */ 181 inline GLuint getFastTextureID() const { return fastTextureID; };181 inline GLuint getFastTextureID() const { return this->fastTextureID; }; 182 182 /** @returns the default Font */ 183 183 inline static Font* getDefaultFont() { return Font::defaultFont; };
Note: See TracChangeset
for help on using the changeset viewer.