-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGUIRenderer.cpp
More file actions
52 lines (40 loc) · 1.84 KB
/
GUIRenderer.cpp
File metadata and controls
52 lines (40 loc) · 1.84 KB
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
#include "GUIRenderer.h"
#include "GUISystem.h"
#include "GUIPanel.h"
#include "GUIButton.h"
#include "GUILabel.h"
#include "GUITextField.h"
#include "QuadRenderer.h"
#include "TextRenderer.h"
void GUIRenderer::RenderGUIVisitor::Visit(GUIPanel *component)
{
QuadRenderer::GetInstance().AddQuad(component->GetNormalizedPositionCenter(), component->GetNormalizedDimensions(), component->GetColor(), component->GetOpacity(), component->GetTexture());
}
void GUIRenderer::RenderGUIVisitor::Visit(GUIButton *component)
{
QuadRenderer::GetInstance().AddQuad(component->GetNormalizedPositionCenter(), component->GetNormalizedDimensions(), component->GetColor(), component->GetOpacity(), component->GetTexture());
}
void GUIRenderer::RenderGUIVisitor::Visit(GUILabel *component)
{
QuadRenderer::GetInstance().AddQuad(component->GetNormalizedPositionCenter(), component->GetNormalizedDimensions(), component->GetColor(), component->GetOpacity(), nullptr);
TextRenderer::GetInstance().AddText(component->GetText());
}
void GUIRenderer::RenderGUIVisitor::Visit(GUITextField *component)
{
QuadRenderer::GetInstance().AddQuad(component->GetNormalizedPositionCenter(), component->GetNormalizedDimensions(), component->GetBackgroundColor(), component->GetOpacity(), nullptr);
TextRenderer::GetInstance().AddText(component->GetText());
}
void GUIRenderer::Render()
{
GraphicsSystem::GetInstance().SetDepthStencilState(GraphicsSystem::DepthStencilState::DISABLED);
RenderGUIVisitor visitor;
for (auto it = GUISystem::GetInstance().GetGUIs()->begin(); it != GUISystem::GetInstance().GetGUIs()->end(); ++it)
{
if (!(*it)->IsVisible())
continue;
(*it)->GetRoot()->AcceptPreorder(visitor);
QuadRenderer::GetInstance().Render();
TextRenderer::GetInstance().Render();
}
GraphicsSystem::GetInstance().SetDepthStencilState(GraphicsSystem::DepthStencilState::ENABLED);
}