Changeset 5339 in orxonox.OLD for trunk/src/lib/graphics/text_engine.cc
- Timestamp:
- Oct 9, 2005, 11:25:04 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/graphics/text_engine.cc
r5337 r5339 453 453 454 454 this->fastTextureID = this->createFastTexture(); 455 456 457 // this->createAsciiImage("test.bmp"); 455 458 } 456 459 … … 472 475 if (xpmArray != NULL) 473 476 this->loadFontFromXPMArray(xpmArray); 477 474 478 } 475 479 … … 569 573 glNewList(glyph->displayList, GL_COMPILE); // Start Building A List 570 574 glBegin(GL_QUADS); // Use A Quad For Each Character 571 glTexCoord2f(cx, 1.0f-cy-0.0625f); // Texture Coord (Bottom Left)572 glVertex2d(0, 16); // Vertex Coord (Bottom Left)573 glTexCoord2f(cx+0.0625f, 1.0f-cy-0.0625f); // Texture Coord (Bottom Right)574 glVertex2i(16, 16); // Vertex Coord (Bottom Right)575 glTexCoord2f(cx+0.0625f, 1.0f-cy-0.001f); // Texture Coord (Top Right)575 glTexCoord2f(cx, cy+0.001f); // Texture Coord (Bottom Left) 576 glVertex2d(0,-16); // Vertex Coord (Bottom Left) 577 glTexCoord2f(cx+0.0625f, cy+0.001f); // Texture Coord (Bottom Right) 578 glVertex2i(16,-16); // Vertex Coord (Bottom Right) 579 glTexCoord2f(cx+0.0625f, cy+0.0625f); // Texture Coord (Top Right) 576 580 glVertex2i(16,0); // Vertex Coord (Top Right) 577 glTexCoord2f(cx, 1.0f-cy-0.001f); // Texture Coord (Top Left)581 glTexCoord2f(cx, cy+0.0625f); // Texture Coord (Top Left) 578 582 glVertex2i(0,0); // Vertex Coord (Top Left) 579 583 glEnd(); // Done Building Our Quad (Character) … … 621 625 622 626 Font* Font::defaultFont = NULL; 627 628 void Font::createAsciiImage(const char* fileName) 629 { 630 if (this->font == NULL) 631 return; 632 int height = this->getMaxHeight(); 633 634 // 635 SDL_Color tmpColor = {0, 0, 0}; 636 // Surface definition. 637 SDL_Rect tmpRect; // this represents a Rectangle for blitting. 638 SDL_Surface* tmpSurf = SDL_CreateRGBSurface(SDL_SWSURFACE, 639 height*16, height*16, 640 32, 641 #if SDL_BYTEORDER == SDL_LIL_ENDIAN /* OpenGL RGBA masks */ 642 0x000000FF, 643 0x0000FF00, 644 0x00FF0000, 645 0xFF000000 646 #else 647 0xFF000000, 648 0x00FF0000, 649 0x0000FF00, 650 0x000000FF 651 #endif 652 ); 653 tmpRect.x = 0; tmpRect.y = 0; tmpRect.w = tmpSurf->w; tmpRect.h = tmpSurf->h; 654 SDL_SetClipRect(tmpSurf, &tmpRect); 655 int maxLineHeight = 0; 656 657 int posX, posY; 658 // all the interessting Glyphs 659 for (posY = 0; posY < 16; posY++) 660 { 661 for (posX = 0; posX < 16; posX++) 662 { 663 SDL_Surface* glyphSurf = NULL; 664 if (likely(this->font != NULL)) 665 { 666 SDL_Color white = {255, 255, 255}; 667 glyphSurf = TTF_RenderGlyph_Blended(this->font, posX+16*posY, white); 668 } 669 if( glyphSurf != NULL ) 670 { 671 tmpRect.x = height*posX; 672 tmpRect.y = height*posY; 673 SDL_SetAlpha(glyphSurf, 0, 0); 674 675 SDL_BlitSurface(glyphSurf, NULL, tmpSurf, &tmpRect); 676 SDL_FreeSurface(glyphSurf); 677 // Outputting Glyphs to BMP-files. 678 /* 679 char outname[512]; 680 if (i < 10) 681 sprintf( outname, "%s-glyph-00%d.bmp", this->getName(), i ); 682 else if (i <100) 683 sprintf( outname, "%s-glyph-0%d.bmp", this->getName(), i ); 684 else 685 sprintf( outname, "%s-glyph-%d.bmp", this->getName(), i ); 686 SDL_SaveBMP(tmpSurf, outname);*/ 687 688 } 689 } 690 } 691 SDL_SaveBMP(tmpSurf, fileName); 692 SDL_FreeSurface(tmpSurf); 693 } 694 623 695 /** 624 696 * initializes the default font … … 747 819 748 820 // all the interessting Glyphs 749 for (int i = 0; i < = 127; i++)821 for (int i = 0; i < 128; i++) 750 822 { 751 823 SDL_Surface* glyphSurf = NULL; … … 882 954 { 883 955 x = 0; y = 0; 884 for (i = 0; i < FONT_HIGHEST_KNOWN_CHAR; i++)956 for (i = 0; i <= FONT_HIGHEST_KNOWN_CHAR; i++) 885 957 { 886 if( tmpGlyph = this->glyphArray[i])958 if((tmpGlyph = this->glyphArray[i]) != NULL) 887 959 { 888 960 // getting the height of the highest Glyph in the Line. … … 902 974 } 903 975 } 904 if (i == FONT_HIGHEST_KNOWN_CHAR)976 if (i >= FONT_HIGHEST_KNOWN_CHAR-1 || size > 8192) 905 977 sizeOK = true; 906 978 else
Note: See TracChangeset
for help on using the changeset viewer.