/* ******************************************************************************** Copyright 2006, 2007 Ben Ruyl This file is part of Sokoban 3D. Sokoban 3D is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Sokoban 3D is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Sokoban 3D; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ******************************************************************************** */ #include // Header File For Windows #include #include #include // Header File For The OpenGL32 Library #include // Header File For The GLu32 Library #include #include "text.h" #include "texture.h" #include "freetype.h" #include "sokomain.h" #include "menumain.h" #include "language.h" #include #include //int base = 0; freetype::font_data our_font; GLvoid KillFont(GLvoid) // Delete The Font From Memory { // our_font.clean(); // glDeleteLists(base,256); // Delete All 256 Display Lists } GLvoid BuildFont() { string path = stAppDirectory + "Data/font/font.ttf"; our_font.init(path.c_str(), 16); } void glprintline(wstring line) { glPushMatrix(); if (RTL) { float width = GetTextWidth(line.c_str(), 16); glTranslatef(-width * 400, 0, 0); } // for (int i = 0; i < line.length(); i++) for (int i = 0; i < line.length(); i++) { int z = i; if (RTL) z = line.length() - 1 - i; if (line[z] <= 0x007F) glCallList(our_font.list_base + line[z]); else { for (int k = 0; k < charlist_extended.size(); k++) if (charlist_extended[k].charcode == line[z]) glCallList(charlist_extended[k].listpos); } } glPopMatrix(); } void print(const freetype::font_data &ft_font, float x, float y, int fontsize, int pickname, wchar_t *text) { // We want a coordinate system where things coresponding to window pixels. // pushScreenCoordinateMatrix(); GLuint font=ft_font.list_base; float h=ft_font.h;///.63f; //We make the height about 1.5* that of const wchar_t *start_line=text; wchar_t *c; vector lines; for(c=text;*c;c++) { if (*c=='@') //(*c=='\n') { { wstring line; for(const wchar_t *n=start_line;n -1) glPushName(pickname); //glCallLists(strlen(text), GL_UNSIGNED_BYTE, text); // wstring test = text; glprintline(lines[i]); // glCallLists(lines[i].length(), GL_UNSIGNED_BYTE, lines[i].c_str()); if (pickname > -1) glPopName(); // float rpos[4]; // glGetFloatv(GL_CURRENT_RASTER_POSITION ,rpos); // float len=x-rpos[0]; glPopMatrix(); } glPopAttrib(); glDisable(GL_BLEND); glEnable(GL_DEPTH_TEST); glDisable(GL_TEXTURE_2D); } GLvoid glPrint(GLfloat x, GLfloat y, int fontsize, int pickname, const wchar_t *fmt, ...) { wchar_t text[256]; // Holds Our String va_list ap; // Pointer To List Of Arguments if (fmt == NULL) // If There's No Text *text=0; // Do Nothing else { va_start(ap, fmt); // Parses The String For Variables vswprintf(text, fmt, ap); // And Converts Symbols To Actual Numbers va_end(ap); // Results Are Stored In Text } print(our_font, x, y, fontsize, pickname, (wchar_t*) text); } /*GLvoid glSinusPrint(GLfloat x, GLfloat y, char *string) { glPushMatrix(); glTranslatef(x,y,0); // glListBase(base-32+(128*1)); glScalef(float(12/16.000f), float(12/16.000f), 1); float z = x; float wave; for (int i = 0; i < strlen(string); i++) { glPushMatrix(); wave = TabSin[int(z+scrollx) % 360]; glTranslatef(z, 30*wave, 0); GLuint font=our_font.list_base; float h=our_font.h/.63f; glListBase(font); glCallLists(1, GL_BYTE, &string[i]); z += 15; glPopMatrix(); } glPopMatrix(); }*/