-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathText.hpp
More file actions
52 lines (42 loc) · 1001 Bytes
/
Text.hpp
File metadata and controls
52 lines (42 loc) · 1001 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#pragma once
#include <string>
#include "gltext.h"
#include "Color.hpp"
struct Text : DrawableObject
{
float X, Y;
GLTtext* _Text = nullptr;
Color _Color { 255, 255, 255, 255 };
std::string TextString;
Text(float InX, float InY, std::string InText, Color InColor)
{
X = InX;
Y = InY;
_Text = gltCreateText();
TextString = InText;
SetText(InText);
SetColor(InColor);
}
void SetText(std::string InText)
{
if (InText == TextString)
return;
TextString = InText;
gltSetText(_Text, InText.c_str());
}
void operator=(std::string InText)
{
return SetText(InText);
}
void SetColor(Color c)
{
_Color = c;
}
virtual void Draw(std::shared_ptr<ShaderProgram> Shader) override
{
gltBeginDraw();
gltColor(_Color.R, _Color.G, _Color.B, _Color.A);
gltDrawText2D(_Text, X, Y, 1.0f);
gltEndDraw();
}
};