- Timestamp:
- Apr 7, 2005, 4:21:36 PM (20 years ago)
- Location:
- orxonox/branches/textEngine/src/lib/graphics/font
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/textEngine/src/lib/graphics/font/glfont.cc
r3740 r3747 112 112 this->fontFile = NULL; 113 113 this->glyphArray = NULL; 114 this->fastTextureID = 0; 114 115 115 116 this->currentText = new Text; … … 120 121 121 122 this->setSize(fontSize); 123 this->setType(TEXT_DYNAMIC); 122 124 123 125 this->currentText->renderStyle = TTF_STYLE_NORMAL; … … 134 136 this->createTexture(); 135 137 136 this-> createFastTexture();138 this->fastTextureID = this->createFastTexture(); 137 139 } 138 140 … … 169 171 } 170 172 173 /** 174 \brief sets the Type of this Text 175 \param type the type to set. 176 */ 177 void GLFont::setType(int type) 178 { 179 this->currentText->type = type; 180 } 181 171 182 172 183 /** … … 244 255 void GLFont::draw(void) 245 256 { 257 // storing all the Transformation Matrices. 246 258 GLdouble modMat[16]; 247 259 GLint viewPort[4]; … … 251 263 this->enter2DMode(); 252 264 253 265 // setting the Position of this Text. 254 266 Vector pos; 255 267 if (this->currentText->bindNode) … … 271 283 pos.z = 0; 272 284 } 273 glBindTexture(GL_TEXTURE_2D, this->currentText->texture); 274 glEnable(GL_TEXTURE_2D); 275 glBegin(GL_QUADS); 276 277 glTexCoord2f(this->currentText->texCoord.minU, this->currentText->texCoord.minV); 278 glVertex2i(pos.x, pos.y ); 279 280 glTexCoord2f(this->currentText->texCoord.maxU, this->currentText->texCoord.minV); 281 glVertex2i(pos.x + this->currentText->textPosSize.w, pos.y ); 282 283 glTexCoord2f(this->currentText->texCoord.maxU, this->currentText->texCoord.maxV); 284 glVertex2i(pos.x + this->currentText->textPosSize.w, pos.y + this->currentText->textPosSize.h); 285 286 glTexCoord2f(this->currentText->texCoord.minU, this->currentText->texCoord.maxV); 287 glVertex2i(pos.x, pos.y + this->currentText->textPosSize.h); 288 289 glEnd(); 290 285 286 // drawing this Text. 287 if(currentText->type == TEXT_STATIC) 288 { 289 glBindTexture(GL_TEXTURE_2D, this->currentText->texture); 290 glEnable(GL_TEXTURE_2D); 291 glBegin(GL_QUADS); 292 293 glTexCoord2f(this->currentText->texCoord.minU, this->currentText->texCoord.minV); 294 glVertex2i(pos.x, pos.y ); 295 296 glTexCoord2f(this->currentText->texCoord.maxU, this->currentText->texCoord.minV); 297 glVertex2i(pos.x + this->currentText->textPosSize.w, pos.y ); 298 299 glTexCoord2f(this->currentText->texCoord.maxU, this->currentText->texCoord.maxV); 300 glVertex2i(pos.x + this->currentText->textPosSize.w, pos.y + this->currentText->textPosSize.h); 301 302 glTexCoord2f(this->currentText->texCoord.minU, this->currentText->texCoord.maxV); 303 glVertex2i(pos.x, pos.y + this->currentText->textPosSize.h); 304 305 glEnd(); 306 } 307 else //(if currentText->type & TEXT_DYNAMIC) 308 { 309 glBindTexture(GL_TEXTURE_2D, this->fastTextureID); 310 // glEnable(GL_TEXTURE_2D); 311 glTranslatef(pos.x, pos.y, 0); 312 313 printf("%d, %d\n", this->fastTextureID, glyphArray[65]->displayList); 314 glCallList(glyphArray[65]->displayList); 315 } 291 316 this->leave2DMode(); 292 317 } … … 443 468 444 469 // setting default values. (maybe not needed afterwards) 445 //SDL_Color tmpColor; tmpColor.r = tmpColor.g = tmpColor.b = 0;470 SDL_Color tmpColor; tmpColor.r = tmpColor.g = tmpColor.b = 0; 446 471 // Surface definition. 447 472 SDL_Rect tmpRect; // this represents a Rectangle for blitting. … … 490 515 } 491 516 // reading in the new Glyph 492 glyphSurf = TTF_RenderGlyph_ Blended(this->font,517 glyphSurf = TTF_RenderGlyph_Shaded(this->font, 493 518 i, 494 this->currentText->color );495 //tmpColor);519 this->currentText->color, 520 tmpColor); 496 521 if( glyphSurf ) 497 522 { … … 503 528 tmpTexCoord.maxV = (float)(tmpRect.y+tmpGlyph->height)/(float)tmpSurf->w; 504 529 tmpGlyph->displayList = glGenLists(1); 530 505 531 glNewList(tmpGlyph->displayList, GL_COMPILE); 506 532 glBegin(GL_QUADS); … … 508 534 glVertex2d(0, 0); 509 535 glTexCoord2f(tmpTexCoord.minU, tmpTexCoord.maxV); 510 glVertex2d(0, 1);536 glVertex2d(0, tmpRect.y); 511 537 glTexCoord2f(tmpTexCoord.maxU, tmpTexCoord.maxV); 512 glVertex2d( 1, 1);538 glVertex2d(tmpRect.x, tmpRect.y); 513 539 glTexCoord2f(tmpTexCoord.maxU, tmpTexCoord.minV); 514 glVertex2d( 1, 0);540 glVertex2d(tmpRect.x, 0); 515 541 glEnd(); 516 542 glEndList(); -
orxonox/branches/textEngine/src/lib/graphics/font/glfont.h
r3740 r3747 26 26 27 27 #define FONT_HIGHEST_KNOWN_CHAR 128 //!< The highest character known to the textEngine. 28 29 #define TEXT_STATIC 0 //!< Static Text 30 #define TEXT_DYNAMIC 1 //!< Dynamic Text 31 /** 32 * STATIC means: a font, that is only one GL-face. 33 ** it is very fast, and can be used for all text 34 ** that does not have to be changed anymore, or if 35 ** the the text should look very nice 36 * DYNAMIC means: a very fast font, that will is build 37 ** from multiple quads. 38 ** Use this type, if you want to create fast changing 39 ** text like a counter. 40 */ 28 41 29 42 … … 78 91 // text 79 92 void setBindNode(PNode* bindNode); 93 void setType(int type); 80 94 void setText(const char* text); 81 95 void setStyle(char* renderStyle); … … 95 109 96 110 Glyph** glyphArray; //!< An Array of all the Glyphs stored in the Array of Glyphs. 111 GLuint fastTextureID; //!< The fast textureID. 97 112 98 113 //! Represents one textElement. 99 114 struct Text 100 115 { 116 int type; //!< The type of this Font. 101 117 char* text; //!< The text to display 102 118 SDL_Color color; //!< The color of the font.
Note: See TracChangeset
for help on using the changeset viewer.