SFML community forums

Help => General => Topic started by: roccio on November 28, 2018, 09:17:24 am

Title: Multiple windows
Post by: roccio on November 28, 2018, 09:17:24 am
Hello,
I have a question regarding the correct way of using mnultiple windows with SFML (2.5.1).

Here is the general info:

- one window is the main program interface
- from this interface you can launch a thread that will open many other windows (al opened and managed in this new thread)

so the question are:

1) do I need to call setActive(true) for every window?
2) what happens if I set the vertical retrace to true? Every window will stop the code waiting the retrace?

thanks
Title: Re: Multiple windows
Post by: Laurent on November 28, 2018, 09:49:29 am
Quote
1) do I need to call setActive(true) for every window?
It depends what you do. Calling setActive(true) is necessary only if you call OpenGL functions yourself; if you use the graphics module, SFML will automatically do it for you.

And since a window is created and fully managed within a single thread, you don't even have to call setActive(false) (which would be needed if the window was created and used in different threads).

But why don't you just try the simple way, before asking if you need to do more complicated things? ;)

Quote
2) what happens if I set the vertical retrace to true? Every window will stop the code waiting the retrace?
I guess so, but since each window lives in its own thread, they won't block each other. Again, why don't you just try?
Title: Re: Multiple windows
Post by: roccio on November 28, 2018, 11:29:04 am
Many thanks,

I have tried and not using setActive at all, and I have no issues. Just wondering if this is the correct way.