mirror of
https://github.com/devZoGok/vb01.git
synced 2026-08-26 19:43:30 +00:00
54 lines
1.2 KiB
C++
Executable File
54 lines
1.2 KiB
C++
Executable File
#ifndef TEXT_H
|
|
#define TEXT_H
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
#include "vector.h"
|
|
#include "util.h"
|
|
|
|
namespace vb01{
|
|
class Node;
|
|
class Texture;
|
|
class Shader;
|
|
class Material;
|
|
|
|
class Text{
|
|
public:
|
|
struct Glyph{
|
|
u16 ch;
|
|
Texture *texture = nullptr;
|
|
u32 advance;
|
|
Vector2 size, bearing;
|
|
};
|
|
|
|
Text(std::string, std::wstring);
|
|
~Text();
|
|
void update();
|
|
void setText(std::wstring);
|
|
inline Node* getNode(){return node;}
|
|
inline void setNode(Node *node){this->node = node;}
|
|
inline void setScale(float s){this->scale = s;}
|
|
inline int getLength(){return entry.length();}
|
|
inline std::wstring getText(){return entry;}
|
|
inline bool isHorizontal(){return horizontal;}
|
|
inline void setHorizontal(bool h){this->horizontal = h;}
|
|
inline Material* getMaterial(){return material;}
|
|
inline void setMaterial(Material *mat){this->material = mat;}
|
|
private:
|
|
void initFont(std::string);
|
|
void prepareGlyphs(Glyph, Vector2);
|
|
void renderGlyphs(Glyph, float[], u32);
|
|
Glyph* getGlyph(u16);
|
|
|
|
Node *node = nullptr;
|
|
Material *material = nullptr;
|
|
std::wstring entry;
|
|
std::vector<Glyph> characters;
|
|
unsigned int VAO, VBO;
|
|
float scale = 1;
|
|
bool horizontal = true;
|
|
};
|
|
}
|
|
|
|
#endif
|