Changeset 3694 in orxonox.OLD for orxonox/branches/textEngine/src/lib/graphics/font/glfont.cc
- Timestamp:
- Mar 31, 2005, 11:45:30 AM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/textEngine/src/lib/graphics/font/glfont.cc
r3693 r3694 97 97 } 98 98 99 //! A simple variable for checking if ttf was initialized 99 100 bool GLFont::ttfInitialized = false; 100 101 101 102 /** 103 \brief initializes a new Font 104 \param fontFile The file to load a Font from 105 \param fontSize the Size in pixels of the Font 106 */ 102 107 bool GLFont::init(const char* fontFile, unsigned int fontSize) 103 108 { … … 120 125 } 121 126 122 127 /** 128 \brief sets The Font. 129 \param fontFile The file containing the font. 130 \returns true if loaded, false if something went wrong, or if a font was loaded before. 131 */ 123 132 bool GLFont::setFont(const char* fontFile) 124 133 { … … 132 141 { 133 142 PRINTF(1)("TTF_OpenFont: %s\n", TTF_GetError()); 134 // handle error143 return false; 135 144 } 145 return true; 136 146 } 137 147 else 138 PRINTF(2)("Font already initialized, unable to change it now.\n"); 139 } 140 141 148 { 149 PRINTF(2)("Font already initialized, unable to change it now.\n"); 150 return false; 151 } 152 } 153 154 /** 155 \brief Sets a new Text to the font 156 \param text the new text to set 157 */ 142 158 void GLFont::setText(const char* text) 143 159 { … … 171 187 } 172 188 189 /** 190 \brief Sets a new Size to the font 191 \param fontSize The new Size in pixels. 192 */ 173 193 void GLFont::setSize(unsigned int fontSize) 174 194 { … … 176 196 } 177 197 198 /** 199 \brief sets a new color to the font 200 \param r Red 201 \param g Green 202 \param b Blue 203 */ 178 204 void GLFont::setColor(Uint8 r, Uint8 g, Uint8 b) 179 205 { … … 183 209 } 184 210 185 211 /** 212 \brief sets a Position. 213 \param x the x-position in pixels from the left border 214 \param y the y-position in pixels from the top border 215 */ 186 216 void GLFont::setPosition(int x, int y) 187 217 { … … 190 220 } 191 221 222 /** 223 \brief draws the Font 224 \todo FIX this is to slow/static 225 */ 192 226 void GLFont::draw(void) 193 227 { … … 197 231 glBegin(GL_QUADS); 198 232 glTexCoord2f(0, 0); glVertex2i(20, 20 ); 199 glTexCoord2f(1, 0); glVertex2i(20 0, 20 );200 glTexCoord2f(1, 1); glVertex2i(20 0, 80);201 glTexCoord2f(0, 1); glVertex2i(20, 80);233 glTexCoord2f(1, 0); glVertex2i(20+this->textPosSize.w, 20 ); 234 glTexCoord2f(1, 1); glVertex2i(20+this->textPosSize.w, 20+this->textPosSize.h); 235 glTexCoord2f(0, 1); glVertex2i(20, 20+this->textPosSize.h); 202 236 glEnd(); 203 237 this->leave2DMode(); … … 206 240 207 241 208 242 /** 243 \brief creates a texture out of the given parameters 244 */ 209 245 void GLFont::createTexture(void) 210 246 { … … 213 249 if (tmpSurf) 214 250 this->texture = loadTexture(tmpSurf, texcoord); 251 252 this->textPosSize.w = tmpSurf->w; 253 this->textPosSize.h = tmpSurf->h; 254 SDL_FreeSurface(tmpSurf); 215 255 } 216 256 … … 261 301 for more info about vertical Fonts 262 302 */ 263 glyph GLFont::getGlyphMetrics(Uint16 character)264 { 265 glyph rg;303 Glyph GLFont::getGlyphMetrics(Uint16 character) 304 { 305 Glyph rg; 266 306 rg.character = character; 267 307 TTF_GlyphMetrics(this->font, rg.character, … … 276 316 } 277 317 278 void GLFont::renderText(void) 279 { 280 281 } 282 283 284 285 void GLFont::enter2DMode() 318 /** 319 \brief entering 2D Mode 320 321 this is a GL-Projection-mode, that is orthogonal, for placing the font in fron of everything else 322 */ 323 void GLFont::enter2DMode(void) 286 324 { 287 325 SDL_Surface *screen = SDL_GetVideoSurface(); … … 314 352 } 315 353 316 317 void GLFont::leave2DMode() 354 /** 355 \brief leaves the 2DMode again also \see GLFont::enter2DMode(void) 356 */ 357 void GLFont::leave2DMode(void) 318 358 { 319 359 glMatrixMode(GL_MODELVIEW); … … 326 366 } 327 367 328 368 /** 369 \brief Loads a Font from an SDL_surface into a texture. 370 \param surface The surface to make the texture of 371 \param texcoord The texture coordinates of the 4 corners of the texture 372 \returns the ID of the texture 373 */ 329 374 GLuint GLFont::loadTexture(SDL_Surface *surface, GLfloat *texcoord) 330 375 { … … 432 477 433 478 434 /* Quick utility function for texture creation */ 479 /** 480 \brief Quick utility function for texture creation 481 \param input an integer 482 \returns the next bigger 2^n-integer than input 483 */ 435 484 int GLFont::powerOfTwo(int input) 436 485 { … … 444 493 445 494 446 495 /** 496 \brief a simple function to get some interesting information about this class 497 */ 447 498 void GLFont::debug(void) 448 499 {
Note: See TracChangeset
for help on using the changeset viewer.