Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4458 in orxonox.OLD for orxonox/trunk/src/lib/graphics/text_engine.h


Ignore:
Timestamp:
Jun 1, 2005, 11:51:44 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: graphicsEngine and TextEngine documented

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/graphics/text_engine.h

    r3845 r4458  
    6060struct TexCoord
    6161{
    62   float minU;                      //!< The minimum U-Coordinate
    63   float maxU;                      //!< The maximum U-Coordinate
    64   float minV;                      //!< The minimum V-Coordinate
    65   float maxV;                      //!< The maximum V-Coordinate
     62  float    minU;              //!< The minimum U-Coordinate
     63  float    maxU;              //!< The maximum U-Coordinate
     64  float    minV;              //!< The minimum V-Coordinate
     65  float    maxV;              //!< The maximum V-Coordinate
    6666};
    6767
     
    7373{
    7474  // Glyph-specific (size and so on)
    75   Uint16 character;              //!< The character
    76   int minX;                      //!< The minimum distance from the origin in X
    77   int maxX;                      //!< The maximum distance from the origin in X
    78   int minY;                      //!< The minimum distance from the origin in Y
    79   int maxY;                      //!< The maximum distance from the origin in Y
    80   int width;                     //!< The width of the Glyph
    81   int height;                    //!< The height of the Glyph
    82   int bearingX;                  //!< How much is right of the Origin
    83   int bearingY;                  //!< How much is above the Origin
    84   int advance;                   //!< How big a Glyph would be in monospace-mode
     75  Uint16   character;         //!< The character
     76  int      minX;              //!< The minimum distance from the origin in X
     77  int      maxX;              //!< The maximum distance from the origin in X
     78  int      minY;              //!< The minimum distance from the origin in Y
     79  int      maxY;              //!< The maximum distance from the origin in Y
     80  int      width;             //!< The width of the Glyph
     81  int      height;            //!< The height of the Glyph
     82  int      bearingX;          //!< How much is right of the Origin
     83  int      bearingY;          //!< How much is above the Origin
     84  int      advance;           //!< How big a Glyph would be in monospace-mode
    8585 
    8686  // OpenGL-specific
    8787  //  TexCoord texCoord;         //!< A Texture Coordinate for this glyph.
    88   GLuint displayList;            //!< DiplayList to render this Glyph.
     88  GLuint displayList;         //!< DiplayList to render this Glyph.
    8989};
    9090
     
    110110  // Static Text
    111111  void setColor(Uint8 r, Uint8 g, Uint8 b);
    112   void setStyle(char* renderStyle);
    113112
    114113  void createTexture();
     
    120119 private:
    121120  Text(Font* font, int type = TEXT_DYNAMIC);
    122 
    123   Font* font;
    124 
    125   int type;                      //!< The type of this Font.
    126   char* text;                    //!< The text to display
    127   SDL_Color color;               //!< The color of the font.
    128   TEXT_ALIGNMENT alignment;      //!< The aignment of the text.
    129   float blending;                //!< The blending intensity.
     121 
     122  static GLuint loadTexture(SDL_Surface* surface, TexCoord* texCoord);
     123  static int powerOfTwo(int input);
     124
     125 private:
     126  Font*             font;           //!< Font of this text
     127
     128  int               type;           //!< The type of this Font.
     129  char*             text;           //!< The text to display
     130  SDL_Color         color;          //!< The color of the font.
     131  TEXT_ALIGNMENT    alignment;      //!< The aignment of the text.
     132  float             blending;       //!< The blending intensity.
     133
    130134  // placement in openGL
    131   GLuint texture;                //!< A GL-texture to hold the text
    132   TexCoord texCoord;             //!< Texture-coordinates \todo fix this to have a struct
    133   SDL_Rect posSize;              //!< An SDL-Rectangle representing the position and size of the Text on the screen.
    134  
    135   PNode* bindNode;               //!< A node the Text is bind to. (if NULL thr node will not be bound to anything.)
     135  GLuint            texture;        //!< A GL-texture to hold the text
     136  TexCoord          texCoord;       //!< Texture-coordinates \todo fix this to have a struct
     137  SDL_Rect          posSize;        //!< An SDL-Rectangle representing the position and size of the Text on the screen.
     138 
     139  PNode*            bindNode;       //!< A node the Text is bind to. (if NULL thr node will not be bound to anything.)
    136140};
    137141
     
    143147{
    144148  friend class Text;
     149
    145150 public:
    146   Font(const char* fontFile, unsigned int fontSize = FONT_DEFAULT_SIZE,
    147        Uint8 r = FONT_DEFAULT_COLOR_R, Uint8 g = FONT_DEFAULT_COLOR_G, Uint8 b = FONT_DEFAULT_COLOR_B);
     151  Font(const char* fontFile,
     152       unsigned int fontSize = FONT_DEFAULT_SIZE,
     153       Uint8 r = FONT_DEFAULT_COLOR_R,
     154       Uint8 g = FONT_DEFAULT_COLOR_G,
     155       Uint8 b = FONT_DEFAULT_COLOR_B);
     156
    148157  virtual ~Font();
    149158
     
    152161  void setSize(unsigned int fontSize);
    153162  void setFastColor(Uint8 r, Uint8 g, Uint8 b);
    154   void setStyle(char* renderStyle);
    155 
    156   inline Glyph** getGlyphArray(void) {return glyphArray;}
    157   inline GLuint getFastTextureID(void) {return fastTextureID;}
    158  
    159  
    160  private:
    161   // general purpose
    162   GLdouble projMat[16];             //!< The Projection Matrix
    163 
    164   // information about the Font
    165   TTF_Font* font;                   //!< The font we use for this.
    166   char* fontFile;                   //!< The fontfile from whitch the font was loaded.
    167   unsigned int fontSize;            //!< The size of the font in pixels. each Font has one size.
    168   int renderStyle;                  //!< The Renderstyle
    169  
    170   Glyph** glyphArray;               //!< An Array of all the Glyphs stored in the Array of Glyphs.
    171   GLuint fastTextureID;             //!< The fast textureID.
    172   SDL_Color fastColor;              //!< A Color for the fast Texture.
    173 
    174   tList<Text>* textList;
    175 
     163  void setStyle(const char* renderStyle);
     164
     165  /** \returns a Pointer to the Array of Glyphs */
     166  inline Glyph** getGlyphArray(void) const {return glyphArray;}
     167  /** \returns the texture to the fast-texture */
     168  inline GLuint getFastTextureID(void) const {return fastTextureID;}
     169 
     170 private:
    176171  int getMaxHeight(void);
    177172  int getMaxAscent(void);
     
    186181  void debug(void);
    187182
    188 };
    189 GLuint loadTexture(SDL_Surface* surface, TexCoord* texCoord);
    190 int powerOfTwo(int input);
    191 
     183 private:
     184  // general purpose
     185  GLdouble      projMat[16];         //!< The Projection Matrix
     186
     187  // information about the Font
     188  TTF_Font*     font;                //!< The font we use for this.
     189  char*         fontFile;            //!< The fontfile from whitch the font was loaded.
     190  unsigned int  fontSize;            //!< The size of the font in pixels. each Font has one size.
     191  int           renderStyle;         //!< The Renderstyle
     192 
     193  Glyph**       glyphArray;          //!< An Array of all the Glyphs stored in the Array of Glyphs.
     194  GLuint        fastTextureID;       //!< The fast textureID.
     195  SDL_Color     fastColor;           //!< A Color for the fast Texture.
     196
     197  tList<Text>*  textList;            //!< A list of texts this Font is mapped to.
     198};
    192199
    193200///////////////////
     
    224231  static bool checkVersion(void);
    225232
    226 
     233 private:
    227234  //  tList<Font>* fontList;
    228   tList<Text>* textList;
     235  tList<Text>*       textList;      //!< a list of all texts of the textEngine
    229236
    230237};
Note: See TracChangeset for help on using the changeset viewer.