libsegl/glfontengine.h

75 lines
1.6 KiB
C++

#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 "color.h"
namespace segl {
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;
Color 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(Color);
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&);
int getTextWidthbyInt(int length);
};
} // namespace segl
#endif