SFML community forums

Help => Graphics => Topic started by: jronald on December 09, 2014, 05:45:44 pm

Title: Does SFML support partially refresh/redraw?
Post by: jronald 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.
Title: Re: Does SFML support partially refresh/redraw?
Post by: Jesper Juhl 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...
Title: Re: Does SFML support partially refresh/redraw?
Post by: jronald 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?
Title: Re: Does SFML support partially refresh/redraw?
Post by: Jesper Juhl 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.
Title: Re: Does SFML support partially refresh/redraw?
Post by: jronald 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?
Title: Re: Does SFML support partially refresh/redraw?
Post by: Jesper Juhl on December 09, 2014, 06:14:17 pm
Yes.

Btw: no need to full-quote what's right above your post.
Title: Re: Does SFML support partially refresh/redraw?
Post by: jronald on December 09, 2014, 06:20:38 pm
OK.
So it is perfect.
Thanks.
Title: Re: Does SFML support partially refresh/redraw?
Post by: wintertime 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.
Title: Re: Does SFML support partially refresh/redraw?
Post by: jronald on December 09, 2014, 06:39:02 pm
Fine, thanks.
Title: Re: Does SFML support partially refresh/redraw?
Post by: Laurent on December 09, 2014, 06:49:02 pm
http://sfml-dev.org/tutorials/2.1/graphics-draw.php#the-drawing-window

The big red box at the end of chapter.
Title: Re: Does SFML support partially refresh/redraw?
Post by: jronald 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?
Title: AW: Does SFML support partially refresh/redraw?
Post by: eXpl0it3r on December 10, 2014, 07:42:53 am
No, it's not a problem.
Title: Re: Does SFML support partially refresh/redraw?
Post by: jronald 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.