-
Notifications
You must be signed in to change notification settings - Fork 209
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Demonstrate how to acquire and use ImGui-SFML
- Loading branch information
1 parent
5312df6
commit 7bde340
Showing
2 changed files
with
31 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,36 @@ | ||
#include <SFML/Graphics.hpp> | ||
#include <imgui-SFML.h> | ||
#include <imgui.h> | ||
|
||
int main() | ||
{ | ||
auto window = sf::RenderWindow{ { 1920u, 1080u }, "CMake SFML Project" }; | ||
auto window = sf::RenderWindow{ { 1280u, 720u }, "CMake SFML Project" }; | ||
window.setFramerateLimit(144); | ||
ImGui::SFML::Init(window); | ||
|
||
sf::Clock clock; | ||
while (window.isOpen()) | ||
{ | ||
for (auto event = sf::Event{}; window.pollEvent(event);) | ||
{ | ||
ImGui::SFML::ProcessEvent(window, event); | ||
|
||
if (event.type == sf::Event::Closed) | ||
{ | ||
window.close(); | ||
} | ||
} | ||
|
||
ImGui::SFML::Update(window, clock.restart()); | ||
|
||
ImGui::Begin("Hello, world!"); | ||
ImGui::Button("Look at this pretty button"); | ||
ImGui::End(); | ||
|
||
window.clear(); | ||
ImGui::SFML::Render(window); | ||
window.display(); | ||
} | ||
} | ||
|
||
ImGui::SFML::Shutdown(); | ||
} |