-
Notifications
You must be signed in to change notification settings - Fork 178
/
Copy pathmain.cpp
58 lines (45 loc) · 1.74 KB
/
main.cpp
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
#include "imgui.h" // necessary for ImGui::*, imgui-SFML.h doesn't include imgui.h
#include "imgui-SFML.h" // for ImGui::SFML::* functions and SFML-specific overloads
#include <SFML/Graphics/CircleShape.hpp>
#include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/System/Clock.hpp>
#include <SFML/Window/Event.hpp>
#include <iostream>
int main() {
sf::RenderWindow window(sf::VideoMode(1280, 720), "ImGui + SFML = <3");
window.setFramerateLimit(60);
ImGui::SFML::Init(window);
// Comment/uncomment this to disable/enable viewports
// Must be using docking branch of ImGui
//ImGui::GetIO().ConfigFlags |= ImGuiConfigFlags_ViewportsEnable
// | ImGuiConfigFlags_DockingEnable;
sf::CircleShape shape(100.f);
shape.setFillColor(sf::Color::Green);
sf::Clock deltaClock;
while (window.isOpen()) {
sf::Event event;
while (window.pollEvent(event)) {
ImGui::SFML::ProcessEvent(window, event);
if (event.type == sf::Event::Closed) {
window.close();
}
}
ImGui::SFML::Update(window, deltaClock.restart());
ImGui::ShowDemoWindow();
ImGui::Begin("Hello, world!");
ImGui::Button("Look at this pretty button");
ImGui::End();
window.clear();
window.draw(shape);
ImGui::SFML::Render(window);
// Comment/uncomment this to disable/enable viewports
// Must be using docking branch of ImGui
//if (ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_ViewportsEnable) {
// ImGui::UpdatePlatformWindows();
// ImGui::RenderPlatformWindowsDefault();
//}
window.display();
}
ImGui::SFML::Shutdown();
return 0;
}