Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion cocos2d/render-texture/CCRenderTexture.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{
* @function
*/
begin: function () {
cc.renderer._turnToCacheMode(this.__instanceId);
this._renderCmd.begin();
},
/**
Expand Down
7 changes: 7 additions & 0 deletions cocos2d/render-texture/CCRenderTextureCanvasRenderCmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
this._needDraw = false;
this._clearColorStr = "rgba(255,255,255,1)";

this._oldIsCacheToCanvasOn = false;

this._cacheCanvas = document.createElement('canvas');
this._cacheContext = new cc.CanvasContextWrapper(this._cacheCanvas.getContext('2d'));
};
Expand Down Expand Up @@ -70,6 +72,8 @@
};

proto.begin = function () {
this._oldIsCacheToCanvasOn = cc.renderer._isCacheToCanvasOn;
cc.renderer._turnToCacheMode(node.__instanceId);
};

proto._beginWithClear = function (r, g, b, a, depthValue, stencilValue, flags) {
Expand All @@ -91,6 +95,9 @@

var scale = cc.contentScaleFactor();
cc.renderer._renderingToCacheCanvas(this._cacheContext, node.__instanceId, scale, scale);

cc.renderer._isCacheToCanvasOn = this._oldIsCacheToCanvasOn;

var spriteRenderCmd = node.sprite._renderCmd;
spriteRenderCmd._notifyRegionStatus && spriteRenderCmd._notifyRegionStatus(cc.Node.CanvasRenderCmd.RegionStatus.Dirty);
};
Expand Down
7 changes: 7 additions & 0 deletions cocos2d/render-texture/CCRenderTextureWebGLRenderCmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

this._fBO = null;
this._oldFBO = null;
this._oldIsCacheToBufferOn = false;
this._textureCopy = null;
this._depthRenderBuffer = null;

Expand Down Expand Up @@ -226,6 +227,10 @@

proto.begin = function () {
var node = this._node;

this._oldIsCacheToBufferOn = cc.renderer._isCacheToBufferOn;
cc.renderer._turnToCacheMode(node.__instanceId);

// Save the current matrix
cc.kmGLMatrixMode(cc.KM_GL_PROJECTION);
cc.kmGLPushMatrix();
Expand Down Expand Up @@ -320,6 +325,8 @@
var node = this._node;
cc.renderer._renderingToBuffer(node.__instanceId);

cc.renderer._isCacheToBufferOn = this._oldIsCacheToBufferOn;

var gl = cc._renderContext;
var director = cc.director;
gl.bindFramebuffer(gl.FRAMEBUFFER, this._oldFBO);
Expand Down