Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3696 in orxonox.OLD for orxonox/branches/textEngine/src


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

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

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

    r3694 r3696  
    4343{
    4444 public:
    45   GLFont(const char* fontFile, unsigned int fontSize = FONT_DEFAULT_SIZE);
     45  GLFont(const char* fontFile);
    4646  virtual ~GLFont();
    4747
     
    5959  void createTexture(void);
    6060 
    61   void renderText(void);
    62   void renderText(const char* text, int x, int y);
    63 
    6461  virtual void draw(void);
    6562
    6663 private:
    6764  // 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.
    7370
    7471  // 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
    8476
    8577  bool init(const char* fontFile, unsigned int fontSize = FONT_DEFAULT_SIZE);
  • orxonox/branches/textEngine/src/story_entities/world.cc

    r3695 r3696  
    203203      testFont = new FontSet();
    204204      testFont->buildFont("../data/pictures/font.tga");
    205       tmpFont = new GLFont("../data/fonts/refluxed.ttf", 50);
     205      tmpFont = new GLFont("../data/fonts/refluxed.ttf");
    206206      this->glmis->step();
    207207
Note: See TracChangeset for help on using the changeset viewer.