Page principale | Hiérarchie des classes | Liste alphabétique | Liste des classes | Liste des fichiers | Membres de classe

C:/Projects/ngn/include/font.h

00001 /***************************************************************************
00002  *            font.h
00003  *
00004  *  Sat May  1 13:07:53 2004
00005  *  Copyright  2004  tite
00006  *  thierry.schartz@bluebottle.com
00007  ****************************************************************************/
00008 
00009 /*
00010  *  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version.
00014  *
00015  *  This program is distributed in the hope that it will be useful,
00016  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  *  GNU Library General Public License for more details.
00019  *
00020  *  You should have received a copy of the GNU General Public License
00021  *  along with this program; if not, write to the Free Software
00022  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
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                         //constructor
00054                         Font();
00055                         Font( const Font& other );
00056                         
00057                         // init font
00058                         bool load( const std::string& freetype_font, int size );
00059                         // destroy mem
00060                         void destroy();
00061 
00062                         // print something at (x,y) position
00063                         void print( int x, int y, const char* txt );
00064 
00065                         // set font color
00066                         void setColor( const Colorf& color );
00067                         
00068                         // is font loaded
00069                         bool isLoaded() const;
00070                         // get font size
00071                         int getSize() const;
00072                         // get font color
00073                         const Colorf& getColor() const;
00074                         
00075                         // get font line skip value
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; // the font file
00086                         Colorf m_color;                 // font color
00087                         int m_size;                             // font size
00088                         TTF_Font* m_font;               // TTF_Font
00089                         GLuint m_texid[1];              // texture id
00090                         bool m_loaded;                  // font is loaded
00091                 
00092                 };
00093 
00094         }// core
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                     // print all lines
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;  // font vector
00142                         static std::vector<line> m_ln;                  // line vector
00143 
00144                         friend class gl::Renderer;
00145 
00146 
00147                 };
00148 
00149 
00150 
00151 
00152 
00153 
00154 
00155 }//ngn
00156 #endif /* _FONT_H */
00157 
00158 
00159 
00160 
00161 

Généré le Fri Nov 19 14:20:29 2004 pour NGN par  doxygen 1.3.9.1