Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Aug 25, 2005, 2:07:12 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: optimized TextEngine, now the chars can also be copied fast by using a const char-pointer instead of copiing the whole text-array

File:
1 edited

Legend:

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

    r5121 r5122  
    3939#define  TEXT_ALIGN_CENTER           E2D_ALIGN_CENTER
    4040#define  TEXT_ALIGN_SCREEN_CENTER    E2D_ALIGN_SCREEN_CENTER
     41#define  TEXT_DEFAULT_COLOR          Vector(1.0, 1.0, 1.0)      //!< the default Color (white)
     42#define  TEXT_DEFAULT_BLENDING       1.0f                       //!< the default blending of the text, (no blending at all)
    4143
    4244/* some default values */
    43 #define FONT_DEFAULT_SIZE       50                   //!< default size of the Text
    44 #define FONT_DEFAULT_TEXT       "orxonox 1234567890" //!< default text to display
    45 #define FONT_DEFAULT_COLOR_R    255                  //!< default red part (color) of the text
    46 #define FONT_DEFAULT_COLOR_G    255                  //!< default red green (color) of the text
    47 #define FONT_DEFAULT_COLOR_B    255                  //!< default red blue (color) of the text
    48 #define FONT_NUM_COLORS         256                  //!< number of colors.
    49 
    50 #define FONT_HIGHEST_KNOWN_CHAR 128                  //!< The highest character known to the textEngine.
    51 
    52 #define TEXT_DEFAULT_ALIGNMENT  TEXT_ALIGN_CENTER    //!< default alignment
    53 #define TEXT_STATIC             0                    //!< Static Text
    54 #define TEXT_DYNAMIC            1                    //!< Dynamic Text
     45#define FONT_DEFAULT_SIZE            50                         //!< default size of the Text
     46#define FONT_NUM_COLORS              256                        //!< number of colors.
     47
     48#define FONT_HIGHEST_KNOWN_CHAR      128                        //!< The highest character known to the textEngine.
     49
     50#define TEXT_DEFAULT_ALIGNMENT       TEXT_ALIGN_CENTER          //!< default alignment
     51
     52typedef enum TEXT_RENDER_TYPE
     53{
     54  TEXT_RENDER_STATIC      = 1,
     55  TEXT_RENDER_DYNAMIC     = 2
     56};
    5557/**
    5658 * STATIC means: a font, that is only one GL-face.
     
    103105class Text : public Element2D
    104106{
    105   friend class TextEngine;
    106107 public:
     108   Text(Font* font, TEXT_RENDER_TYPE type = TEXT_RENDER_DYNAMIC);
    107109  ~Text();
    108110
    109   void setType(int type);
    110   void setText(const char* text);
     111  void setType(TEXT_RENDER_TYPE type);
     112  void setText(const char* text, bool isExtern = false);
    111113  /** @param blending the blending intensity to set (between 0.0 and 1.0) */
    112114  inline void setBlending(float blending) { this->blending = blending; };
     
    122124
    123125 private:
    124   Text(Font* font, int type = TEXT_DYNAMIC);
    125 
    126126  static GLuint loadTexture(SDL_Surface* surface, TexCoord* texCoord);
    127127  static int powerOfTwo(int input);
     
    130130  Font*             font;           //!< Font of this text
    131131
    132   int               type;           //!< The type of this Font.
     132  TEXT_RENDER_TYPE  type;           //!< The type of this Font.
    133133  char*             text;           //!< The text to display
     134  const char*       externText;     //!< the text to Display from an external Source.
    134135  Vector            color;          //!< The color of the font.
    135136  float             blending;       //!< The blending intensity.
     
    207208  Text* createText(const char* fontFile,
    208209                   unsigned int fontSize = FONT_DEFAULT_SIZE,
    209                    int textType = TEXT_DYNAMIC);
     210                   int textType = TEXT_RENDER_DYNAMIC);
    210211
    211212  void debug() const;
Note: See TracChangeset for help on using the changeset viewer.