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

Author Topic: Does SFML support partially refresh/redraw?  (Read 7064 times)

0 Members and 1 Guest are viewing this topic.

jronald

  • Newbie
  • *
  • Posts: 21
    • View Profile
    • Email
Does SFML support partially refresh/redraw?
« on: December 09, 2014, 05:45:44 pm »
In SFML 2.1, I only find the RenderWindow::clear(color) that clear the whole window, also the Window::display draw the whole window.

My question is that, does it support, for example, only draw the necessary area, e.g. a rect. I think it'll be much efficent then. This is very good for developing apps/boardgames etc.

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Does SFML support partially refresh/redraw?
« Reply #1 on: December 09, 2014, 05:49:38 pm »
Short answer: no.
It wouldn't be efficient. Modern GPUs really want to just draw the whole frame each time. It would also be more complicated for users who would need to keep track of what areas to redraw.
Redrawing the whole frame every time is simple and efficient.
As for board games; you are not really going to be GPU limited anyway, so it actually doesn't even matter. Really...
« Last Edit: December 09, 2014, 05:51:45 pm by Jesper Juhl »

jronald

  • Newbie
  • *
  • Posts: 21
    • View Profile
    • Email
Re: Does SFML support partially refresh/redraw?
« Reply #2 on: December 09, 2014, 06:04:51 pm »
Short answer: no.
It wouldn't be efficient. Modern GPUs really want to just draw the whole frame each time. It would also be more complicated for users who would need to keep track of what areas to redraw.
Redrawing the whole frame every time is simple and efficient.
As for board games; you are not really going to be GPU limited anyway, so it actually doesn't even matter. Really...
What about power saving?

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Does SFML support partially refresh/redraw?
« Reply #3 on: December 09, 2014, 06:08:14 pm »
Draw fewer frames.
If you are implementing a board game, like say, chess. Just don't redraw if the board had not changed and if you keep your (potential) redraw interval at 10fps that's going to be more than fast enough when the board does change.
Keep it simple.

jronald

  • Newbie
  • *
  • Posts: 21
    • View Profile
    • Email
Re: Does SFML support partially refresh/redraw?
« Reply #4 on: December 09, 2014, 06:12:34 pm »
Draw fewer frames.
If you are implementing a board game, like say, chess. Just don't redraw if the board had not changed and if you keep your (potential) redraw interval at 10fps that's going to be more than fast enough when the board does change.
Keep it simple.
So, can fps be variable, only draw when needed?

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Does SFML support partially refresh/redraw?
« Reply #5 on: December 09, 2014, 06:14:17 pm »
Yes.

Btw: no need to full-quote what's right above your post.

jronald

  • Newbie
  • *
  • Posts: 21
    • View Profile
    • Email
Re: Does SFML support partially refresh/redraw?
« Reply #6 on: December 09, 2014, 06:20:38 pm »
OK.
So it is perfect.
Thanks.

wintertime

  • Sr. Member
  • ****
  • Posts: 255
    • View Profile
Re: Does SFML support partially refresh/redraw?
« Reply #7 on: December 09, 2014, 06:35:04 pm »
On a boardgame without animations you could use waitEvent after display, then poll remaining events. This prevents useless redrawing when there are no new events and therefore no need to draw something different.

jronald

  • Newbie
  • *
  • Posts: 21
    • View Profile
    • Email
Re: Does SFML support partially refresh/redraw?
« Reply #8 on: December 09, 2014, 06:39:02 pm »
Fine, thanks.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Does SFML support partially refresh/redraw?
« Reply #9 on: December 09, 2014, 06:49:02 pm »
Laurent Gomila - SFML developer

jronald

  • Newbie
  • *
  • Posts: 21
    • View Profile
    • Email
Re: Does SFML support partially refresh/redraw?
« Reply #10 on: December 10, 2014, 05:07:57 am »
Speed is not a problem, but is power saving a problem considering draw the whole windows or a small part of it?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11033
    • View Profile
    • development blog
    • Email
AW: Does SFML support partially refresh/redraw?
« Reply #11 on: December 10, 2014, 07:42:53 am »
No, it's not a problem.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

jronald

  • Newbie
  • *
  • Posts: 21
    • View Profile
    • Email
Re: Does SFML support partially refresh/redraw?
« Reply #12 on: December 10, 2014, 08:05:05 am »
Maybe a little problem, there are at least two solutions for the example to be able to run, e.g. set the environment in debugging in property page or copy the dll into the exe directory, it needs some little comparison to choose a better way. When the example just can not run, it'll depends on the error message of the develop tools, fortunately the error message help in the case. However it is not the most efficient way.

 

anything