00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef _GLFONT2D_H_
00022 #define _GLFONT2D_H_
00023
00024 #include <common/Vector.h>
00025 #include <common/Vector4.h>
00026 #include <lang/LangString.h>
00027 #include <GLEXT/GLFont2dStorage.h>
00028
00029 class GLFont2dFreeType;
00030 class GLFont2dI;
00031 class GLFont2d
00032 {
00033 public:
00034 GLFont2d();
00035 ~GLFont2d();
00036
00037 bool createFont(const std::string &typeFace, unsigned int h, bool makeShadow = false);
00038
00039 void draw(Vector &color, float size,
00040 float x, float y, float z,
00041 const LangString &text);
00042 void drawA(Vector &color, float alpha, float size,
00043 float x, float y, float z,
00044 const LangString &text);
00045 void drawA(GLFont2dI *handler, Vector &color, float alpha, float size,
00046 float x, float y, float z,
00047 const LangString &text);
00048 void drawWidth(float width,
00049 Vector &color, float size,
00050 float x, float y, float z,
00051 const LangString &text);
00052 void drawWidthRhs(float width,
00053 Vector &color, float size,
00054 float x, float y, float z,
00055 const LangString &text);
00056 void drawSubStr(int start, int len,
00057 Vector &color, float size,
00058 float x, float y, float z,
00059 const LangString &text);
00060 void drawSubStrA(int start, int len,
00061 Vector &color, float alpha, float size,
00062 float x, float y, float z,
00063 const LangString &text);
00064 void drawBilboard(Vector &color, float alpha, float size,
00065 float x, float y, float z,
00066 const LangString &text);
00067
00068 float getWidth(float size, const LangString &text, int len = 0);
00069 int getChars(float size, const LangString &text, float width);
00070
00071 void draw(Vector &color, float size,
00072 float x, float y, float z,
00073 const std::string &text);
00074 void drawA(Vector &color, float alpha, float size,
00075 float x, float y, float z,
00076 const std::string &text);
00077 void drawA(GLFont2dI *handler, Vector &color, float alpha, float size,
00078 float x, float y, float z,
00079 const std::string &text);
00080 void drawWidth(float width,
00081 Vector &color, float size,
00082 float x, float y, float z,
00083 const std::string &text);
00084 void drawWidthRhs(float width,
00085 Vector &color, float size,
00086 float x, float y, float z,
00087 const std::string &text);
00088 void drawSubStr(int start, int len,
00089 Vector &color, float size,
00090 float x, float y, float z,
00091 const std::string &text);
00092 void drawSubStrA(int start, int len,
00093 Vector &color, float alpha, float size,
00094 float x, float y, float z,
00095 const std::string &text);
00096 void drawBilboard(Vector &color, float alpha, float size,
00097 float x, float y, float z,
00098 const std::string &text);
00099
00100 float getWidth(float size, const std::string &text, int len = 0);
00101 int getChars(float size, const std::string &text, float width);
00102
00103 static unsigned int getTotalCharacters() { return totalCharacters_; }
00104
00105 protected:
00106 static unsigned int totalCharacters_;
00107 GLFont2dFreeType *freetype_;
00108 GLFont2dStorage characters_;
00109 LangString langText_;
00110 float height_;
00111
00112 GLFont2dStorage::CharEntry *getCharacter(unsigned int character);
00113
00114 void drawLetter(GLFont2dStorage::CharEntry *entry);
00115
00116 bool drawString(unsigned len,
00117 Vector &color, float alpha,
00118 float size,
00119 float x, float y, float z,
00120 const unsigned int *string,
00121 bool bilboard);
00122 bool drawStringHandler(unsigned length,
00123 GLFont2dI *handler,
00124 Vector &color, float alpha,
00125 float size,
00126 float x, float y, float z,
00127 const unsigned int *string);
00128 };
00129
00130 class GLFont2dI
00131 {
00132 public:
00133 virtual void drawCharacter(
00134 int charPosition, Vector &position,
00135 GLFont2dStorage::CharEntry &charEntry, Vector4 &color) = 0;
00136 };
00137
00138 #endif