Bring in a simple SDL2 demo for completeness. It's running in a main.cpp to test SDL2 in C++.
This commit is contained in:
parent
dfbae6043b
commit
b4ff44788a
6 changed files with 57 additions and 3 deletions
44
sfmldemo/main.cpp
Normal file
44
sfmldemo/main.cpp
Normal file
|
@ -0,0 +1,44 @@
|
|||
#include "imgui.h"
|
||||
#include "imgui-SFML.h"
|
||||
|
||||
#include <SFML/Graphics/CircleShape.hpp>
|
||||
#include <SFML/Graphics/RenderWindow.hpp>
|
||||
#include <SFML/System/Clock.hpp>
|
||||
#include <SFML/Window/Event.hpp>
|
||||
|
||||
int main() {
|
||||
sf::RenderWindow window(sf::VideoMode(1920, 1080), "ImGui + SFML = <3");
|
||||
// window.setFramerateLimit(60);
|
||||
window.setVerticalSyncEnabled(true);
|
||||
ImGui::SFML::Init(window);
|
||||
|
||||
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) {
|
||||
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();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue