From 39c454d6bffa2e287640ad55c1bc5dbe87b99171 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Thu, 30 Nov 2017 17:08:23 +0800 Subject: [PATCH] Set preserveDrawingBuffer only for wechat game environment --- cocos2d/core/CCGame.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/cocos2d/core/CCGame.js b/cocos2d/core/CCGame.js index 8186d761eb..c740e7735c 100644 --- a/cocos2d/core/CCGame.js +++ b/cocos2d/core/CCGame.js @@ -698,13 +698,16 @@ var game = { } if (cc._renderType === game.RENDER_TYPE_WEBGL) { - this._renderContext = cc._renderContext = cc.webglContext - = cc.create3DContext(localCanvas, { + var opts = { 'stencil': true, 'alpha': cc.macro.ENABLE_TRANSPARENT_CANVAS, 'antialias': cc.macro.ENABLE_WEBGL_ANTIALIAS - 'preserveDrawingBuffer': isWeChatGame - }); + }; + if (isWeChatGame) { + opts['preserveDrawingBuffer'] = true; + } + this._renderContext = cc._renderContext = cc.webglContext + = cc.create3DContext(localCanvas, opts); } // WebGL context created successfully if (this._renderContext) {