GLFont2d.h

Go to the documentation of this file.
00001 ////////////////////////////////////////////////////////////////////////////////
00002 //    Scorched3D (c) 2000-2009
00003 //
00004 //    This file is part of Scorched3D.
00005 //
00006 //    Scorched3D is free software; you can redistribute it and/or modify
00007 //    it under the terms of the GNU General Public License as published by
00008 //    the Free Software Foundation; either version 2 of the License, or
00009 //    (at your option) any later version.
00010 //
00011 //    Scorched3D is distributed in the hope that it will be useful,
00012 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //    GNU General Public License for more details.
00015 //
00016 //    You should have received a copy of the GNU General Public License
00017 //    along with Scorched3D; if not, write to the Free Software
00018 //    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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 /* _GLFONT2D_H_ */

Generated on Mon Feb 16 15:14:44 2009 for Scorched3D by  doxygen 1.5.3