Changeset 7448 in orxonox.OLD for trunk/src/lib/graphics/text_engine
- Timestamp:
- Apr 29, 2006, 8:03:35 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/graphics/text_engine/text.cc
r7431 r7448 96 96 97 97 // setting up the Text-Width if DYNAMIC 98 // if (this->type & TEXT_RENDER_DYNAMIC && this->getAlignment() != TEXT_ALIGN_LEFT && this->font != NULL)98 // if (this->type & TEXT_RENDER_DYNAMIC && this->getAlignment() != TEXT_ALIGN_LEFT && this->font != NULL) 99 99 const Font* calcSizeFont = this->font; 100 100 if (calcSizeFont != NULL || (calcSizeFont = Font::getDefaultFont()) != NULL) … … 122 122 void Text::draw() const 123 123 { 124 if (unlikely(this->text.empty())) 125 return; 124 126 glPushMatrix(); 125 127 // transform for alignment. … … 135 137 glEnable(GL_TEXTURE_2D); 136 138 glBlendFunc(GL_SRC_ALPHA, GL_ONE); 137 138 139 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, GL_MODULATE ); 139 140 140 Glyph** glyphArray; 141 if (likely (this->font != NULL)) 142 { 143 glyphArray = this->font->getGlyphArray(); 144 glBindTexture(GL_TEXTURE_2D, font->getTexture()); 145 } 146 else 147 { 148 if (unlikely(Font::getDefaultFont() == NULL)) 149 Font::initDefaultFont(); 150 glyphArray = Font::getDefaultFont()->getGlyphArray(); 151 glBindTexture(GL_TEXTURE_2D, Font::getDefaultFont()->getTexture()); 152 } 153 if (likely(!this->text.empty())) 154 { 155 glTranslatef(getAbsCoor2D().x, getAbsCoor2D().y, 0); 156 glRotatef(this->getAbsDir2D(), 0, 0, 1); 157 Glyph* tmpGlyph; 158 float posX = 0.0f; 159 160 glBegin(GL_QUADS); 161 for (unsigned int i = 0; i < this->text.size(); i++) 141 Glyph** glyphArray = this->font->getGlyphArray(); 142 glBindTexture(GL_TEXTURE_2D, font->getTexture()); 143 glTranslatef(getAbsCoor2D().x, getAbsCoor2D().y, 0); 144 glRotatef(this->getAbsDir2D(), 0, 0, 1); 145 146 Glyph* tmpGlyph; 147 float posX = 0.0f; 148 glBegin(GL_QUADS); 149 for (unsigned int i = 0; i < this->text.size(); i++) 150 { 151 if(likely((tmpGlyph = glyphArray[this->text[i]]) != NULL)) 162 152 { 163 if(likely((tmpGlyph = glyphArray[this->text[i]]) != NULL)) 164 { 165 glTexCoord2f(tmpGlyph->texCoord[1], tmpGlyph->texCoord[2]); 166 glVertex2d(posX+tmpGlyph->maxX*this->getSizeY2D(), 0); 167 168 glTexCoord2f(tmpGlyph->texCoord[1], tmpGlyph->texCoord[3]); 169 glVertex2d(posX+tmpGlyph->maxX*this->getSizeY2D(), this->getSizeY2D()); 170 171 glTexCoord2f(tmpGlyph->texCoord[0], tmpGlyph->texCoord[3]); 172 glVertex2d(posX+tmpGlyph->minX*this->getSizeY2D(), this->getSizeY2D()); 173 174 glTexCoord2f(tmpGlyph->texCoord[0], tmpGlyph->texCoord[2]); 175 glVertex2d(posX+tmpGlyph->minX*this->getSizeY2D(), 0); 176 177 posX += tmpGlyph->advance * this->getSizeY2D(); 178 } 153 glTexCoord2f(tmpGlyph->texCoord[1], tmpGlyph->texCoord[2]); 154 glVertex2d(posX+tmpGlyph->maxX*this->getSizeY2D(), 0); 155 156 glTexCoord2f(tmpGlyph->texCoord[1], tmpGlyph->texCoord[3]); 157 glVertex2d(posX+tmpGlyph->maxX*this->getSizeY2D(), this->getSizeY2D()); 158 159 glTexCoord2f(tmpGlyph->texCoord[0], tmpGlyph->texCoord[3]); 160 glVertex2d(posX+tmpGlyph->minX*this->getSizeY2D(), this->getSizeY2D()); 161 162 glTexCoord2f(tmpGlyph->texCoord[0], tmpGlyph->texCoord[2]); 163 glVertex2d(posX+tmpGlyph->minX*this->getSizeY2D(), 0); 164 165 posX += tmpGlyph->advance * this->getSizeY2D(); 179 166 } 180 glEnd(); 181 } 182 167 } 168 glEnd(); 183 169 glPopMatrix(); 184 170 } … … 231 217 0xFF000000 232 218 #else 233 219 0xFF000000, 234 220 0x00FF0000, 235 221 0x0000FF00, … … 237 223 #endif 238 224 ); 239 if ( image == NULL ) { 225 if ( image == NULL ) 226 { 240 227 return 0; 241 228 } … … 244 231 saved_flags = surface->flags&(SDL_SRCALPHA|SDL_RLEACCELOK); 245 232 saved_alpha = surface->format->alpha; 246 if ( (saved_flags & SDL_SRCALPHA) == SDL_SRCALPHA ) { 233 if ( (saved_flags & SDL_SRCALPHA) == SDL_SRCALPHA ) 234 { 247 235 SDL_SetAlpha(surface, 0, 0); 248 236 } … … 256 244 257 245 /* Restore the alpha blending attributes */ 258 if ( (saved_flags & SDL_SRCALPHA) == SDL_SRCALPHA ) { 246 if ( (saved_flags & SDL_SRCALPHA) == SDL_SRCALPHA ) 247 { 259 248 SDL_SetAlpha(surface, saved_flags, saved_alpha); 260 249 }
Note: See TracChangeset
for help on using the changeset viewer.