- Timestamp:
- Mar 31, 2005, 4:34:05 PM (20 years ago)
- Location:
- orxonox/branches/textEngine/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/textEngine/src/lib/graphics/font/glfont.cc
r3694 r3696 53 53 #include "debug.h" 54 54 55 GLFont::GLFont(const char* fontFile, unsigned int fontSize) 56 { 57 this->init(fontFile, fontSize); 58 } 59 55 /** 56 \brief constructs a Font 57 \param fontFile the File to load the font from 58 */ 59 GLFont::GLFont(const char* fontFile) 60 { 61 this->init(fontFile); 62 } 63 64 /** 65 \brief destructs a font 66 */ 60 67 GLFont::~GLFont(void) 61 68 { … … 65 72 66 73 /** 67 \ function to enable TTF_Fonts74 \brief function to enable TTF_Fonts 68 75 */ 69 76 void GLFont::enableFonts(void) … … 113 120 this->font = NULL; 114 121 this->fontFile = NULL; 115 122 this->text = NULL; 123 this->texture = 0; 116 124 117 125 this->setSize(fontSize); … … 121 129 this->setFont(fontFile); 122 130 123 this->setText( FONT_DEFAULT_TEXT); 124 131 this->setText(FONT_DEFAULT_TEXT); 132 133 this->createTexture(); 125 134 } 126 135 … … 158 167 void GLFont::setText(const char* text) 159 168 { 169 if (this->text) 170 delete []this->text; 160 171 this->text = new char[strlen(text)+1]; 161 172 strcpy(this->text, text); 162 163 this->createTexture();164 173 } 165 174 … … 216 225 void GLFont::setPosition(int x, int y) 217 226 { 218 this-> positionX= x;219 this-> positionY= y;227 this->textPosSize.x = x; 228 this->textPosSize.y = y; 220 229 } 221 230 … … 246 255 { 247 256 GLfloat texcoord[4]; 248 SDL_Surface* tmpSurf = TTF_RenderText_Blended(this->font, this->text, this->color); 257 SDL_Surface* tmpSurf; 258 if (this->texture) 259 glDeleteTextures(1, &this->texture); 260 tmpSurf = TTF_RenderText_Blended(this->font, this->text, this->color); 249 261 if (tmpSurf) 250 262 this->texture = loadTexture(tmpSurf, texcoord); … … 446 458 } 447 459 448 460 /** 461 \brief Quick utility function for texture creation 462 \param input an integer 463 \returns the next bigger 2^n-integer than input 464 */ 465 int GLFont::powerOfTwo(int input) 466 { 467 int value = 1; 468 469 while ( value < input ) { 470 value <<= 1; 471 } 472 return value; 473 } 474 475 476 /** 477 \brief checks if the compiled version and the local version of SDL_ttf match. 478 \returns true if match, false otherwise 479 */ 449 480 bool GLFont::checkVersion(void) 450 481 { … … 475 506 } 476 507 477 478 479 /**480 \brief Quick utility function for texture creation481 \param input an integer482 \returns the next bigger 2^n-integer than input483 */484 int GLFont::powerOfTwo(int input)485 {486 int value = 1;487 488 while ( value < input ) {489 value <<= 1;490 }491 return value;492 }493 508 494 509 -
orxonox/branches/textEngine/src/lib/graphics/font/glfont.h
r3694 r3696 43 43 { 44 44 public: 45 GLFont(const char* fontFile , unsigned int fontSize = FONT_DEFAULT_SIZE);45 GLFont(const char* fontFile); 46 46 virtual ~GLFont(); 47 47 … … 59 59 void createTexture(void); 60 60 61 void renderText(void);62 void renderText(const char* text, int x, int y);63 64 61 virtual void draw(void); 65 62 66 63 private: 67 64 // information about the Font 68 TTF_Font* font; 69 char* fontFile; 70 char* text; 71 unsigned int fontSize; 72 SDL_Color color; 65 TTF_Font* font; //!< The font we use for this. 66 char* fontFile; //!< The fontfile from whitch the font was loaded. 67 char* text; //!< The text to display 68 unsigned int fontSize; //!< The size of the font in pixels 69 SDL_Color color; //!< The color of the font. 73 70 74 71 // placement in openGL 75 GLuint texture; 76 SDL_Rect textPosSize; //!< A SDL-Rectangle representing the position and size of the Text on the screen. 77 int positionX; 78 int positionY; 79 int width; 80 int height; 81 int renderStyle; 82 SDL_Surface* surface; 83 GLfloat* texcoord; 72 GLuint texture; //!< A GL-texture to hold the text 73 SDL_Rect textPosSize; //!< An SDL-Rectangle representing the position and size of the Text on the screen. 74 int renderStyle; //!< The Renderstyle 75 GLfloat* texcoord; //!< Texture-coordinates \todo fix this to have a struct 84 76 85 77 bool init(const char* fontFile, unsigned int fontSize = FONT_DEFAULT_SIZE); -
orxonox/branches/textEngine/src/story_entities/world.cc
r3695 r3696 203 203 testFont = new FontSet(); 204 204 testFont->buildFont("../data/pictures/font.tga"); 205 tmpFont = new GLFont("../data/fonts/refluxed.ttf" , 50);205 tmpFont = new GLFont("../data/fonts/refluxed.ttf"); 206 206 this->glmis->step(); 207 207
Note: See TracChangeset
for help on using the changeset viewer.