-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRenderer.cpp
More file actions
84 lines (73 loc) · 1.45 KB
/
Copy pathRenderer.cpp
File metadata and controls
84 lines (73 loc) · 1.45 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include "PCH.h"
#include "Renderer.h"
#include "imgui.h"
#include "imgui-SFML.h"
#include <iostream>
Renderer::Renderer()
{
window.create(sf::VideoMode(1, 1), "ShellProtector", sf::Style::Close);
window.setVisible(false);
window_visibility = false;
std::cout << "Window Init\n";
window.setFramerateLimit(60);
ImGui::SFML::Init(window);
}
Renderer::~Renderer()
{
ImGui::SFML::Shutdown();
}
auto Renderer::GetInstance() -> Renderer*
{
if (instance == nullptr)
instance = new Renderer;
return instance;
}
void Renderer::DestroyInstance()
{
if (instance != nullptr)
delete instance;
}
auto Renderer::GetWindow() -> sf::RenderWindow* const
{
return &window;
}
void Renderer::Update(const sf::Time& t)
{
while (window.pollEvent(event))
{
ImGui::SFML::ProcessEvent(window, event);
if (event.type == sf::Event::Closed)
{
window.close();
}
}
if (window.hasFocus())
{
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Escape))
window.close();
}
ImGui::SFML::Update(window, t);
}
void Renderer::Render()
{
window.clear();
ImGui::SFML::Render(window);
window.display();
}
void Renderer::ShowWindow()
{
if (window_visibility) return;
window.setVisible(true);
window_visibility = true;
window.setSize(sf::Vector2u(WINDOW_WIDTH, WINDOW_HEIGHT));
}
void Renderer::HideWindow()
{
if (!window_visibility) return;
window.setVisible(false);
window_visibility = false;
window.setSize(sf::Vector2u(1, 1));
}
void Renderer::Stop() {
window.close();
}