SFML community forums
Help => Graphics => Topic started 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.
-
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...
-
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?
-
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.
-
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?
-
Yes.
Btw: no need to full-quote what's right above your post.
-
OK.
So it is perfect.
Thanks.
-
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.
-
Fine, thanks.
-
http://sfml-dev.org/tutorials/2.1/graphics-draw.php#the-drawing-window
The big red box at the end of chapter.
-
Speed is not a problem, but is power saving a problem considering draw the whole windows or a small part of it?
-
No, it's not a problem.
-
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.