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

Author Topic: Duplicating main window output to second window  (Read 2531 times)

0 Members and 1 Guest are viewing this topic.

JohnAppleseed

  • Newbie
  • *
  • Posts: 2
    • View Profile
Duplicating main window output to second window
« 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... )


Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: Duplicating main window output to second window
« Reply #1 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.

JohnAppleseed

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Duplicating main window output to second window
« Reply #2 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?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: Duplicating main window output to second window
« Reply #3 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...
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

wintertime

  • Sr. Member
  • ****
  • Posts: 255
    • View Profile
Re: Duplicating main window output to second window
« Reply #4 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/

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Duplicating main window output to second window
« Reply #5 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...
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

 

anything