Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 31, 2005, 9:28:09 PM (19 years ago)
Author:
bensch
Message:

orxonox/branches/textEngine: coloring issue, now the color is set right, and a little plastic surgery on the texCoord (struct instead of float*)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/textEngine/src/lib/graphics/font/glfont.cc

    r3696 r3700  
    128128
    129129  this->setFont(fontFile);
     130
     131  this->setColor(0, 255, 0);
    130132
    131133  this->setText(FONT_DEFAULT_TEXT);
     
    239241  glEnable(GL_TEXTURE_2D);
    240242  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);
    245247  glEnd();
    246248  this->leave2DMode();
     
    254256void GLFont::createTexture(void)
    255257{
    256   GLfloat texcoord[4];
    257258  SDL_Surface* tmpSurf;
    258259  if (this->texture)
     
    260261  tmpSurf = TTF_RenderText_Blended(this->font, this->text, this->color);
    261262  if (tmpSurf)
    262     this->texture = loadTexture(tmpSurf, texcoord);
     263    this->texture = loadTexture(tmpSurf, &texCoord);
    263264
    264265  this->textPosSize.w = tmpSurf->w;
     
    343344  glDisable(GL_DEPTH_TEST);
    344345  glDisable(GL_CULL_FACE);
     346  glDisable(GL_LIGHTING);  // will be set back when leaving 2D-mode
    345347  glEnable(GL_TEXTURE_2D);
    346  
     348
    347349  /* This allows alpha blending of 2D textures with the scene */
    348350  glEnable(GL_BLEND);
     
    381383   \brief Loads a Font from an SDL_surface into a texture.
    382384   \param surface The surface to make the texture of
    383    \param texcoord The texture coordinates of the 4 corners of the texture
     385   \param texCoord The texture coordinates of the 4 corners of the texture
    384386   \returns the ID of the texture
    385387*/
    386 GLuint GLFont::loadTexture(SDL_Surface *surface, GLfloat *texcoord)
     388GLuint GLFont::loadTexture(SDL_Surface *surface, TexCoord* texCoord)
    387389{
    388390  GLuint texture;
     
    396398  w = powerOfTwo(surface->w);
    397399  h = powerOfTwo(surface->h);
    398   texcoord[0] = 0.0f;                   /* Min X */
    399   texcoord[1] = 0.0f;                   /* Min Y */
    400   texcoord[2] = (GLfloat)surface->w / w;        /* Max X */
    401   texcoord[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;
    402404 
    403405  image = SDL_CreateRGBSurface(
Note: See TracChangeset for help on using the changeset viewer.