libsegl/glfontengine.h

72 lines
1.6 KiB
C
Raw Normal View History

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"
#include "glcolor.h"
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;
GLColor col;
// 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);
void setColor(GLColor);
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
};
#endif