From 2f1a1773f27fec6417b83566bde735a922d8e73f Mon Sep 17 00:00:00 2001 From: pandamicro Date: Wed, 11 Jul 2018 16:28:23 +0800 Subject: [PATCH] Fix RenderTexture error for Android WeChat (#2967) * Fix RenderTexture error for Android WeChat. * Fix audio clip set error and instance release safe. --- cocos2d/render-texture/CCRenderTextureWebGLRenderCmd.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cocos2d/render-texture/CCRenderTextureWebGLRenderCmd.js b/cocos2d/render-texture/CCRenderTextureWebGLRenderCmd.js index 445d9cc7c4..6cf19d5d55 100644 --- a/cocos2d/render-texture/CCRenderTextureWebGLRenderCmd.js +++ b/cocos2d/render-texture/CCRenderTextureWebGLRenderCmd.js @@ -236,6 +236,9 @@ proto.begin = function(){ var gl = cc._renderContext; + this._oldFBO = gl.getParameter(gl.FRAMEBUFFER_BINDING); + gl.bindFramebuffer(gl.FRAMEBUFFER, this._fBO);//Will direct drawing to the frame buffer created above + var director = cc.director; director.setProjection(director.getProjection()); @@ -259,9 +262,6 @@ proto.begin = function(){ viewport.y = (this._fullRect.y - this._rtTextureRect.y) * viewPortRectHeightRatio; gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height); - this._oldFBO = gl.getParameter(gl.FRAMEBUFFER_BINDING); - gl.bindFramebuffer(gl.FRAMEBUFFER, this._fBO);//Will direct drawing to the frame buffer created above - /* Certain Qualcomm Andreno gpu's will retain data in memory after a frame buffer switch which corrupts the render to the texture. * The solution is to clear the frame buffer before rendering to the texture. However, calling glClear has the unintended result of clearing the current texture. * Create a temporary texture to overcome this. At the end of CCRenderTexture::begin(), switch the attached texture to the second one, call glClear,