Files
panopainter/engine/font.h

41 lines
731 B
C++

#pragma once
#include "texture.h"
#include "util.h"
enum class kFont : uint16_t
{
Arial_11 = const_hash("arial-16"),
};
class Font
{
public:
const int w = 512;
const int h = 512;
const int num_chars = 96;
const int start_char = 32;
stbtt_fontinfo font;
Texture2D font_tex;
std::vector<stbtt_bakedchar> chars;
bool load(const char* ttf);
};
class FontManager
{
static std::map<kFont, Font> m_fonts;
public:
static bool load(kFont id, const char* ttf);
static const Font& get(kFont id);
};
class TextMesh
{
public:
GLuint font_array = 0;
int font_array_count = 0;
GLuint font_buffers[2] = {0, 0};
bool create();
void update(kFont id, const char* text);
};