Triangles/src/main.cpp

54 lines
1.1 KiB
C++
Raw Normal View History

2020-07-21 11:03:22 +00:00
#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include <imgui.h>
#include <imgui-SFML.h>
2020-07-21 11:34:39 +00:00
#include "state.hpp"
#include "imgui_helper.hpp"
2020-07-21 11:03:22 +00:00
int main(int argc, char **argv) {
// init
2020-07-21 11:34:39 +00:00
Tri::State state{};
sf::RenderWindow window(
sf::VideoMode(state.width, state.height),
"Triangles",
sf::Style::Titlebar | sf::Style::Close);
ImGui::SFML::Init(window);
window.setFramerateLimit(60);
// main loop
sf::Event event;
while(window.isOpen()) {
// events
window.pollEvent(event);
ImGui::SFML::ProcessEvent(event);
if(event.type == sf::Event::Closed) {
window.close();
}
2020-07-21 11:44:10 +00:00
state.handle_event(&event);
// update
2020-07-21 11:34:39 +00:00
ImGui::SFML::Update(window, state.dt);
2020-07-21 11:34:39 +00:00
state.update();
ImGui::EndFrame();
// update end
// draw
window.clear();
ImGui::SFML::Render(window);
2020-07-21 11:34:39 +00:00
state.draw();
window.display();
}
// cleanup
window.close();
ImGui::SFML::Shutdown();
2020-07-21 11:03:22 +00:00
return 0;
}