Skip to content

Commit c5cbb41

Browse files
committed
You can now set the boolean preserveDrawingBuffer in the Game Config (either directly, or in the Render Config). This is passed to the WebGL context during creation and controls if the buffers are automatically cleared each frame or not. The default is to clear them. Set to true to retain them.
1 parent bfbf665 commit c5cbb41

4 files changed

Lines changed: 24 additions & 3 deletions

File tree

src/core/Config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,11 @@ var Config = new Class({
393393
*/
394394
this.clearBeforeRender = GetValue(renderConfig, 'clearBeforeRender', true);
395395

396+
/**
397+
* @const {boolean} Phaser.Core.Config#preserveDrawingBuffer - If the value is true the WebGL buffers will not be cleared and will preserve their values until cleared or overwritten by the author.
398+
*/
399+
this.preserveDrawingBuffer = GetValue(renderConfig, 'preserveDrawingBuffer', false);
400+
396401
/**
397402
* @const {boolean} Phaser.Core.Config#premultipliedAlpha - In WebGL mode, sets the drawing buffer to contain colors with pre-multiplied alpha.
398403
*/

src/core/typedefs/GameConfig.js

Lines changed: 16 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/core/typedefs/RenderConfig.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/renderer/webgl/WebGLRenderer.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ var WebGLRenderer = new Class({
6666
premultipliedAlpha: gameConfig.premultipliedAlpha,
6767
stencil: true,
6868
failIfMajorPerformanceCaveat: gameConfig.failIfMajorPerformanceCaveat,
69-
powerPreference: gameConfig.powerPreference
69+
powerPreference: gameConfig.powerPreference,
70+
preserveDrawingBuffer: gameConfig.preserveDrawingBuffer
7071
};
7172

7273
/**

0 commit comments

Comments
 (0)