-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEApplication.cpp
More file actions
82 lines (58 loc) · 1.42 KB
/
Copy pathEApplication.cpp
File metadata and controls
82 lines (58 loc) · 1.42 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
#include "EApplication.h"
#include "imgui.h"
#include "imgui-SFML.h"
#include "ELog.h"
EApplication::EApplication() {
render.window = &window;
render.blockManager = &blockManager;
blockManager.window = &window;
}
void EApplication::Init()
{
//Create window and do basic things.
window.create(sf::VideoMode(1024, 720), "Endcoder");
window.setFramerateLimit(60);
ImGui::SFML::Init(window);
render.Init();
keyboard.Init();
}
void EApplication::Update()
{
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
ImGui::SFML::ProcessEvent(event);
if (event.type == sf::Event::Closed)
window.close();
// catch the resize events
if (event.type == sf::Event::Resized)
{
// update the view to the new size of the window
sf::FloatRect visibleArea(0, 0, event.size.width, event.size.height);
window.setView(sf::View(visibleArea));
}
//Disable the blockmanager from updating if the mouse is ontop of imgui
if (!render.gui.isAnyWindowHovered()) {
blockManager.Update(event);
}
else {
blockManager.UpdateBlocks();
}
}
keyboard.Update();
ImGui::SFML::Update(window, deltaClock.restart());
window.clear(sf::Color::White);
//window.draw(testText);
render.Draw();
ImGui::SFML::Render(window);
window.display();
}
}
void EApplication::Shutdown()
{
ImGui::SFML::Shutdown();
blockManager.Shutdown();
keyboard.Shutdown();
}