Tuesday, July 12, 2022
HomeGame Developmentsfml - Do I've to clear the complete goal with a single...

sfml – Do I’ve to clear the complete goal with a single colour each body?


From the documentation (emphasis mine):

Calling clear earlier than drawing something is necessary, in any other case the contents from earlier frames will likely be current behind something you draw. The one exception is while you cowl the complete window with what you draw, in order that no pixel is just not drawn to. On this case you possibly can keep away from calling clear (though it will not have a noticeable affect on efficiency).

So that you’re proper, should you plan to redraw the complete display, each body, then you do not have to name clear.

…however since calling clear is reasonable, it’s extremely really helpful to take action: it’s going to forestall some eventual WTF?!!!? throughout future growth (e.g. WTF, why are there bizarre shapes after I debug my character motion code ?!!!?). Additionally, since it’s usually anticipated to be there, you may get much less bizarre seems at you when you’ve different devs take a look at your code. With out going into particulars, it could possibly aid you discover some bugs along with your code that might be tougher to trace should you did not do it.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments