From 26c7aacea039abec21c5e3d85db49e6aa0136383 Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Tue, 21 Jul 2020 20:15:10 +0900 Subject: [PATCH] Impl basic drawing, a basic start to the program --- .gitignore | 2 ++ include/imgui-SFML.h | 1 + src/main.cpp | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+) create mode 120000 include/imgui-SFML.h diff --git a/.gitignore b/.gitignore index a5309e6..de5a352 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ build*/ +compile_commands.json +.clangd/ diff --git a/include/imgui-SFML.h b/include/imgui-SFML.h new file mode 120000 index 0000000..be86680 --- /dev/null +++ b/include/imgui-SFML.h @@ -0,0 +1 @@ +../third_party/imgui-sfml/imgui-SFML.h \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 817b524..72d131a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2,6 +2,45 @@ #include #include +#include +#include + int main(int argc, char **argv) { + // init + sf::RenderWindow window(sf::VideoMode(800, 600), "Triangles"); + ImGui::SFML::Init(window); + window.setFramerateLimit(60); + const sf::Time dt = sf::microseconds(16666); + + // main loop + sf::Event event; + while(window.isOpen()) { + // events + window.pollEvent(event); + ImGui::SFML::ProcessEvent(event); + if(event.type == sf::Event::Closed) { + window.close(); + } + + // update + ImGui::SFML::Update(window, dt); + + ImGui::Begin("Test window"); + ImGui::Text("Test text"); + + ImGui::End(); + ImGui::EndFrame(); + // update end + + // draw + window.clear(); + ImGui::SFML::Render(window); + window.display(); + } + + // cleanup + window.close(); + ImGui::SFML::Shutdown(); + return 0; }