From b1bae6c4dd0697bd1436cf747db2001f792ad8c0 Mon Sep 17 00:00:00 2001 From: yinkaile <501251991@qq.com> Date: Mon, 6 Nov 2017 17:52:00 +0800 Subject: [PATCH] fixed RenderTarget --- cocos2d/core/base-nodes/CCSGNodeBaseRenderCmd.js | 1 - cocos2d/kazmath/gl/matrix.js | 3 +++ cocos2d/render-texture/CCRenderTextureWebGLRenderCmd.js | 4 +++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/cocos2d/core/base-nodes/CCSGNodeBaseRenderCmd.js b/cocos2d/core/base-nodes/CCSGNodeBaseRenderCmd.js index 1d2d9a5bec..acba7e79c2 100644 --- a/cocos2d/core/base-nodes/CCSGNodeBaseRenderCmd.js +++ b/cocos2d/core/base-nodes/CCSGNodeBaseRenderCmd.js @@ -386,7 +386,6 @@ _ccsg.Node.RenderCmd.prototype = { visit: function (parentCmd) { var node = this._node, renderer = cc.renderer; - parentCmd = parentCmd || this.getParentRenderCmd(); if (parentCmd) { this._curLevel = parentCmd._curLevel + 1; } diff --git a/cocos2d/kazmath/gl/matrix.js b/cocos2d/kazmath/gl/matrix.js index 40016f677e..4182cb78c2 100644 --- a/cocos2d/kazmath/gl/matrix.js +++ b/cocos2d/kazmath/gl/matrix.js @@ -77,17 +77,20 @@ math.glFreeAll = function () { math.glPushMatrix = function () { cc.current_stack.push(cc.current_stack.top); + cc.current_stack.update(); }; math.glPushMatrixWitMat4 = function (saveMat) { cc.current_stack.stack.push(cc.current_stack.top); saveMat.assignFrom(cc.current_stack.top); cc.current_stack.top = saveMat; + cc.current_stack.update(); }; math.glPopMatrix = function () { //No need to lazy initialize, you shouldnt be popping first anyway! cc.current_stack.top = cc.current_stack.stack.pop(); + cc.current_stack.update(); }; math.glMatrixMode = function (mode) { diff --git a/cocos2d/render-texture/CCRenderTextureWebGLRenderCmd.js b/cocos2d/render-texture/CCRenderTextureWebGLRenderCmd.js index 5c02d3e611..e2768b6a7d 100644 --- a/cocos2d/render-texture/CCRenderTextureWebGLRenderCmd.js +++ b/cocos2d/render-texture/CCRenderTextureWebGLRenderCmd.js @@ -140,7 +140,6 @@ proto.initWithWidthAndHeight = function(width, height, format, depthStencilForma var gl = cc._renderContext; this._fullRect = new cc.Rect(0,0, width, height); - this._fullViewport = new cc.Rect(0,0, width, height); width = 0 | width; height = 0 | height; @@ -158,6 +157,8 @@ proto.initWithWidthAndHeight = function(width, height, format, depthStencilForma powH = misc.NextPOT(height); } + this._fullViewport = new cc.Rect(0,0, powW, powH); + //void *data = malloc(powW * powH * 4); var dataLen = powW * powH * 4; var data = new Uint8Array(dataLen); @@ -244,6 +245,7 @@ proto.begin = function(){ var orthoMatrix = cc.math.Matrix4.createOrthographicProjection(-1.0 / widthRatio, 1.0 / widthRatio, -1.0 / heightRatio, 1.0 / heightRatio, -1, 1); + cc.math.glMatrixMode(cc.math.KM_GL_PROJECTION); cc.math.glMultMatrix(orthoMatrix); //calculate viewport