Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: What is a popular way for creating renderwindows dynamically?  (Read 1886 times)

0 Members and 1 Guest are viewing this topic.

devonrevenge

  • Newbie
  • *
  • Posts: 1
    • View Profile
    • Email
What is a popular way for creating renderwindows dynamically?
« on: December 16, 2015, 07:50:13 pm »
I have been practicing making simpler programs but im now attempting to make myself a few experimental gui functions.

Presently if I wanted to create a new window object each time something like a message window popped up I have passed a RenderWindow object as a reference into a function and changed its state again when I needed something else, this requires something like a static object for use in main, I dont really like this, I would like to create a window from within an onject and just call a show window function within it.

What is the popular way of doing something like this, I like to keep my main method simple and clean and im sure theres better ways especially if I wanted to call several different windows fro m several different threads.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
What is a popular way for creating renderwindows dynamically?
« Reply #1 on: December 16, 2015, 09:53:37 pm »
You could return std::unique_ptr<sf::RenderWindow> and if you pass it somewhere use a reference. No need for static variables.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/