Changeset 3700 in orxonox.OLD for orxonox/branches/textEngine/src/lib/graphics/font
- Timestamp:
- Mar 31, 2005, 9:28:09 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
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( -
orxonox/branches/textEngine/src/lib/graphics/font/glfont.h
r3696 r3700 17 17 #define FONT_DEFAULT_COLOR_G 256 //!< the default red green (color) of the text 18 18 #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. 20 20 21 21 … … 37 37 int bearingY; //!< How much is above the Origin 38 38 int advance; //!< How big a Glyph would be in monospace-mode 39 }; 40 41 //! A Struct to handel Texture Coordinates for quads 42 struct 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 39 48 }; 40 49 … … 73 82 SDL_Rect textPosSize; //!< An SDL-Rectangle representing the position and size of the Text on the screen. 74 83 int renderStyle; //!< The Renderstyle 75 GLfloat* texcoord; //!< Texture-coordinates \todo fix this to have a struct84 TexCoord texCoord; //!< Texture-coordinates \todo fix this to have a struct 76 85 77 86 bool init(const char* fontFile, unsigned int fontSize = FONT_DEFAULT_SIZE); … … 88 97 static bool checkVersion(void); 89 98 90 GLuint loadTexture(SDL_Surface* surface, GLfloat* texcoord);99 GLuint loadTexture(SDL_Surface* surface, TexCoord* texCoord); 91 100 92 101 static int powerOfTwo(int input);
Note: See TracChangeset
for help on using the changeset viewer.