Skip to content

Commit beee1dc

Browse files
author
David DeSimone
committed
Fixing rendering issues in CCAtlastNodeWebGLRenderCmd and CCGrid.
1 parent 4ed7dc5 commit beee1dc

File tree

3 files changed

+8
-13
lines changed

3 files changed

+8
-13
lines changed

cocos2d/core/base-nodes/CCAtlasNodeWebGLRenderCmd.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,12 @@
3232
this._textureAtlas = null;
3333
this._colorUnmodified = cc.color.WHITE;
3434
this._colorF32Array = null;
35-
this._uniformColor = null;
3635

3736
this._matrix = new cc.math.Matrix4();
3837
this._matrix.identity();
3938

4039
//shader stuff
4140
this._shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURE_UCOLOR);
42-
this._uniformColor = cc._renderContext.getUniformLocation(this._shaderProgram.getProgram(), "u_color");
4341
};
4442

4543
var proto = cc.AtlasNode.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype);
@@ -71,8 +69,8 @@
7169
this._glProgramState.apply(this._matrix);
7270

7371
cc.glBlendFunc(node._blendFunc.src, node._blendFunc.dst);
74-
if (this._uniformColor && this._colorF32Array) {
75-
context.uniform4fv(this._uniformColor, this._colorF32Array);
72+
if (this._colorF32Array) {
73+
this._glProgramState.setUniformVec4v("u_color", this._colorF32Array);
7674
this._textureAtlas.drawNumberOfQuads(node.quadsToDraw, 0);
7775
}
7876
};

cocos2d/effects/CCGrid.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ cc.GridBase = cc.Class.extend(/** @lends cc.GridBase# */{
3939
_step: null,
4040
_grabber: null,
4141
_isTextureFlipped: false,
42-
_shaderProgram: null,
42+
_glProgramState: null,
4343
_directorProjection: 0,
4444

4545
_dirty: false,
@@ -62,7 +62,7 @@ cc.GridBase = cc.Class.extend(/** @lends cc.GridBase# */{
6262
this._step = cc.p(0, 0);
6363
this._grabber = null;
6464
this._isTextureFlipped = false;
65-
this._shaderProgram = null;
65+
this._glProgramState = null;
6666
this._directorProjection = 0;
6767
this._dirty = false;
6868

@@ -227,7 +227,7 @@ cc.GridBase = cc.Class.extend(/** @lends cc.GridBase# */{
227227
if (!this._grabber)
228228
return false;
229229
this._grabber.grab(this._texture);
230-
this._shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURE);
230+
this._glProgramState = cc.GLProgramState.getOrCreateWithGLProgram(cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURE));
231231
this.calculateVertexPoints();
232232
return true;
233233
},

cocos2d/shaders/CCGLProgramState.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@
2424
THE SOFTWARE.
2525
****************************************************************************/
2626

27-
// @TODO add floatv and intv methods, that take arrays
28-
// and float1..4 methods, which take arguments.
29-
3027
var types =
3128
{
3229
GL_FLOAT: 0,
@@ -122,8 +119,8 @@ cc.UniformValue = cc.Class.extend({
122119
this._value[1], this._value[2]);
123120
break;
124121
case types.GL_FLOAT_VEC4:
125-
this._glprogram.setUniformLocationWith3f(this._uniform.location, this._value[0],
126-
this._value[1], this._value[2]);
122+
this._glprogram.setUniformLocationWith4f(this._uniform.location, this._value[0],
123+
this._value[1], this._value[2], this._value[3]);
127124
break;
128125
case types.GL_FLOAT_MAT4:
129126
this._glprogram.setUniformLocationWithMatrix4fv(this._uniform.location, this._value);
@@ -136,7 +133,7 @@ cc.UniformValue = cc.Class.extend({
136133
cc.glBindTexture2DN(this._value, this._textureId);
137134
break;
138135
default:
139-
cc.Assert(false, "Unsupported type");
136+
;
140137
}
141138
},
142139
});

0 commit comments

Comments
 (0)