This is a simple game I'm writing to test the idea of using games to teach C++. https://learncodethehardway.com/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

54 lines
1.3 KiB

#include "imgui.h"
#include "imgui-SFML.h"
#include <fmt/core.h>
#include <SFML/Graphics/CircleShape.hpp>
#include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/System/Clock.hpp>
#include <SFML/Window/Event.hpp>
int main() {
fmt::print("Setting up a window for you...\n");
sf::RenderWindow window(sf::VideoMode(1920, 1080), "ImGui + SFML = <3");
// window.setFramerateLimit(60);
window.setVerticalSyncEnabled(true);
int res = ImGui::SFML::Init(window);
if(res == 1) {
fmt::print("ImGui returned result {}\n", res);
} else {
fmt::print("ImGui returned an error code={}\n", res);
return -1;
}
sf::CircleShape shape(100.f);
shape.setFillColor(sf::Color::Green);
sf::Clock deltaClock;
while (window.isOpen()) {
sf::Event event;
while (window.pollEvent(event)) {
ImGui::SFML::ProcessEvent(window, event);
if (event.type == sf::Event::Closed) {
fmt::print("Exiting...\n");
window.close();
}
}
ImGui::SFML::Update(window, deltaClock.restart());
ImGui::ShowDemoWindow();
ImGui::Begin("Hello, world!");
ImGui::Button("Look at this pretty button");
ImGui::End();
window.clear();
window.draw(shape);
ImGui::SFML::Render(window);
window.display();
}
ImGui::SFML::Shutdown();
}