Title / Description
Code #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; }
Author
Highlight as C C++ CSS Clojure Delphi ERb Groovy (beta) HAML HTML JSON Java JavaScript PHP Plain text Python Ruby SQL XML YAML diff code