summaryrefslogtreecommitdiff
path: root/src/main.cpp
blob: 5bb7884d8fcfdd46c470646a4abfe9fa7820198f (plain)
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
#include <imgui-SFML.h>
#include <imgui.h>

#include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/System/Clock.hpp>
#include <SFML/Window/Event.hpp>
#include <SFML/Window/VideoMode.hpp>
#include <optional>

int main() {
  sf::RenderWindow window(sf::VideoMode({800, 600}), "sillyeditor");
  window.setFramerateLimit(60);
  ImGui::SFML::Init(window);

  sf::Clock deltaClock;
  while (window.isOpen()) {
    while (const std::optional<sf::Event> event = window.pollEvent()) {
      if (event.has_value()) {
        sf::Event e = event.value();
        ImGui::SFML::ProcessEvent(window, e);
      }

      if (event->is<sf::Event::Closed>()) {
        window.close();
      }
    }

    ImGui::SFML::Update(window, deltaClock.restart());

    window.clear();

    ImGui::SFML::Render(window);
    window.display();
  }

  return 0;
}