Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 31, 2005, 11:45:30 AM (20 years ago)
Author:
bensch
Message:

orxonox/textEngine: doxygen tags, some minor fix

File:
1 edited

Legend:

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

    r3693 r3694  
    9797}
    9898
     99//! A simple variable for checking if ttf was initialized
    99100bool GLFont::ttfInitialized = false;
    100101
    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*/
    102107bool GLFont::init(const char* fontFile, unsigned int fontSize)
    103108{
     
    120125}
    121126
    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*/
    123132bool GLFont::setFont(const char* fontFile)
    124133{
     
    132141        {
    133142          PRINTF(1)("TTF_OpenFont: %s\n", TTF_GetError());
    134           // handle error
     143          return false;
    135144      }
     145      return true;
    136146    }
    137147  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*/
    142158void GLFont::setText(const char* text)
    143159{
     
    171187}
    172188
     189/**
     190   \brief Sets a new Size to the font
     191   \param fontSize The new Size in pixels.
     192*/
    173193void GLFont::setSize(unsigned int fontSize)
    174194{
     
    176196}
    177197
     198/**
     199   \brief sets a new color to the font
     200   \param r Red
     201   \param g Green
     202   \param b Blue
     203*/
    178204void GLFont::setColor(Uint8 r, Uint8 g, Uint8 b)
    179205{
     
    183209}
    184210
    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*/
    186216void GLFont::setPosition(int x, int y)
    187217{
     
    190220}
    191221
     222/**
     223   \brief draws the Font
     224   \todo FIX this is to slow/static
     225*/
    192226void GLFont::draw(void)
    193227{
     
    197231  glBegin(GL_QUADS);
    198232  glTexCoord2f(0, 0); glVertex2i(20,   20  );
    199   glTexCoord2f(1, 0); glVertex2i(200, 20  );
    200   glTexCoord2f(1, 1); glVertex2i(200,   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);
    202236  glEnd();
    203237  this->leave2DMode();
     
    206240
    207241
    208 
     242/**
     243   \brief creates a texture out of the given parameters
     244*/
    209245void GLFont::createTexture(void)
    210246{
     
    213249  if (tmpSurf)
    214250    this->texture = loadTexture(tmpSurf, texcoord);
     251
     252  this->textPosSize.w = tmpSurf->w;
     253  this->textPosSize.h = tmpSurf->h;
     254  SDL_FreeSurface(tmpSurf);
    215255}
    216256
     
    261301   for more info about vertical Fonts
    262302*/
    263 glyph GLFont::getGlyphMetrics(Uint16 character)
    264 {
    265   glyph rg;
     303Glyph GLFont::getGlyphMetrics(Uint16 character)
     304{
     305  Glyph rg;
    266306  rg.character = character;
    267307  TTF_GlyphMetrics(this->font, rg.character,
     
    276316}
    277317
    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*/
     323void GLFont::enter2DMode(void)
    286324{
    287325  SDL_Surface *screen = SDL_GetVideoSurface();
     
    314352}
    315353
    316 
    317 void GLFont::leave2DMode()
     354/**
     355   \brief leaves the 2DMode again also \see GLFont::enter2DMode(void)
     356*/
     357void GLFont::leave2DMode(void)
    318358{
    319359        glMatrixMode(GL_MODELVIEW);
     
    326366}
    327367
    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*/
    329374GLuint GLFont::loadTexture(SDL_Surface *surface, GLfloat *texcoord)
    330375{
     
    432477
    433478
    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*/
    435484int GLFont::powerOfTwo(int input)
    436485{
     
    444493
    445494
    446 
     495/**
     496   \brief a simple function to get some interesting information about this class
     497*/
    447498void GLFont::debug(void)
    448499{
Note: See TracChangeset for help on using the changeset viewer.