Advertisement
Guest User

Untitled

a guest
Aug 13th, 2018
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. #include <SFML/Graphics.hpp>
  2. #include <TGUI/TGUI.hpp>
  3.  
  4. int main()
  5. {
  6. // Create the main window
  7. sf::RenderWindow app(sf::VideoMode(800, 600), "SFML window");
  8.  
  9. tgui::Gui gui;
  10. gui.setTarget(app);
  11.  
  12. auto child = tgui::ChildWindow::create();
  13. child->connect("closed", [&](tgui::ChildWindow::Ptr window) {
  14. });
  15. gui.add(child); // Closing the window make the program crash.
  16.  
  17. // Start the game loop
  18. while (app.isOpen())
  19. {
  20. // Process events
  21. sf::Event event;
  22. while (app.pollEvent(event))
  23. {
  24. gui.handleEvent(event);
  25. // Close window : exit
  26. if (event.type == sf::Event::Closed)
  27. app.close();
  28. }
  29.  
  30. // Clear screen
  31. app.clear();
  32.  
  33. // Draw the GUI
  34. gui.draw();
  35.  
  36. // Update the window
  37. app.display();
  38. }
  39.  
  40.  
  41. return EXIT_SUCCESS;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement