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

Author Topic: Static RenderWindow pointer  (Read 1393 times)

0 Members and 1 Guest are viewing this topic.

thekevinbutler

  • Newbie
  • *
  • Posts: 1
    • View Profile
Static RenderWindow pointer
« on: December 29, 2015, 08:13:57 am »
Put down the torches! I know we aren't supposed to have a static RenderWindow. I get that. But, will a pointer have the same issue? I've tested it out and it runs fine.

If I may say why I would need multiple objects to have a reference to the main window: Point-and-click mechanics. Passing window as an argument gets heavy since the objects are buried under layers of parent classes that don't necessarily need any window information.

I ask you, is a static RenderWindow pointer bad? Might there be a workaround?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Static RenderWindow pointer
« Reply #1 on: December 29, 2015, 09:01:02 am »
What's "bad" is to construct and destroy it at global scope (before/after main() is executed), because it may interfere with construction/destruction of other (internal) global objects. But you can control construction/destruction independantly of the scope and type of the variable.

That's for the answer to your question. Now if you want to discuss design decisions, there's also a lot to say on this topic ;)
Laurent Gomila - SFML developer

 

anything