2014-12-08 02:16:06 -05:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <string>
|
|
|
|
#include <sstream>
|
|
|
|
#include "lodepng.h"
|
|
|
|
#include "wx/glcanvas.h"
|
2015-06-01 00:04:05 -04:00
|
|
|
#include "wx/filename.h"
|
|
|
|
#include "wx/stdpaths.h"
|
2014-12-08 02:16:06 -05:00
|
|
|
|
|
|
|
class GLFontChar {
|
|
|
|
public:
|
|
|
|
GLFontChar();
|
|
|
|
~GLFontChar();
|
|
|
|
|
|
|
|
void setId(int idval);
|
|
|
|
int getId();
|
|
|
|
|
|
|
|
void setXOffset(int xofs);
|
|
|
|
int getXOffset();
|
|
|
|
|
|
|
|
void setYOffset(int yofs);
|
|
|
|
int getYOffset();
|
|
|
|
|
|
|
|
void setX(int xpos);
|
|
|
|
int getX();
|
|
|
|
|
|
|
|
void setY(int ypos);
|
|
|
|
int getY();
|
|
|
|
|
|
|
|
void setWidth(int w);
|
|
|
|
int getWidth();
|
|
|
|
|
|
|
|
void setHeight(int h);
|
|
|
|
int getHeight();
|
|
|
|
|
|
|
|
void setXAdvance(int xadv);
|
|
|
|
int getXAdvance();
|
|
|
|
|
|
|
|
float getAspect();
|
|
|
|
|
|
|
|
void setIndex(unsigned int idx);
|
|
|
|
int getIndex();
|
|
|
|
|
|
|
|
private:
|
|
|
|
int id;
|
|
|
|
int x, y, width, height;
|
|
|
|
int xoffset, yoffset;
|
|
|
|
int xadvance;
|
|
|
|
float aspect;
|
|
|
|
int index;
|
|
|
|
};
|
|
|
|
|
|
|
|
class GLFont {
|
|
|
|
public:
|
2014-12-08 20:39:38 -05:00
|
|
|
enum Align {
|
2014-12-16 21:30:03 -05:00
|
|
|
GLFONT_ALIGN_LEFT, GLFONT_ALIGN_RIGHT, GLFONT_ALIGN_CENTER, GLFONT_ALIGN_TOP, GLFONT_ALIGN_BOTTOM
|
2014-12-08 20:39:38 -05:00
|
|
|
};
|
2015-06-30 23:07:39 -04:00
|
|
|
enum GLFontSize {
|
|
|
|
GLFONT_SIZE12, GLFONT_SIZE16, GLFONT_SIZE18, GLFONT_SIZE24, GLFONT_SIZE32, GLFONT_SIZE48, GLFONT_MAX
|
|
|
|
};
|
2014-12-08 20:39:38 -05:00
|
|
|
|
2014-12-08 02:16:06 -05:00
|
|
|
GLFont();
|
|
|
|
~GLFont();
|
|
|
|
void loadFont(std::string fontFile);
|
2014-12-09 21:28:08 -05:00
|
|
|
bool isLoaded();
|
2014-12-08 19:38:38 -05:00
|
|
|
|
|
|
|
float getStringWidth(std::string str, float size, float viewAspect);
|
2014-12-08 20:39:38 -05:00
|
|
|
void drawString(std::string str, float xpos, float ypos, int pxHeight, Align hAlign = GLFONT_ALIGN_LEFT, Align vAlign = GLFONT_ALIGN_TOP);
|
2014-12-08 02:16:06 -05:00
|
|
|
|
2015-06-30 23:07:39 -04:00
|
|
|
static GLFont fonts[GLFONT_MAX];
|
|
|
|
static GLFont &getFont(GLFontSize esize);
|
|
|
|
|
2014-12-08 02:16:06 -05:00
|
|
|
private:
|
|
|
|
std::string nextParam(std::istringstream &str);
|
|
|
|
std::string getParamKey(std::string param_str);
|
|
|
|
std::string getParamValue(std::string param_str);
|
|
|
|
|
|
|
|
int numCharacters;
|
|
|
|
int lineHeight;
|
|
|
|
int base;
|
|
|
|
int imageWidth, imageHeight;
|
2014-12-09 21:28:08 -05:00
|
|
|
bool loaded;
|
2014-12-08 02:16:06 -05:00
|
|
|
|
|
|
|
std::map<int, GLFontChar *> characters;
|
|
|
|
|
|
|
|
std::vector<float> gl_vertices;
|
|
|
|
std::vector<float> gl_uv;
|
|
|
|
|
|
|
|
std::string fontName;
|
|
|
|
std::string imageFile;
|
|
|
|
std::string fontFileSource;
|
|
|
|
GLuint texId;
|
|
|
|
};
|