text.h

Go to the documentation of this file.
00001 
00002 //            Copyright (C) 2004-2007 by The Allacrost Project
00003 //                         All Rights Reserved
00004 //
00005 // This code is licensed under the GNU GPL version 2. It is free software 
00006 // and you may modify it and/or redistribute it under the terms of this license.
00007 // See http://www.gnu.org/copyleft/gpl.html for details.
00009 
00019 #ifndef __TEXT_HEADER__
00020 #define __TEXT_HEADER__
00021 
00022 #include "defs.h"
00023 #include "utils.h"
00024 
00025 typedef struct _TTF_Font TTF_Font;
00026 
00027 namespace hoa_video {
00028 
00030 enum TEXT_SHADOW_STYLE {
00031   VIDEO_TEXT_SHADOW_INVALID = -1,
00032 
00034   VIDEO_TEXT_SHADOW_NONE = 0,
00036   VIDEO_TEXT_SHADOW_DARK = 1,
00038   VIDEO_TEXT_SHADOW_LIGHT = 2,
00040   VIDEO_TEXT_SHADOW_BLACK = 3,
00042   VIDEO_TEXT_SHADOW_COLOR = 4,
00044   VIDEO_TEXT_SHADOW_INVCOLOR = 5,
00045 
00046   VIDEO_TEXT_SHADOW_TOTAL = 6
00047 };
00048 
00052 class FontGlyph {
00053 public:
00055   GLuint texture;
00057   int32 width;
00059   int32 height;
00061   int min_x;
00063   int min_y;
00065   float max_x;
00067   float max_y;
00069   int32 advance;
00071   int top_y;
00072 }; // class FontGlyph
00073 
00074 
00078 class FontProperties {
00079 public:
00081   int32 height;
00083   int32 line_skip;
00085   int32 ascent;
00087   int32 descent;
00089   int32 shadow_x;
00091   int32 shadow_y;
00093   TEXT_SHADOW_STYLE shadow_style;
00095   TTF_Font* ttf_font;
00097   std::map<uint16, FontGlyph*>* glyph_cache;
00098 }; // class FontProperties
00099 
00103 class RenderedLine {
00104 private:
00106         RenderedLine(const RenderedLine &other);
00108         RenderedLine &operator=(const RenderedLine &other);
00109 public:
00111   enum
00112   {
00113     MAIN_TEXTURE   = 0,
00114     SHADOW_TEXTURE = 1,
00115     NUM_TEXTURES   = 2,
00116   };
00118   int32 height;
00120   float v;
00122   int32 width;
00124   float u;
00126   GLuint texture[NUM_TEXTURES];
00128   int32 x_offset;
00130   int32 y_offset;
00132   RenderedLine(GLuint *tex, 
00133          int32 lineWidth,  int32 texWidth,
00134          int32 lineHeight, int32 texHeight, 
00135          int32 xOffset,    int32 yOffset);
00137   ~RenderedLine();
00138 }; // class RenderedLine
00139 
00140 
00144 class RenderedString {
00145 private:
00147   int32 _width;
00149   int32 _line_skip;
00151   int32 _shadow_xoff;
00153   int32 _shadow_yoff;
00154 public:
00156   std::vector<RenderedLine*> lines;
00158   RenderedString(int32 line_skip, int32 shadowX = 0, int32 shadowY = 0);
00160   ~RenderedString();
00162   bool Draw() const;
00164   bool Add(RenderedLine *line);
00166   int32 GetLineSkip() const { return _line_skip; };
00168   int32 GetWidth() const { return _width; };
00170   int32 GetShadowX() const { return _shadow_xoff; };
00172   int32 GetShadowY() const { return _shadow_yoff; };
00174   void SetShadowX(int32 xoff) { _shadow_xoff = xoff; };
00176   void SetShadowY(int32 yoff) { _shadow_yoff = yoff; };
00177 }; // class RenderedString
00178 
00179 }  // namespace hoa_video
00180 
00181 
00182 #endif

Generated on Fri Jul 6 23:11:25 2007 for Hero of Allacrost by  doxygen 1.5.1