-
Notifications
You must be signed in to change notification settings - Fork 171
/
main.cpp
45 lines (34 loc) · 1.09 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
#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.hpp>
int main()
{
sf::RenderWindow window(sf::VideoMode({640, 480}), "ImGui + SFML = <3");
window.setFramerateLimit(60);
if (!ImGui::SFML::Init(window))
return -1;
sf::CircleShape shape(100.f);
shape.setFillColor(sf::Color::Green);
sf::Clock deltaClock;
while (window.isOpen())
{
while (const auto event = window.pollEvent())
{
ImGui::SFML::ProcessEvent(window, *event);
if (event->is<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);
window.display();
}
ImGui::SFML::Shutdown();
}