@@ -48,11 +48,18 @@ cc.GLProgram = cc.Class.extend(/** @lends cc.GLProgram# */{
48
48
49
49
var updated = false ;
50
50
var element = this . _hashForUniforms [ name ] ;
51
- var args = Array . isArray ( arguments [ 1 ] ) ? arguments [ 1 ] :
52
- Array . prototype . slice . call ( arguments , 1 ) ;
51
+ var args ;
52
+ if ( Array . isArray ( arguments [ 1 ] ) ) {
53
+ args = arguments [ 1 ] ;
54
+ } else {
55
+ args = new Array ( arguments . length - 1 ) ;
56
+ for ( var i = 1 ; i < arguments . length ; i += 1 ) {
57
+ args [ i - 1 ] = arguments [ i ] ;
58
+ }
59
+ }
53
60
54
61
if ( ! element || element . length !== args . length ) {
55
- this . _hashForUniforms [ name ] = args . slice ( ) ;
62
+ this . _hashForUniforms [ name ] = [ ] . concat ( args ) ;
56
63
updated = true ;
57
64
} else {
58
65
for ( var i = 0 ; i < args . length ; i += 1 ) {
@@ -260,11 +267,14 @@ cc.GLProgram = cc.Class.extend(/** @lends cc.GLProgram# */{
260
267
* cc.UNIFORM_SAMPLER
261
268
*/
262
269
updateUniforms : function ( ) {
263
- [ cc . UNIFORM_PMATRIX_S , cc . UNIFORM_MVMATRIX_S , cc . UNIFORM_MVPMATRIX_S ,
264
- cc . UNIFORM_TIME_S , cc . UNIFORM_SINTIME_S , cc . UNIFORM_COSTIME_S ,
265
- cc . UNIFORM_RANDOM01_S , cc . UNIFORM_SAMPLER_S ] . forEach ( function ( name ) {
266
- this . _addUniformLocation ( name ) ;
267
- } . bind ( this ) ) ;
270
+ this . _addUniformLocation ( cc . UNIFORM_PMATRIX_S ) ;
271
+ this . _addUniformLocation ( cc . UNIFORM_MVMATRIX_S ) ;
272
+ this . _addUniformLocation ( cc . UNIFORM_MVPMATRIX_S ) ;
273
+ this . _addUniformLocation ( cc . UNIFORM_TIME_S ) ;
274
+ this . _addUniformLocation ( cc . UNIFORM_SINTIME_S ) ;
275
+ this . _addUniformLocation ( cc . UNIFORM_COSTIME_S ) ;
276
+ this . _addUniformLocation ( cc . UNIFORM_RANDOM01_S ) ;
277
+ this . _addUniformLocation ( cc . UNIFORM_SAMPLER_S ) ;
268
278
this . _usesTime = ( this . _uniforms [ cc . UNIFORM_TIME_S ] != null || this . _uniforms [ cc . UNIFORM_SINTIME_S ] != null || this . _uniforms [ cc . UNIFORM_COSTIME_S ] != null ) ;
269
279
270
280
this . use ( ) ;
0 commit comments