Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3700 in orxonox.OLD for orxonox/branches/textEngine/src/lib/graphics


Ignore:
Timestamp:
Mar 31, 2005, 9:28:09 PM (20 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*)

Location:
orxonox/branches/textEngine/src/lib/graphics/font
Files:
2 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(
  • orxonox/branches/textEngine/src/lib/graphics/font/glfont.h

    r3696 r3700  
    1717#define FONT_DEFAULT_COLOR_G    256                  //!< the default red green (color) of the text
    1818#define FONT_DEFAULT_COLOR_B    256                  //!< the default red blue (color) of the text
    19 #define FONT_NUM_COLORS         256                  //!< The number of colors. 
     19#define FONT_NUM_COLORS         256                  //!< The number of colors.
    2020
    2121
     
    3737  int bearingY;                  //!< How much is above the Origin
    3838  int advance;                   //!< How big a Glyph would be in monospace-mode
     39};
     40
     41//! A Struct to handel Texture Coordinates for quads
     42struct TexCoord
     43{
     44  float minU;                      //!< The minimum U-Coordinate
     45  float maxU;                      //!< The maximum U-Coordinate
     46  float minV;                      //!< The minimum V-Coordinate
     47  float maxV;                      //!< The maximum V-Coordinate
    3948};
    4049
     
    7382  SDL_Rect textPosSize;            //!< An SDL-Rectangle representing the position and size of the Text on the screen.
    7483  int renderStyle;                 //!< The Renderstyle
    75   GLfloat* texcoord;               //!< Texture-coordinates \todo fix this to have a struct
     84  TexCoord texCoord;               //!< Texture-coordinates \todo fix this to have a struct
    7685
    7786  bool init(const char* fontFile, unsigned int fontSize = FONT_DEFAULT_SIZE);
     
    8897  static bool checkVersion(void);
    8998
    90   GLuint loadTexture(SDL_Surface* surface, GLfloat* texcoord);
     99  GLuint loadTexture(SDL_Surface* surface, TexCoord* texCoord);
    91100
    92101  static int powerOfTwo(int input);
Note: See TracChangeset for help on using the changeset viewer.