2020-07-21 11:03:22 +00:00
|
|
|
#include <SFML/System.hpp>
|
|
|
|
#include <SFML/Window.hpp>
|
|
|
|
#include <SFML/Graphics.hpp>
|
|
|
|
|
2020-07-21 11:15:10 +00:00
|
|
|
#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) {
|
2020-07-21 11:15:10 +00:00
|
|
|
// 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);
|
2020-07-21 11:15:10 +00:00
|
|
|
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);
|
|
|
|
}
|
2020-07-21 11:15:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// update
|
2020-07-21 11:34:39 +00:00
|
|
|
ImGui::SFML::Update(window, state.dt);
|
2020-07-21 11:15:10 +00:00
|
|
|
|
2020-07-21 11:34:39 +00:00
|
|
|
state.update();
|
2020-07-21 11:15:10 +00:00
|
|
|
|
|
|
|
ImGui::EndFrame();
|
|
|
|
// update end
|
|
|
|
|
|
|
|
// draw
|
|
|
|
window.clear();
|
|
|
|
ImGui::SFML::Render(window);
|
2020-07-21 11:34:39 +00:00
|
|
|
state.draw();
|
2020-07-21 11:15:10 +00:00
|
|
|
window.display();
|
|
|
|
}
|
|
|
|
|
|
|
|
// cleanup
|
|
|
|
window.close();
|
|
|
|
ImGui::SFML::Shutdown();
|
|
|
|
|
2020-07-21 11:03:22 +00:00
|
|
|
return 0;
|
|
|
|
}
|