Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 31, 2005, 4:34:05 PM (19 years ago)
Author:
bensch
Message:

orxonox/branches/textEngine: minor change and doxy-tags

File:
1 edited

Legend:

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

    r3694 r3696  
    5353#include "debug.h"
    5454
    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*/
     59GLFont::GLFont(const char* fontFile)
     60{
     61  this->init(fontFile);
     62}
     63
     64/**
     65   \brief destructs a font
     66*/
    6067GLFont::~GLFont(void)
    6168{
     
    6572
    6673/**
    67    \function to enable TTF_Fonts
     74   \brief function to enable TTF_Fonts
    6875*/
    6976void GLFont::enableFonts(void)
     
    113120  this->font = NULL;
    114121  this->fontFile = NULL;
    115 
     122  this->text = NULL;
     123  this->texture = 0;
    116124 
    117125  this->setSize(fontSize);
     
    121129  this->setFont(fontFile);
    122130
    123   this->setText( FONT_DEFAULT_TEXT);
    124 
     131  this->setText(FONT_DEFAULT_TEXT);
     132
     133  this->createTexture();
    125134}
    126135
     
    158167void GLFont::setText(const char* text)
    159168{
     169  if (this->text)
     170    delete []this->text;
    160171  this->text = new char[strlen(text)+1];
    161172  strcpy(this->text, text);
    162 
    163   this->createTexture();
    164173}
    165174
     
    216225void GLFont::setPosition(int x, int y)
    217226{
    218   this->positionX = x;
    219   this->positionY = y;
     227  this->textPosSize.x = x;
     228  this->textPosSize.y = y;
    220229}
    221230
     
    246255{
    247256  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);
    249261  if (tmpSurf)
    250262    this->texture = loadTexture(tmpSurf, texcoord);
     
    446458}
    447459
    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*/
     465int 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*/
    449480bool GLFont::checkVersion(void)
    450481{
     
    475506}
    476507
    477 
    478 
    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 */
    484 int GLFont::powerOfTwo(int input)
    485 {
    486   int value = 1;
    487  
    488   while ( value < input ) {
    489     value <<= 1;
    490   }
    491   return value;
    492 }
    493508
    494509
Note: See TracChangeset for help on using the changeset viewer.