Changeset 3700 in orxonox.OLD for orxonox/branches/textEngine/src/lib/graphics/font/glfont.cc
- Timestamp:
- Mar 31, 2005, 9:28:09 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/textEngine/src/lib/graphics/font/glfont.cc
r3696 r3700 128 128 129 129 this->setFont(fontFile); 130 131 this->setColor(0, 255, 0); 130 132 131 133 this->setText(FONT_DEFAULT_TEXT); … … 239 241 glEnable(GL_TEXTURE_2D); 240 242 glBegin(GL_QUADS); 241 glTexCoord2f( 0, 0); glVertex2i(20, 20 );242 glTexCoord2f( 1, 0); glVertex2i(20+this->textPosSize.w, 20 );243 glTexCoord2f( 1, 1); glVertex2i(20+this->textPosSize.w, 20+this->textPosSize.h);244 glTexCoord2f( 0, 1); glVertex2i(20, 20+this->textPosSize.h);243 glTexCoord2f(this->texCoord.minU, this->texCoord.minV); glVertex2i(20, 20 ); 244 glTexCoord2f(this->texCoord.maxU, this->texCoord.minV); glVertex2i(20+this->textPosSize.w, 20 ); 245 glTexCoord2f(this->texCoord.maxU, this->texCoord.maxV); glVertex2i(20+this->textPosSize.w, 20+this->textPosSize.h); 246 glTexCoord2f(this->texCoord.minU, this->texCoord.maxV); glVertex2i(20, 20+this->textPosSize.h); 245 247 glEnd(); 246 248 this->leave2DMode(); … … 254 256 void GLFont::createTexture(void) 255 257 { 256 GLfloat texcoord[4];257 258 SDL_Surface* tmpSurf; 258 259 if (this->texture) … … 260 261 tmpSurf = TTF_RenderText_Blended(this->font, this->text, this->color); 261 262 if (tmpSurf) 262 this->texture = loadTexture(tmpSurf, texcoord);263 this->texture = loadTexture(tmpSurf, &texCoord); 263 264 264 265 this->textPosSize.w = tmpSurf->w; … … 343 344 glDisable(GL_DEPTH_TEST); 344 345 glDisable(GL_CULL_FACE); 346 glDisable(GL_LIGHTING); // will be set back when leaving 2D-mode 345 347 glEnable(GL_TEXTURE_2D); 346 348 347 349 /* This allows alpha blending of 2D textures with the scene */ 348 350 glEnable(GL_BLEND); … … 381 383 \brief Loads a Font from an SDL_surface into a texture. 382 384 \param surface The surface to make the texture of 383 \param tex coord The texture coordinates of the 4 corners of the texture385 \param texCoord The texture coordinates of the 4 corners of the texture 384 386 \returns the ID of the texture 385 387 */ 386 GLuint GLFont::loadTexture(SDL_Surface *surface, GLfloat *texcoord)388 GLuint GLFont::loadTexture(SDL_Surface *surface, TexCoord* texCoord) 387 389 { 388 390 GLuint texture; … … 396 398 w = powerOfTwo(surface->w); 397 399 h = powerOfTwo(surface->h); 398 tex coord[0] = 0.0f; /* Min X */399 tex coord[1] = 0.0f; /* Min Y */400 tex coord[2] = (GLfloat)surface->w / w; /* Max X */401 tex coord[3] = (GLfloat)surface->h / h; /* Max Y */400 texCoord->minU = 0.0f; 401 texCoord->minV = 0.0f; 402 texCoord->maxU = (GLfloat)surface->w / w; 403 texCoord->maxV = (GLfloat)surface->h / h; 402 404 403 405 image = SDL_CreateRGBSurface(
Note: See TracChangeset
for help on using the changeset viewer.