00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef _FONT_H
00026 #define _FONT_H
00027
00028 #ifdef WIN32
00029 #include <windows.h>
00030 #endif
00031
00032
00033 #include <string>
00034 #include <vector>
00035 #include "GLee.h"
00036 #include "color.h"
00037 #include "renderer.h"
00038 #include <SDL/SDL_ttf.h>
00039
00040
00041
00042
00043 namespace ngn {
00044
00045
00046
00047 namespace core {
00048
00049 class NGN_API Font
00050 {
00051 public:
00052
00053
00054 Font();
00055 Font( const Font& other );
00056
00057
00058 bool load( const std::string& freetype_font, int size );
00059
00060 void destroy();
00061
00062
00063 void print( int x, int y, const char* txt );
00064
00065
00066 void setColor( const Colorf& color );
00067
00068
00069 bool isLoaded() const;
00070
00071 int getSize() const;
00072
00073 const Colorf& getColor() const;
00074
00075
00076 int getLineSkip() const;
00077
00078
00079
00080 private:
00081
00082 void createTexture( SDL_Surface* text, GLfloat *texcoord );
00083 int pow2( int i );
00084
00085 std::string m_fontfile;
00086 Colorf m_color;
00087 int m_size;
00088 TTF_Font* m_font;
00089 GLuint m_texid[1];
00090 bool m_loaded;
00091
00092 };
00093
00094 }
00095
00096
00097
00105 class NGN_API FontManager
00106 {
00107 public:
00108 FontManager();
00109 FontManager( const FontManager& other );
00110
00112 bool init();
00114 void destroy();
00115
00117 unsigned int addFont( const std::string& freetype_font, int size, const core::Colorf& color );
00119 void removeFont( unsigned int ID );
00121 void print( unsigned int fontID, int x, int y, const char* str, ... );
00123 int getLineSkip( unsigned int fontID );
00124
00125 private:
00126
00127 void println();
00128
00129 class line
00130 {
00131 public:
00132 line();
00133 line( const line& other );
00134 virtual ~line();
00135
00136 unsigned int font;
00137 int x,y;
00138 std::string msg;
00139 };
00140
00141 static std::vector<core::Font*> m_vec;
00142 static std::vector<line> m_ln;
00143
00144 friend class gl::Renderer;
00145
00146
00147 };
00148
00149
00150
00151
00152
00153
00154
00155 }
00156 #endif
00157
00158
00159
00160
00161