SFML + SFGUI
C++
code posted
by
Quintus
created at 17 Mar 20:39
Edit
|
Back
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
#include <iostream> #include <functional> #include <SFML/Graphics.hpp> #include <SFGUI/SFGUI.hpp> void on_button_click() { std::cout << "Test" << std::endl; } int main() { sf::RenderWindow rwindow(sf::VideoMode(640, 480), "SFML + SFGUI test"); sf::CircleShape shape(100.0f); shape.setFillColor(sf::Color::Green); sfg::SFGUI sfgui; sfg::Desktop desktop; auto window = sfg::Window::Create(); window->SetTitle("Test window"); auto button = sfg::Button::Create("Hello"); button->GetSignal(sfg::Button::OnLeftClick).Connect(std::bind(&on_button_click)); window->Add(button); desktop.Add(window); bool quit = false; while (!quit) { sf::Event event; while (rwindow.pollEvent(event)) { if (event.type == sf::Event::Closed) { rwindow.close(); quit = true; } desktop.HandleEvent(event); } desktop.Update(1.0f); rwindow.clear(); rwindow.draw(shape); sfgui.Display(rwindow); rwindow.display(); } return 0; } |
1.02 KB in 3 ms with coderay