2009-01-21 01:00:31 +01:00
|
|
|
/* libsegl - Sebas Extended GL Library
|
|
|
|
* Collection of Opengl/3D-Math helpers
|
|
|
|
*
|
|
|
|
* Copyright (c) 2008 by Sebastian Lohff, seba@seba-geek.de
|
|
|
|
* http://www.seba-geek.de
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library 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
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
2008-02-09 13:43:23 +01:00
|
|
|
#ifndef __GLFONTENGINE_H
|
|
|
|
#define __GLFONTENGINE_H
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#include <map>
|
|
|
|
#include <cmath>
|
|
|
|
|
|
|
|
|
|
|
|
#include <SDL.h>
|
|
|
|
#include <SDL_opengl.h>
|
|
|
|
#include "gltexture.h"
|
2008-08-10 17:14:54 +02:00
|
|
|
#include "color.h"
|
|
|
|
|
|
|
|
namespace segl {
|
2008-02-09 13:43:23 +01:00
|
|
|
|
|
|
|
class GLFont {
|
|
|
|
public:
|
|
|
|
GLFont(std::string fontfile, float cwdth) {
|
|
|
|
charwidth = cwdth;
|
|
|
|
font = new GLTexture(fontfile);
|
|
|
|
}
|
|
|
|
~GLFont() {
|
|
|
|
delete(font);
|
|
|
|
}
|
|
|
|
GLTexture* font;
|
|
|
|
float charwidth;
|
|
|
|
};
|
|
|
|
|
|
|
|
class GLFontEngine {
|
|
|
|
private:
|
|
|
|
static std::map<std::string, GLFont*> fontpool;
|
|
|
|
|
|
|
|
GLFont *font;
|
|
|
|
bool fontloaded;
|
2008-08-10 17:14:54 +02:00
|
|
|
Color col;
|
2008-02-09 13:43:23 +01:00
|
|
|
// float r, g, b, a;
|
|
|
|
int fsize;
|
|
|
|
|
|
|
|
void init();
|
|
|
|
public:
|
|
|
|
static bool addFont(std::string fontfile, std::string fontname);
|
|
|
|
static void quit();
|
|
|
|
|
|
|
|
static void prepare2DbyPushingMatrix();
|
|
|
|
static void regain3DbyPoppingMatrix();
|
|
|
|
static void paintSDLRect(SDL_Rect);
|
|
|
|
|
|
|
|
GLFontEngine();
|
|
|
|
GLFontEngine(std::string);
|
|
|
|
bool fontSelect(std::string);
|
|
|
|
void setColor(float, float, float, float=1.0f);
|
2008-08-10 17:14:54 +02:00
|
|
|
void setColor(Color);
|
2008-02-09 13:43:23 +01:00
|
|
|
|
|
|
|
void renderText(std::string, SDL_Rect); // wrapper
|
|
|
|
// void renderText(std::string, int x, int y, *SDL_Rect=0, bool center=false);
|
|
|
|
// void renderLines(std::string, int x, int y,
|
|
|
|
|
|
|
|
void renderLine(std::string, SDL_Rect);
|
|
|
|
void renderLine(std::string, int x, int y, bool center=false, SDL_Rect *rendered_to=0);
|
|
|
|
void renderLines(std::string, int x, int y, bool center=false, SDL_Rect *rendered_to=0, int wrap=0, int paintbackground=0);
|
|
|
|
|
|
|
|
void setSize(int);
|
|
|
|
int getSize();
|
|
|
|
void getSDLRect(const std::string&, SDL_Rect*);
|
|
|
|
int getTextWidth(const std::string&);
|
2008-03-31 13:00:13 +02:00
|
|
|
int getTextWidthbyInt(int length);
|
2008-02-09 13:43:23 +01:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2008-08-10 17:14:54 +02:00
|
|
|
} // namespace segl
|
2008-02-09 13:43:23 +01:00
|
|
|
|
|
|
|
#endif
|