1
0
mirror of synced 2025-02-02 12:27:20 +01:00
jujube/test/imgui-sfml-demo.cpp

29 lines
956 B
C++

#include <imgui/imgui.h>
#include <imgui-sfml/imgui-SFML.h>
#include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/System/Clock.hpp>
#include <SFML/Window/Event.hpp>
int main() {
sf::RenderWindow window(sf::VideoMode(640, 480), "imgui-sfml-demo");
window.setVerticalSyncEnabled(true);
ImGui::SFML::Init(window);
window.resetGLStates(); // call it if you only draw ImGui. Otherwise not needed.
sf::Clock deltaClock;
while (window.isOpen()) {
sf::Event event;
while (window.pollEvent(event)) {
ImGui::SFML::ProcessEvent(event);
if (event.type == sf::Event::Closed) {
window.close();
}
}
ImGui::SFML::Update(window, deltaClock.restart());
window.clear(sf::Color::Transparent); // fill background with color
ImGui::ShowDemoWindow();
ImGui::SFML::Render(window);
window.display();
}
ImGui::SFML::Shutdown();
}