SFML community forums

Help => Window => Topic started by: JohnAppleseed on October 23, 2013, 12:55:00 pm

Title: Duplicating main window output to second window
Post by: JohnAppleseed on October 23, 2013, 12:55:00 pm
Hello All,

For a project I am writing, I would like to create a duplicate window. For example: everything  will be drawn to the main window, and the duplicate window at an arbitrary position and size will simply replicate the output.

I haven't been able to figure out if there is an efficient way around this, currently everything is drawn to a render texture then to the two windows at a ~30-40% reduction in performance.

Any ideas on how to do this without a loss of performance?

Gr,

John Appleseed ( Yes that's my real name... )

Title: Re: Duplicating main window output to second window
Post by: Ixrec on October 23, 2013, 01:20:46 pm
"~30-40% reduction" compared to what?  And how are you measuring it?

As far as I know your only options are what you just described, or simply drawing everything directly to both windows after giving them different views.  The latter might be more efficient, I dunno.  In principle, there's no getting around the fact that you need to draw everything at least twice, so you shouldn't be surprised if things slow down somewhat.
Title: Re: Duplicating main window output to second window
Post by: JohnAppleseed on October 23, 2013, 02:02:00 pm
Yes the other option is indeed drawing all drawables twice, in this application it seems the performance (fps - fraps) was even worse.

After some unrelated testing I found out that the decrease in performance was because the window type was sf::Style::None.

sf::Style::Default/sf::Style::Fullscreen resulted in the original performance.

I'm not sure if it is the result of the operating system (Windows 8.1) or the graphics drivers (latest).

Is this expected?
Title: Re: Duplicating main window output to second window
Post by: eXpl0it3r on October 23, 2013, 02:27:53 pm
Sounds odd to me, but then again FRAPS is not really a good tool to check performance, especially with multiple windows. If you just want to check for FPS, I'd suggest to implement your own FPS code and compare them.

Why the styles would have an influence, one would probably have to look at the implementation and read the documentation about OS calls...
Title: Re: Duplicating main window output to second window
Post by: wintertime on October 23, 2013, 05:43:47 pm
I'm sure you can directly copy the pixels from one framebuffer of a window to the frambuffer of another window or a texture. You would just have to program this yourself with OpenGL calls.
Some results of a quick search:
http://www.opengl.org/wiki/GLAPI/glBlitFramebuffer
http://www.gamedev.net/topic/461451-direct-copy-from-framebuffer-to-texture/
Title: Re: Duplicating main window output to second window
Post by: Nexus on October 24, 2013, 01:23:29 pm
currently everything is drawn to a render texture then to the two windows at a ~30-40% reduction in performance.
How do you draw the render texture to the windows? And again, compared to what?

If you do it correctly, you will only have one additional draw call per window. But having two windows has of course an overhead on its own...