1 /* ************************************************************************* * 2 OldSkoolGravityGame (OSGG) Lunar Lander-like game for linux. 3 Copyright (C) 2008 Jimmy Christensen ( dusted at dusted dot dk ) 4 5 This program is free software: you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation, either version 3 of the License, or 8 (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program. If not, see <http://www.gnu.org/licenses/>. 17 * ************************************************************************* */ 18 19 #include <iostream> 20 #include <SDL/SDL_ttf.h> 21 #include <GL/gl.h> 22 23 24 #ifndef DATADIR 25 #define DATADIR "./" 26 #endif 27 28 #define FONT_DEFAULT 0 29 #define FONT_NUM 1 30 31 using namespace std; 32 33 struct glCharInfo_struct { 34 GLfloat Xa,Ya,Xb,Yb, width; 35 }; 36 37 struct glFontInfo_struct { 38 GLuint tex; 39 GLfloat height; 40 struct glCharInfo_struct ch[255]; 41 }; 42 43 class glTextClass { 44 private: 45 void genFontTex(string TTFfontName, int fontSize, int font); 46 struct glFontInfo_struct fontInfo[FONT_NUM]; 47 48 public: 49 GLfloat getHeight(int font); 50 void write(string text, int font, GLfloat scale, GLfloat x, GLfloat y); 51 glTextClass(); 52 ~glTextClass(); 53 }; 54