Skip to content

Commit c8096c4

Browse files
committed
Fixed cocos2d#2416: fixed a bug of cc.RenderTexture
1 parent cf9ba67 commit c8096c4

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

cocos2d/render-texture/CCRenderTexture.js

+2
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{
114114
cc.Node.prototype.ctor.call(this);
115115
this._cascadeColorEnabled = true;
116116
this._cascadeOpacityEnabled = true;
117+
this._clearColor = new cc.Color(0,0,0,255);
117118

118119
if(width !== undefined && height !== undefined) {
119120
format = format || cc.Texture2D.PIXEL_FORMAT_RGBA8888;
@@ -372,6 +373,7 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{
372373
listenToForeground:function (obj) { }
373374
});
374375

376+
var _p = cc.RenderTexture.prototype;
375377
// Extended
376378
/** @expose */
377379
_p.clearColorVal;

cocos2d/render-texture/CCRenderTextureWebGLRenderCmd.js

+11-11
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
cc.Node.WebGLRenderCmd.call(this, renderableObject);
2828
this._needDraw = true;
2929

30-
this._clearColor = cc.color(0, 0, 0, 0);
3130
this._fBO = null;
3231
this._oldFBO = null;
3332
this._textureCopy = null;
@@ -52,7 +51,7 @@
5251
// backup and set
5352
if (locClearFlags & gl.COLOR_BUFFER_BIT) {
5453
oldClearColor = gl.getParameter(gl.COLOR_CLEAR_VALUE);
55-
gl.clearColor(this._clearColor.r / 255, this._clearColor.g / 255, this._clearColor.b / 255, this._clearColor.a / 255);
54+
gl.clearColor(node._clearColor.r / 255, node._clearColor.g / 255, node._clearColor.b / 255, node._clearColor.a / 255);
5655
}
5756

5857
if (locClearFlags & gl.DEPTH_BUFFER_BIT) {
@@ -84,8 +83,9 @@
8483
var locChildren = node._children;
8584
for (var i = 0; i < locChildren.length; i++) {
8685
var getChild = locChildren[i];
87-
if (getChild != node.sprite)
88-
getChild._renderCmd.visit(this);
86+
if (getChild != node.sprite){
87+
getChild._renderCmd.visit(node.sprite._renderCmd); //TODO it's very Strange
88+
}
8989
}
9090
node.end();
9191
}
@@ -114,7 +114,7 @@
114114
gl.deleteRenderbuffer(this._depthRenderBuffer);
115115
};
116116

117-
proto.updateClearColor = function(clearColor){};
117+
proto.updateClearColor = function(clearColor){ };
118118

119119
proto.initWithWidthAndHeight = function(width, height, format, depthStencilFormat){
120120
var node = this._node;
@@ -339,23 +339,23 @@
339339
node.end();
340340
};
341341

342-
proto.visit = function(ctx){
342+
proto.visit = function(parentCmd){
343343
var node = this._node;
344+
if (!node._visible)
345+
return;
344346
cc.kmGLPushMatrix();
345347

348+
//TODO using GridNode
346349
/* var locGrid = this.grid;
347350
if (locGrid && locGrid.isActive()) {
348351
locGrid.beforeDraw();
349352
this.transformAncestors();
350353
}*/
351354

352-
node.transform(ctx);
355+
this._syncStatus(parentCmd);
353356
//this.toRenderer();
354-
355-
node.sprite.visit();
356-
//this.draw(ctx);
357-
358357
cc.renderer.pushRenderCommand(this);
358+
node.sprite.visit(this);
359359

360360
//TODO GridNode
361361
/* if (locGrid && locGrid.isActive())

0 commit comments

Comments
 (0)