mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-11-01 07:00:04 +00:00
Create a text shader and font utility
This commit is contained in:
parent
817a59f741
commit
82b265b6d4
11 changed files with 473 additions and 5 deletions
51
scwx-qt/source/scwx/qt/util/font.hpp
Normal file
51
scwx-qt/source/scwx/qt/util/font.hpp
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
#pragma once
|
||||
|
||||
#include <scwx/qt/util/gl.hpp>
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
namespace scwx
|
||||
{
|
||||
namespace qt
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
|
||||
struct Glyph
|
||||
{
|
||||
GLuint textureId;
|
||||
glm::ivec2 size; // pixels
|
||||
glm::ivec2 bearing; // pixels
|
||||
GLint advance; // 1/64 pixels
|
||||
};
|
||||
|
||||
class FontImpl;
|
||||
|
||||
class Font
|
||||
{
|
||||
public:
|
||||
explicit Font(const std::string& resource);
|
||||
~Font();
|
||||
|
||||
Font(const Font&) = delete;
|
||||
Font& operator=(const Font&) = delete;
|
||||
|
||||
Font(Font&&) = delete;
|
||||
Font& operator=(Font&&) = delete;
|
||||
|
||||
void GenerateGlyphs(OpenGLFunctions& gl,
|
||||
std::unordered_map<char, Glyph>& glyphs,
|
||||
unsigned int height);
|
||||
|
||||
static std::shared_ptr<Font> Create(const std::string& resource);
|
||||
|
||||
private:
|
||||
std::unique_ptr<FontImpl> p;
|
||||
};
|
||||
|
||||
} // namespace util
|
||||
} // namespace qt
|
||||
} // namespace scwx
|
||||
Loading…
Add table
Add a link
Reference in a new issue