GoodBoyDigital/pixi.js — pull request #995 by agamemnus (2014-09-24 19:02:41+00:00)
Title: Add clearBeforeRender for <webgl>

Maybe "clearBeforeRender" this is not the best naming (since it will clear anyway..), but this aligns canvas and webgl:

Basically it allows the user to do clearColor whenever they want, instead of this being done for them. This is useful in the following circumstance:

1) The game/program loads a background image, but not right away.
2) Before the background image is loaded, we want to fill the canvas with a certain color (for example, white).
3) In canvas mode, this is done by setting ``clearBeforeRender`` to false and then adding a single ``fillRect`` command.
4) In webGL mode, the equivalent is running ``gl.clearColor`` and then ``gl.clear``.
5) We can of course set the background color in webGL mode and this probably won't be expensive (although I don't know), but in canvas it *is* expensive to clear/fill on every frame.
6) Thus, the user would have to detect webGL mode or canvas mode themselves, and either set the background color or not.
7) To eliminate this coding complexity for the user, this small bit of extra code aligns ``clearBeforeRender`` (or, as much as possible) to the canvas implementation.