SFML community forums

Help => Window => Topic started by: thekevinbutler on December 29, 2015, 08:13:57 am

Title: Static RenderWindow pointer
Post by: thekevinbutler 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?
Title: Re: Static RenderWindow pointer
Post by: Laurent 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 ;)