Triangles/src/main.cpp

61 lines
1.4 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:34:39 +00:00
} else if(event.type == sf::Event::KeyPressed) {
if(event.key.code == sf::Keyboard::H) {
state.flags.set(0);
}
} else if(event.type == sf::Event::KeyReleased) {
if(event.key.code == sf::Keyboard::H) {
state.flags.reset(0);
}
}
// 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;
}