Changeset 4536 in orxonox.OLD for orxonox/trunk
- Timestamp:
- Jun 7, 2005, 10:33:17 AM (19 years ago)
- Location:
- orxonox/trunk/src/lib/graphics
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/graphics/graphics_engine.cc
r4519 r4536 302 302 if( unlikely(this->currentFPS < this->minFPS)) this->minFPS = this->currentFPS; 303 303 304 #ifndef NO_TEXT 304 305 char tmpChar1[20]; 305 306 sprintf(tmpChar1, "Current: %4.0f", this->currentFPS); … … 311 312 sprintf(tmpChar3, "Min: %4.0f", this->minFPS); 312 313 this->geTextMinFPS->setText(tmpChar3); 314 #endif /* NO_TEXT */ 313 315 } 314 316 } … … 324 326 if( display) 325 327 { 328 #ifndef NO_TEXT 326 329 this->geTextCFPS = TextEngine::getInstance()->createText("fonts/druid.ttf", 35, TEXT_DYNAMIC, 0, 255, 0); 327 330 this->geTextCFPS->setAlignment(TEXT_ALIGN_LEFT); … … 333 336 this->geTextMinFPS->setAlignment(TEXT_ALIGN_LEFT); 334 337 this->geTextMinFPS->setPosition(5, 560); 338 #endif /* NO_TEXT */ 335 339 } 336 340 this->bDisplayFPS = display; -
orxonox/trunk/src/lib/graphics/graphics_engine.h
r4519 r4536 76 76 float minFPS; //!< minimal frame rate we ever got since start 77 77 78 #ifndef NO_TEXT 78 79 Text* geTextCFPS; //!< Text for the current FPS 79 80 Text* geTextMaxFPS; //!< Text for the max FPS 80 81 Text* geTextMinFPS; //!< Text for the min FPS 81 82 #endif /* NO_TEXT */ 82 83 }; 83 84 -
orxonox/trunk/src/lib/graphics/text_engine.cc
r4519 r4536 91 91 void Text::setType(int type) 92 92 { 93 this->type = type; 94 } 95 93 if (this->font->font) 94 this->type = type; 95 else 96 this->type = TEXT_DYNAMIC; 97 } 96 98 97 99 /** … … 163 165 164 166 this has to be called every time by the user, to if changes were made. 167 this is only for TEXT_STATIC-mode 165 168 */ 166 169 void Text::createTexture(void) … … 169 172 if (this->texture) 170 173 glDeleteTextures(1, &this->texture); 171 tmpSurf = TTF_RenderText_Blended(this->font->font, 172 this->text, 173 this->color); 174 if (likely(this->font != NULL)) 175 tmpSurf = TTF_RenderText_Blended(this->font->font, 176 this->text, 177 this->color); 174 178 if (tmpSurf) 175 179 this->texture = loadTexture(tmpSurf, &this->texCoord); … … 424 428 425 429 // erease this font out of the memory. 426 if ( this->font)430 if (likely(this->font != NULL)) 427 431 TTF_CloseFont(this->font); 428 432 } … … 441 445 442 446 this->font = TTF_OpenFont(this->fontFile, this->fontSize); 443 if(!this->font) 447 if(!this->font) 444 448 { 445 449 PRINTF(1)("TTF_OpenFont: %s\n", TTF_GetError()); … … 447 451 } 448 452 else 449 return true;453 return true; 450 454 } 451 455 else … … 473 477 this->renderStyle |= TTF_STYLE_UNDERLINE; 474 478 475 if ( this->font)479 if (likely(this->font != NULL)) 476 480 TTF_SetFontStyle(this->font, this->renderStyle); 477 481 else 478 482 PRINTF(2)("Font was not initialized, please do so before setting the Font-Style.\n"); 479 483 } 480 481 482 484 483 485 /** … … 508 510 int Font::getMaxHeight(void) 509 511 { 510 if ( this->font)512 if (likely (this->font != NULL)) 511 513 return TTF_FontHeight(this->font); 512 514 else … … 521 523 int Font::getMaxAscent(void) 522 524 { 523 if ( this->font)525 if (likely(this->font != NULL)) 524 526 return TTF_FontAscent(this->font); 525 527 else … … 534 536 int Font::getMaxDescent(void) 535 537 { 536 if ( this->font)538 if (likely(this->font != NULL)) 537 539 return TTF_FontDescent(this->font); 538 540 else … … 553 555 Glyph* rg = new Glyph; 554 556 rg->character = character; 555 TTF_GlyphMetrics(this->font, rg->character, 556 &rg->minX, &rg->maxX, 557 &rg->minY, &rg->maxY, 558 &rg->advance); 557 if (likely (this->font!= NULL)) 558 TTF_GlyphMetrics(this->font, rg->character, 559 &rg->minX, &rg->maxX, 560 &rg->minY, &rg->maxY, 561 &rg->advance); 559 562 rg->height = rg->maxY - rg->minY; 560 563 rg->width = rg->maxX - rg->minX; … … 605 608 606 609 // all the interessting Glyphs 607 for (int i = 32; i <= 122; i++)610 for (int i = 0; i <= 127; i++) 608 611 { 609 612 SDL_Surface* glyphSurf = NULL; … … 627 630 } 628 631 // reading in the new Glyph 629 glyphSurf = TTF_RenderGlyph_Blended(this->font, i, this->fastColor); 630 if( glyphSurf ) 632 if (likely(this->font != NULL)) 633 glyphSurf = TTF_RenderGlyph_Blended(this->font, i, this->fastColor); 634 if( glyphSurf != NULL ) 631 635 { 632 636 … … 671 675 } 672 676 } 677 SDL_SaveBMP(tmpSurf, "text"); 673 678 674 679 GLuint texture; … … 723 728 724 729 This function searches for a 2^n sizes texture-size, this is for 725 openGL-version < 1.2 compatibility . and because it is realy easy like this.730 openGL-version < 1.2 compatibility ( and because it is realy easy like this :)) 726 731 */ 727 732 int Font::findOptimalFastTextureSize(void) … … 764 769 } 765 770 return size; 766 767 771 } 768 772 … … 773 777 void Font::debug(void) 774 778 { 775 776 779 // print the loaded font's style 777 780 int style; 778 style = TTF_GetFontStyle(this->font); 781 if (likely(this->font != NULL)) 782 style = TTF_GetFontStyle(this->font); 779 783 PRINTF(0)("The font style is:"); 780 784 if(style==TTF_STYLE_NORMAL) … … 789 793 } 790 794 PRINTF(0)("\n"); 791 792 793 795 } 794 796 … … 824 826 825 827 TextEngine::singletonRef = NULL; 826 827 828 } 828 829 -
orxonox/trunk/src/lib/graphics/text_engine.h
r4519 r4536 30 30 31 31 //! An enumerator for the text alignment. 32 enum TEXT_ALIGNMENT {TEXT_ALIGN_LEFT, TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER, TEXT_ALIGN_SCREEN_CENTER}; 32 enum TEXT_ALIGNMENT { TEXT_ALIGN_LEFT, 33 TEXT_ALIGN_RIGHT, 34 TEXT_ALIGN_CENTER, 35 TEXT_ALIGN_SCREEN_CENTER }; 33 36 34 37 /* some default values */ … … 85 88 86 89 // OpenGL-specific 87 // TexCoord texCoord; 88 GLuint displayList;//!< DiplayList to render this Glyph.90 // TexCoord texCoord; //!< A Texture Coordinate for this glyph. 91 GLuint displayList; //!< DiplayList to render this Glyph. 89 92 }; 90 93
Note: See TracChangeset
for help on using the changeset viewer.