25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

97 lines
2.5 KiB

/* 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.
*/
#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