-
Notifications
You must be signed in to change notification settings - Fork 3
/
PanelComponent.h
62 lines (48 loc) · 1.21 KB
/
PanelComponent.h
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
53
54
55
56
57
58
59
60
61
62
#pragma once
#include <VrLib/Texture.h>
#include <VrLib/tien/components/MeshRenderer.h>
#include <VrLib/gl/FBO.h>
namespace vrlib
{
class Texture;
class TrueTypeFont;
namespace gl
{
class FBO;
}
}
class PanelComponent : public vrlib::tien::Component, public vrlib::tien::components::MeshRenderer::Mesh
{
class FboToTexture : public vrlib::Texture
{
public:
vrlib::gl::FBO* fbo;
FboToTexture(vrlib::gl::FBO* fbo) : fbo(fbo), vrlib::Texture(nullptr)
{
}
inline void bind() override
{
fbo->use();
}
};
public:
glm::vec4 clearColor;
vrlib::gl::FBO* fbo;
vrlib::gl::FBO* backFbo;
enum class FontUniform
{
projectionMatrix,
modelMatrix,
s_texture,
color,
};
static vrlib::gl::Shader<FontUniform>* fontShader;
static std::map<std::pair<std::string, float>, vrlib::TrueTypeFont*> fonts;
PanelComponent(const glm::vec2 &size, const glm::ivec2 &res);
~PanelComponent();
void clear();
void swap();
bool drawText(const glm::vec2 &position, const std::string &font, const std::string &text, const glm::vec4 &color, float size);
bool drawImage(const std::string &image,const glm::vec2 &position, const glm::vec2 &size);
virtual nlohmann::json toJson(nlohmann::json &meshes) const;
};