From 1d8a6f29e09b5df3931f9825e20fca0dc81a5523 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Mon, 14 Mar 2016 11:48:55 +0800 Subject: [PATCH] Refactor cc.Macro to cc.macro --- cocos2d/actions/CCActionCamera.js | 4 +- cocos2d/actions/CCActionCatmullRom.js | 2 +- cocos2d/actions/CCActionInterval.js | 6 +- .../CCClippingNodeWebGLRenderCmd.js | 4 +- cocos2d/core/CCCamera.js | 2 +- cocos2d/core/CCConfiguration.js | 4 +- cocos2d/core/CCDirectorWebGL.js | 4 +- cocos2d/core/CCDrawingPrimitivesCanvas.js | 4 +- cocos2d/core/CCDrawingPrimitivesWebGL.js | 40 +- cocos2d/core/CCScheduler.js | 8 +- cocos2d/core/base-nodes/CCAtlasNode.js | 2 +- .../base-nodes/CCAtlasNodeWebGLRenderCmd.js | 10 +- cocos2d/core/base-nodes/CCSGNode.js | 20 +- .../base-nodes/CCSGNodeCanvasRenderCmd.js | 6 +- cocos2d/core/components/CCComponent.js | 4 +- cocos2d/core/label/CCSGLabelWebGLRenderCmd.js | 10 +- cocos2d/core/labelttf/CCLabelTTF.js | 6 +- cocos2d/core/layers/CCLayer.js | 4 +- cocos2d/core/layers/CCLayerWebGLRenderCmd.js | 12 +- cocos2d/core/platform/CCEGLView.js | 10 +- cocos2d/core/platform/CCMacro.js | 14 +- cocos2d/core/sprites/CCAnimationCache.js | 2 +- cocos2d/core/sprites/CCSGSprite.js | 10 +- .../core/sprites/CCSGSpriteWebGLRenderCmd.js | 896 +++++++++--------- cocos2d/core/sprites/CCScale9Sprite.js | 8 +- .../sprites/CCScale9SpriteWebGLRenderCmd.js | 16 +- cocos2d/core/sprites/CCSpriteBatchNode.js | 4 +- .../CCSpriteBatchNodeWebGLRenderCmd.js | 6 +- cocos2d/core/textures/CCTextureAtlas.js | 12 +- cocos2d/core/textures/CCTextureCache.js | 2 +- cocos2d/core/utils/CCProfiler.js | 6 +- cocos2d/core/utils/base-node.js | 4 +- cocos2d/core/value-types/CCTypes.js | 20 +- cocos2d/effects/CCGrid.js | 14 +- cocos2d/kazmath/utility.js | 4 +- cocos2d/labels/CCLabelAtlasWebGLRenderCmd.js | 4 +- cocos2d/labels/CCLabelBMFontWebGLRenderCmd.js | 2 +- cocos2d/menus/CCMenuItem.js | 22 +- cocos2d/motion-streak/CCMotionStreak.js | 2 +- .../CCMotionStreakWebGLRenderCmd.js | 10 +- cocos2d/node-grid/CCNodeGrid.js | 2 +- cocos2d/particle/CCParticleBatchNode.js | 12 +- .../CCParticleBatchNodeWebGLRenderCmd.js | 2 +- cocos2d/particle/CCSGParticleSystem.js | 20 +- .../CCSGParticleSystemCanvasRenderCmd.js | 4 +- .../CCSGParticleSystemWebGLRenderCmd.js | 20 +- .../CCProgressTimerWebGLRenderCmd.js | 12 +- .../CCRenderTextureCanvasRenderCmd.js | 2 +- cocos2d/shaders/CCGLProgram.js | 79 +- cocos2d/shaders/CCGLStateCache.js | 56 +- cocos2d/shaders/CCShaderCache.js | 2 +- cocos2d/shape-nodes/CCDrawNode.js | 14 +- .../shape-nodes/CCDrawNodeCanvasRenderCmd.js | 2 +- cocos2d/tilemap/CCSGTMXLayer.js | 4 +- cocos2d/transitions/CCTransition.js | 4 +- .../ccui/base-classes/CCProtectedNode.js | 4 +- extensions/ccui/layouts/UILayout.js | 8 +- .../cocostudio/action/CCActionObject.js | 2 +- extensions/cocostudio/armature/CCArmature.js | 2 +- .../armature/CCArmatureWebGLRenderCmd.js | 2 +- extensions/cocostudio/armature/CCBone.js | 2 +- .../cocostudio/armature/datas/CCDatas.js | 2 +- .../armature/display/CCBatchNode.js | 2 +- .../armature/display/CCSkinWebGLRenderCmd.js | 16 +- .../armature/utils/CCDataReaderHelper.js | 24 +- .../gui/control-extension/CCControlStepper.js | 2 +- extensions/gui/scrollview/CCSorting.js | 8 +- extensions/gui/scrollview/CCTableView.js | 16 +- extensions/spine/SGSkeleton.js | 8 +- extensions/spine/SGSkeletonWebGLRenderCmd.js | 8 +- external/gaf/Library/GAFShaderManager.js | 6 +- .../gaf/Library/GAFSpriteWebGLRenderCmd.js | 2 +- .../src/ClippingNodeTest/ClippingNodeTest.js | 12 +- .../src/CocosNodeTest/CocosNodeTest.js | 4 +- test/visual-tests/src/LabelTest/LabelTest.js | 4 +- test/visual-tests/src/LayerTest/LayerTest.js | 8 +- .../visual-tests/src/OpenGLTest/OpenGLTest.js | 32 +- .../src/SchedulerTest/SchedulerTest.js | 2 +- .../visual-tests/src/SpriteTest/SpriteTest.js | 12 +- 79 files changed, 824 insertions(+), 819 deletions(-) diff --git a/cocos2d/actions/CCActionCamera.js b/cocos2d/actions/CCActionCamera.js index 90b8a432c0..9f57d1a1f8 100644 --- a/cocos2d/actions/CCActionCamera.js +++ b/cocos2d/actions/CCActionCamera.js @@ -193,9 +193,9 @@ cc.OrbitCamera = cc.ActionCamera.extend({ var r = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2) + Math.pow(z, 2)); var s = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2)); if (s === 0.0) - s = cc.Macro.FLT_EPSILON; + s = cc.macro.FLT_EPSILON; if (r === 0.0) - r = cc.Macro.FLT_EPSILON; + r = cc.macro.FLT_EPSILON; zenith = Math.acos(z / r); if (x < 0) diff --git a/cocos2d/actions/CCActionCatmullRom.js b/cocos2d/actions/CCActionCatmullRom.js index b85de71125..d7ee983e17 100644 --- a/cocos2d/actions/CCActionCatmullRom.js +++ b/cocos2d/actions/CCActionCatmullRom.js @@ -216,7 +216,7 @@ cc.CardinalSplineTo = cc.ActionInterval.extend({ cc.getControlPointAt(ps, p + 2), this._tension, lt); - if (cc.Macro.ENABLE_STACKABLE_ACTIONS) { + if (cc.macro.ENABLE_STACKABLE_ACTIONS) { var tempX, tempY; tempX = this.target.getPositionX() - this._previousPosition.x; tempY = this.target.getPositionY() - this._previousPosition.y; diff --git a/cocos2d/actions/CCActionInterval.js b/cocos2d/actions/CCActionInterval.js index 11b0b7822c..59c2761741 100644 --- a/cocos2d/actions/CCActionInterval.js +++ b/cocos2d/actions/CCActionInterval.js @@ -1093,7 +1093,7 @@ cc.MoveBy = cc.ActionInterval.extend({ var x = this._positionDelta.x * dt; var y = this._positionDelta.y * dt; var locStartPosition = this._startPosition; - if (cc.Macro.ENABLE_STACKABLE_ACTIONS) { + if (cc.macro.ENABLE_STACKABLE_ACTIONS) { var targetX = this.target.getPositionX(); var targetY = this.target.getPositionY(); var locPreviousPosition = this._previousPosition; @@ -1460,7 +1460,7 @@ cc.JumpBy = cc.ActionInterval.extend({ var x = this._delta.x * dt; var locStartPosition = this._startPosition; - if (cc.Macro.ENABLE_STACKABLE_ACTIONS) { + if (cc.macro.ENABLE_STACKABLE_ACTIONS) { var targetX = this.target.getPositionX(); var targetY = this.target.getPositionY(); var locPreviousPosition = this._previousPosition; @@ -1680,7 +1680,7 @@ cc.BezierBy = cc.ActionInterval.extend({ var y = cc.bezierAt(ya, yb, yc, yd, dt); var locStartPosition = this._startPosition; - if (cc.Macro.ENABLE_STACKABLE_ACTIONS) { + if (cc.macro.ENABLE_STACKABLE_ACTIONS) { var targetX = this.target.getPositionX(); var targetY = this.target.getPositionY(); var locPreviousPosition = this._previousPosition; diff --git a/cocos2d/clipping-nodes/CCClippingNodeWebGLRenderCmd.js b/cocos2d/clipping-nodes/CCClippingNodeWebGLRenderCmd.js index c878551526..c66867c9e9 100644 --- a/cocos2d/clipping-nodes/CCClippingNodeWebGLRenderCmd.js +++ b/cocos2d/clipping-nodes/CCClippingNodeWebGLRenderCmd.js @@ -206,8 +206,8 @@ gl.stencilOp(!node.inverted ? gl.REPLACE : gl.ZERO, gl.KEEP, gl.KEEP); if (node.alphaThreshold < 1) { //TODO desktop - var program = cc.shaderCache.programForKey(cc.Macro.SHADER_POSITION_TEXTURECOLORALPHATEST); - var alphaValueLocation = gl.getUniformLocation(program.getProgram(), cc.Macro.UNIFORM_ALPHA_TEST_VALUE_S); + var program = cc.shaderCache.programForKey(cc.macro.SHADER_POSITION_TEXTURECOLORALPHATEST); + var alphaValueLocation = gl.getUniformLocation(program.getProgram(), cc.macro.UNIFORM_ALPHA_TEST_VALUE_S); // set our alphaThreshold cc.glUseProgram(program.getProgram()); program.setUniformLocationWith1f(alphaValueLocation, node.alphaThreshold); diff --git a/cocos2d/core/CCCamera.js b/cocos2d/core/CCCamera.js index d98cf36995..c55aaed99a 100644 --- a/cocos2d/core/CCCamera.js +++ b/cocos2d/core/CCCamera.js @@ -278,5 +278,5 @@ cc.Camera = cc._Class.extend({ * @return {Number} */ cc.Camera.getZEye = function () { - return cc.Macro.FLT_EPSILON; + return cc.macro.FLT_EPSILON; }; diff --git a/cocos2d/core/CCConfiguration.js b/cocos2d/core/CCConfiguration.js index 519b12650a..a27ee0f88b 100644 --- a/cocos2d/core/CCConfiguration.js +++ b/cocos2d/core/CCConfiguration.js @@ -91,7 +91,7 @@ cc.configuration = /** @lends cc.configuration# */{ var locValueDict = this._valueDict; locValueDict["cocos2d.x.version"] = cc.ENGINE_VERSION; locValueDict["cocos2d.x.compiled_with_profiler"] = false; - locValueDict["cocos2d.x.compiled_with_gl_state_cache"] = cc.Macro.ENABLE_GL_STATE_CACHE; + locValueDict["cocos2d.x.compiled_with_gl_state_cache"] = cc.macro.ENABLE_GL_STATE_CACHE; this._inited = true; }, @@ -220,7 +220,7 @@ cc.configuration = /** @lends cc.configuration# */{ * Dumps the current configuration on the console */ dumpInfo: function(){ - if(cc.Macro.ENABLE_GL_STATE_CACHE === 0){ + if(cc.macro.ENABLE_GL_STATE_CACHE === 0){ cc.log(""); cc.log(cc._LogInfos.configuration.dumpInfo); cc.log("") diff --git a/cocos2d/core/CCDirectorWebGL.js b/cocos2d/core/CCDirectorWebGL.js index 1fb8edf7bf..09393ccb89 100644 --- a/cocos2d/core/CCDirectorWebGL.js +++ b/cocos2d/core/CCDirectorWebGL.js @@ -253,9 +253,9 @@ cc.game.once(cc.game.EVENT_RENDERER_INITED, function () { _p.setAlphaBlending = function (on) { if (on) - cc.glBlendFunc(cc.Macro.BLEND_SRC, cc.Macro.BLEND_DST); + cc.glBlendFunc(cc.macro.BLEND_SRC, cc.macro.BLEND_DST); else - cc.glBlendFunc(cc.Macro.ONE, cc.Macro.ZERO); + cc.glBlendFunc(cc.macro.ONE, cc.macro.ZERO); //cc.checkGLErrorDebug(); }; diff --git a/cocos2d/core/CCDrawingPrimitivesCanvas.js b/cocos2d/core/CCDrawingPrimitivesCanvas.js index ccd16b324a..059b264910 100644 --- a/cocos2d/core/CCDrawingPrimitivesCanvas.js +++ b/cocos2d/core/CCDrawingPrimitivesCanvas.js @@ -360,7 +360,7 @@ cc.DrawingPrimitiveCanvas = cc._Class.extend(/** @lends cc.DrawingPrimitiveCanva //context.fillStyle = g1; context.beginPath(); var startAngle_1 = 0; - var endAngle_1 = cc.Macro.PI2; + var endAngle_1 = cc.macro.PI2; context.arc(0, 0, radius - subRadius, startAngle_1, endAngle_1, false); context.closePath(); context.fill(); @@ -388,7 +388,7 @@ cc.DrawingPrimitiveCanvas = cc._Class.extend(/** @lends cc.DrawingPrimitiveCanva //context.fillStyle = g1; context.beginPath(); var startAngle_1 = 0; - var endAngle_1 = cc.Macro.PI2; + var endAngle_1 = cc.macro.PI2; context.arc(0, 0, radius, startAngle_1, endAngle_1, false); context.closePath(); context.fill(); diff --git a/cocos2d/core/CCDrawingPrimitivesWebGL.js b/cocos2d/core/CCDrawingPrimitivesWebGL.js index 90d1c4c949..9de26e294d 100644 --- a/cocos2d/core/CCDrawingPrimitivesWebGL.js +++ b/cocos2d/core/CCDrawingPrimitivesWebGL.js @@ -24,6 +24,8 @@ THE SOFTWARE. ****************************************************************************/ +var macro = cc.macro; + /** * Canvas of DrawingPrimitive implement version use for WebGlMode * @class @@ -58,7 +60,7 @@ cc.DrawingPrimitiveWebGL = cc._Class.extend(/** @lends cc.DrawingPrimitiveWebGL# // // Position and 1 color passed as a uniform (to similate glColor4ub ) // - _t._shader = cc.shaderCache.programForKey(cc.Macro.SHADER_POSITION_UCOLOR); + _t._shader = cc.shaderCache.programForKey(macro.SHADER_POSITION_UCOLOR); _t._colorLocation = _t._renderContext.getUniformLocation(_t._shader.getProgram(), "u_color"); _t._pointSizeLocation = _t._renderContext.getUniformLocation(_t._shader.getProgram(), "u_pointSize"); @@ -83,14 +85,14 @@ cc.DrawingPrimitiveWebGL = cc._Class.extend(/** @lends cc.DrawingPrimitiveWebGL# var glContext = this._renderContext; this._shader.use(); this._shader.setUniformForModelViewAndProjectionMatrixWithMat4(); - cc.glEnableVertexAttribs(cc.Macro.VERTEX_ATTRIB_FLAG_POSITION); + cc.glEnableVertexAttribs(macro.VERTEX_ATTRIB_FLAG_POSITION); glContext.uniform4fv(this._colorLocation, this._colorArray); this._shader.setUniformLocationWith1f(this._pointSizeLocation, this._pointSize); var pointBuffer = glContext.createBuffer(); glContext.bindBuffer(glContext.ARRAY_BUFFER, pointBuffer); glContext.bufferData(glContext.ARRAY_BUFFER, new Float32Array([point.x, point.y]), glContext.STATIC_DRAW); - glContext.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_POSITION, 2, glContext.FLOAT, false, 0, 0); + glContext.vertexAttribPointer(macro.VERTEX_ATTRIB_POSITION, 2, glContext.FLOAT, false, 0, 0); glContext.drawArrays(glContext.POINTS, 0, 1); glContext.deleteBuffer(pointBuffer); @@ -112,14 +114,14 @@ cc.DrawingPrimitiveWebGL = cc._Class.extend(/** @lends cc.DrawingPrimitiveWebGL# var glContext = this._renderContext; this._shader.use(); this._shader.setUniformForModelViewAndProjectionMatrixWithMat4(); - cc.glEnableVertexAttribs(cc.Macro.VERTEX_ATTRIB_FLAG_POSITION); + cc.glEnableVertexAttribs(macro.VERTEX_ATTRIB_FLAG_POSITION); glContext.uniform4fv(this._colorLocation, this._colorArray); this._shader.setUniformLocationWith1f(this._pointSizeLocation, this._pointSize); var pointBuffer = glContext.createBuffer(); glContext.bindBuffer(glContext.ARRAY_BUFFER, pointBuffer); glContext.bufferData(glContext.ARRAY_BUFFER, this._pointsToTypeArray(points), glContext.STATIC_DRAW); - glContext.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_POSITION, 2, glContext.FLOAT, false, 0, 0); + glContext.vertexAttribPointer(macro.VERTEX_ATTRIB_POSITION, 2, glContext.FLOAT, false, 0, 0); glContext.drawArrays(glContext.POINTS, 0, points.length); glContext.deleteBuffer(pointBuffer); @@ -147,13 +149,13 @@ cc.DrawingPrimitiveWebGL = cc._Class.extend(/** @lends cc.DrawingPrimitiveWebGL# var glContext = this._renderContext; this._shader.use(); this._shader.setUniformForModelViewAndProjectionMatrixWithMat4(); - cc.glEnableVertexAttribs(cc.Macro.VERTEX_ATTRIB_FLAG_POSITION); + cc.glEnableVertexAttribs(macro.VERTEX_ATTRIB_FLAG_POSITION); glContext.uniform4fv(this._colorLocation, this._colorArray); var pointBuffer = glContext.createBuffer(); glContext.bindBuffer(glContext.ARRAY_BUFFER, pointBuffer); glContext.bufferData(glContext.ARRAY_BUFFER, this._pointsToTypeArray([origin, destination]), glContext.STATIC_DRAW); - glContext.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_POSITION, 2, glContext.FLOAT, false, 0, 0); + glContext.vertexAttribPointer(macro.VERTEX_ATTRIB_POSITION, 2, glContext.FLOAT, false, 0, 0); glContext.drawArrays(glContext.LINES, 0, 2); glContext.deleteBuffer(pointBuffer); @@ -202,13 +204,13 @@ cc.DrawingPrimitiveWebGL = cc._Class.extend(/** @lends cc.DrawingPrimitiveWebGL# var glContext = this._renderContext; this._shader.use(); this._shader.setUniformForModelViewAndProjectionMatrixWithMat4(); - cc.glEnableVertexAttribs(cc.Macro.VERTEX_ATTRIB_FLAG_POSITION); + cc.glEnableVertexAttribs(macro.VERTEX_ATTRIB_FLAG_POSITION); glContext.uniform4fv(this._colorLocation, this._colorArray); var pointBuffer = glContext.createBuffer(); glContext.bindBuffer(glContext.ARRAY_BUFFER, pointBuffer); glContext.bufferData(glContext.ARRAY_BUFFER, this._pointsToTypeArray(vertices), glContext.STATIC_DRAW); - glContext.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_POSITION, 2, glContext.FLOAT, false, 0, 0); + glContext.vertexAttribPointer(macro.VERTEX_ATTRIB_POSITION, 2, glContext.FLOAT, false, 0, 0); if (closePolygon) glContext.drawArrays(glContext.LINE_LOOP, 0, vertices.length); @@ -233,13 +235,13 @@ cc.DrawingPrimitiveWebGL = cc._Class.extend(/** @lends cc.DrawingPrimitiveWebGL# var glContext = this._renderContext; this._shader.use(); this._shader.setUniformForModelViewAndProjectionMatrixWithMat4(); - cc.glEnableVertexAttribs(cc.Macro.VERTEX_ATTRIB_FLAG_POSITION); + cc.glEnableVertexAttribs(macro.VERTEX_ATTRIB_FLAG_POSITION); glContext.uniform4fv(this._colorLocation, this._colorArray); var pointBuffer = glContext.createBuffer(); glContext.bindBuffer(glContext.ARRAY_BUFFER, pointBuffer); glContext.bufferData(glContext.ARRAY_BUFFER, this._pointsToTypeArray(poli), glContext.STATIC_DRAW); - glContext.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_POSITION, 2, glContext.FLOAT, false, 0, 0); + glContext.vertexAttribPointer(macro.VERTEX_ATTRIB_POSITION, 2, glContext.FLOAT, false, 0, 0); glContext.drawArrays(glContext.TRIANGLE_FAN, 0, poli.length); glContext.deleteBuffer(pointBuffer); @@ -281,13 +283,13 @@ cc.DrawingPrimitiveWebGL = cc._Class.extend(/** @lends cc.DrawingPrimitiveWebGL# var glContext = this._renderContext; this._shader.use(); this._shader.setUniformForModelViewAndProjectionMatrixWithMat4(); - cc.glEnableVertexAttribs(cc.Macro.VERTEX_ATTRIB_FLAG_POSITION); + cc.glEnableVertexAttribs(macro.VERTEX_ATTRIB_FLAG_POSITION); glContext.uniform4fv(this._colorLocation, this._colorArray); var pointBuffer = glContext.createBuffer(); glContext.bindBuffer(glContext.ARRAY_BUFFER, pointBuffer); glContext.bufferData(glContext.ARRAY_BUFFER, vertices, glContext.STATIC_DRAW); - glContext.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_POSITION, 2, glContext.FLOAT, false, 0, 0); + glContext.vertexAttribPointer(macro.VERTEX_ATTRIB_POSITION, 2, glContext.FLOAT, false, 0, 0); glContext.drawArrays(glContext.LINE_STRIP, 0, segments + additionalSegment); glContext.deleteBuffer(pointBuffer); @@ -319,13 +321,13 @@ cc.DrawingPrimitiveWebGL = cc._Class.extend(/** @lends cc.DrawingPrimitiveWebGL# var glContext = this._renderContext; this._shader.use(); this._shader.setUniformForModelViewAndProjectionMatrixWithMat4(); - cc.glEnableVertexAttribs(cc.Macro.VERTEX_ATTRIB_FLAG_POSITION); + cc.glEnableVertexAttribs(macro.VERTEX_ATTRIB_FLAG_POSITION); glContext.uniform4fv(this._colorLocation, this._colorArray); var pointBuffer = glContext.createBuffer(); glContext.bindBuffer(glContext.ARRAY_BUFFER, pointBuffer); glContext.bufferData(glContext.ARRAY_BUFFER, vertices, glContext.STATIC_DRAW); - glContext.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_POSITION, 2, glContext.FLOAT, false, 0, 0); + glContext.vertexAttribPointer(macro.VERTEX_ATTRIB_POSITION, 2, glContext.FLOAT, false, 0, 0); glContext.drawArrays(glContext.LINE_STRIP, 0, segments + 1); glContext.deleteBuffer(pointBuffer); @@ -358,13 +360,13 @@ cc.DrawingPrimitiveWebGL = cc._Class.extend(/** @lends cc.DrawingPrimitiveWebGL# var glContext = this._renderContext; this._shader.use(); this._shader.setUniformForModelViewAndProjectionMatrixWithMat4(); - cc.glEnableVertexAttribs(cc.Macro.VERTEX_ATTRIB_FLAG_POSITION); + cc.glEnableVertexAttribs(macro.VERTEX_ATTRIB_FLAG_POSITION); glContext.uniform4fv(this._colorLocation, this._colorArray); var pointBuffer = glContext.createBuffer(); glContext.bindBuffer(glContext.ARRAY_BUFFER, pointBuffer); glContext.bufferData(glContext.ARRAY_BUFFER, vertices, glContext.STATIC_DRAW); - glContext.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_POSITION, 2, glContext.FLOAT, false, 0, 0); + glContext.vertexAttribPointer(macro.VERTEX_ATTRIB_POSITION, 2, glContext.FLOAT, false, 0, 0); glContext.drawArrays(glContext.LINE_STRIP, 0, segments + 1); glContext.deleteBuffer(pointBuffer); @@ -418,13 +420,13 @@ cc.DrawingPrimitiveWebGL = cc._Class.extend(/** @lends cc.DrawingPrimitiveWebGL# var glContext = this._renderContext; this._shader.use(); this._shader.setUniformForModelViewAndProjectionMatrixWithMat4(); - cc.glEnableVertexAttribs(cc.Macro.VERTEX_ATTRIB_FLAG_POSITION); + cc.glEnableVertexAttribs(macro.VERTEX_ATTRIB_FLAG_POSITION); glContext.uniform4fv(this._colorLocation, this._colorArray); var pointBuffer = glContext.createBuffer(); glContext.bindBuffer(glContext.ARRAY_BUFFER, pointBuffer); glContext.bufferData(glContext.ARRAY_BUFFER, vertices, glContext.STATIC_DRAW); - glContext.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_POSITION, 2, glContext.FLOAT, false, 0, 0); + glContext.vertexAttribPointer(macro.VERTEX_ATTRIB_POSITION, 2, glContext.FLOAT, false, 0, 0); glContext.drawArrays(glContext.LINE_STRIP, 0, segments + 1); glContext.deleteBuffer(pointBuffer); diff --git a/cocos2d/core/CCScheduler.js b/cocos2d/core/CCScheduler.js index 37bdffac25..0ac6974a3a 100644 --- a/cocos2d/core/CCScheduler.js +++ b/cocos2d/core/CCScheduler.js @@ -124,7 +124,7 @@ cc.Timer = cc._Class.extend(/** @lends cc.Timer# */{ this._delay = delay; this._useDelay = (this._delay > 0); this._repeat = repeat; - this._runForever = (this._repeat === cc.Macro.REPEAT_FOREVER); + this._runForever = (this._repeat === cc.macro.REPEAT_FOREVER); }, trigger: function(){ @@ -519,7 +519,7 @@ cc.Scheduler = cc._Class.extend(/** @lends cc.Scheduler# */{ * If paused is YES, then it won't be called until it is resumed.
* If 'interval' is 0, it will be called every frame, but if so, it recommended to use 'scheduleUpdateForTarget:' instead.
* If the callback function is already scheduled, then only the interval parameter will be updated without re-scheduling it again.
- * repeat let the action be repeated repeat + 1 times, use cc.Macro.REPEAT_FOREVER to let the action run continuously
+ * repeat let the action be repeated repeat + 1 times, use cc.macro.REPEAT_FOREVER to let the action run continuously
* delay is the amount of time the action will wait before it'll start
*

* @method scheduleCallbackForTarget @@ -563,14 +563,14 @@ cc.Scheduler = cc._Class.extend(/** @lends cc.Scheduler# */{ key = delay; paused = repeat; delay = 0; - repeat = cc.Macro.REPEAT_FOREVER; + repeat = cc.macro.REPEAT_FOREVER; } }else{ //selector, target, interval, repeat, delay, paused //selector, target, interval, paused if(arguments.length === 4){ paused = repeat; - repeat = cc.Macro.REPEAT_FOREVER; + repeat = cc.macro.REPEAT_FOREVER; delay = 0; } } diff --git a/cocos2d/core/base-nodes/CCAtlasNode.js b/cocos2d/core/base-nodes/CCAtlasNode.js index 03a5a677d4..1f1582fbab 100644 --- a/cocos2d/core/base-nodes/CCAtlasNode.js +++ b/cocos2d/core/base-nodes/CCAtlasNode.js @@ -84,7 +84,7 @@ cc.AtlasNode = _ccsg.Node.extend(/** @lends cc.AtlasNode# */{ _ccsg.Node.prototype.ctor.call(this); EventTarget.call(this); - this._blendFunc = {src: cc.Macro.BLEND_SRC, dst: cc.Macro.BLEND_DST}; + this._blendFunc = {src: cc.macro.BLEND_SRC, dst: cc.macro.BLEND_DST}; this._ignoreContentScaleFactor = false; itemsToRender !== undefined && this.initWithTileFile(tile, tileWidth, tileHeight, itemsToRender); }, diff --git a/cocos2d/core/base-nodes/CCAtlasNodeWebGLRenderCmd.js b/cocos2d/core/base-nodes/CCAtlasNodeWebGLRenderCmd.js index f1c08e9e74..fbbbc15d80 100644 --- a/cocos2d/core/base-nodes/CCAtlasNodeWebGLRenderCmd.js +++ b/cocos2d/core/base-nodes/CCAtlasNodeWebGLRenderCmd.js @@ -35,7 +35,7 @@ this._uniformColor = null; //shader stuff - this._shaderProgram = cc.shaderCache.programForKey(cc.Macro.SHADER_POSITION_TEXTURE_UCOLOR); + this._shaderProgram = cc.shaderCache.programForKey(cc.macro.SHADER_POSITION_TEXTURE_UCOLOR); this._uniformColor = cc._renderContext.getUniformLocation(this._shaderProgram.getProgram(), "u_color"); }; @@ -45,8 +45,8 @@ proto._updateBlendFunc = function () { var node = this._node; if (!this._textureAtlas.texture.hasPremultipliedAlpha()) { - node._blendFunc.src = cc.Macro.SRC_ALPHA; - node._blendFunc.dst = cc.Macro.ONE_MINUS_SRC_ALPHA; + node._blendFunc.src = cc.macro.SRC_ALPHA; + node._blendFunc.dst = cc.macro.ONE_MINUS_SRC_ALPHA; } }; @@ -74,8 +74,8 @@ this._colorUnmodified = cc.Color.WHITE; node._opacityModifyRGB = true; - node._blendFunc.src = cc.Macro.BLEND_SRC; - node._blendFunc.dst = cc.Macro.BLEND_DST; + node._blendFunc.src = cc.macro.BLEND_SRC; + node._blendFunc.dst = cc.macro.BLEND_DST; var locRealColor = node._realColor; this._colorF32Array = new Float32Array([locRealColor.r / 255.0, locRealColor.g / 255.0, locRealColor.b / 255.0, node._realOpacity / 255.0]); diff --git a/cocos2d/core/base-nodes/CCSGNode.js b/cocos2d/core/base-nodes/CCSGNode.js index 459e20dab4..abc4f99a70 100644 --- a/cocos2d/core/base-nodes/CCSGNode.js +++ b/cocos2d/core/base-nodes/CCSGNode.js @@ -142,7 +142,7 @@ _ccsg.Node = cc.Class({ // "whole screen" objects. like Scenes and Layers, should set _ignoreAnchorPointForPosition to true _ignoreAnchorPointForPosition: false, - tag: cc.Macro.NODE_TAG_INVALID, + tag: cc.macro.NODE_TAG_INVALID, _showNode: false, _name: '', ///= 0, cc._LogInfos.Node.schedule_2); interval = interval || 0; - repeat = (repeat == null) ? cc.Macro.REPEAT_FOREVER : repeat; + repeat = (repeat == null) ? cc.macro.REPEAT_FOREVER : repeat; delay = delay || 0; this.scheduler.schedule(callback, this, interval, repeat, delay, !this._running, key); @@ -2002,7 +2002,7 @@ _ccsg.Node = cc.Class({ * @function * @param {cc.GLProgram} newShaderProgram The shader program which fetches from CCShaderCache. * @example - * node.setGLProgram(cc.shaderCache.programForKey(cc.Macro.SHADER_POSITION_TEXTURECOLOR)); + * node.setGLProgram(cc.shaderCache.programForKey(cc.macro.SHADER_POSITION_TEXTURECOLOR)); */ setShaderProgram: function (newShaderProgram) { this._renderCmd.setShaderProgram(newShaderProgram); diff --git a/cocos2d/core/base-nodes/CCSGNodeCanvasRenderCmd.js b/cocos2d/core/base-nodes/CCSGNodeCanvasRenderCmd.js index caedf8dc2f..b0fc26c2b8 100644 --- a/cocos2d/core/base-nodes/CCSGNodeCanvasRenderCmd.js +++ b/cocos2d/core/base-nodes/CCSGNodeCanvasRenderCmd.js @@ -511,11 +511,11 @@ _ccsg.Node.RenderCmd.prototype = { if (!blendFunc) return "source-over"; else { - if (( blendFunc.src === cc.Macro.SRC_ALPHA && blendFunc.dst === cc.Macro.ONE) || (blendFunc.src === cc.Macro.ONE && blendFunc.dst === cc.Macro.ONE)) + if (( blendFunc.src === cc.macro.SRC_ALPHA && blendFunc.dst === cc.macro.ONE) || (blendFunc.src === cc.macro.ONE && blendFunc.dst === cc.macro.ONE)) return "lighter"; - else if (blendFunc.src === cc.Macro.ZERO && blendFunc.dst === cc.Macro.SRC_ALPHA) + else if (blendFunc.src === cc.macro.ZERO && blendFunc.dst === cc.macro.SRC_ALPHA) return "destination-in"; - else if (blendFunc.src === cc.Macro.ZERO && blendFunc.dst === cc.Macro.ONE_MINUS_SRC_ALPHA) + else if (blendFunc.src === cc.macro.ZERO && blendFunc.dst === cc.macro.ONE_MINUS_SRC_ALPHA) return "destination-out"; else return "source-over"; diff --git a/cocos2d/core/components/CCComponent.js b/cocos2d/core/components/CCComponent.js index d28dfade68..0b0cc48efb 100644 --- a/cocos2d/core/components/CCComponent.js +++ b/cocos2d/core/components/CCComponent.js @@ -696,7 +696,7 @@ var Component = cc.Class({ * @method schedule * @param {function} callback The callback function * @param {Number} [interval=0] Tick interval in seconds. 0 means tick every frame. If interval = 0, it's recommended to use scheduleUpdate() instead. - * @param {Number} [repeat=cc.Macro.REPEAT_FOREVER] The selector will be executed (repeat + 1) times, you can use kCCRepeatForever for tick infinitely. + * @param {Number} [repeat=cc.macro.REPEAT_FOREVER] The selector will be executed (repeat + 1) times, you can use kCCRepeatForever for tick infinitely. * @param {Number} [delay=0] The amount of time that the first tick will wait before execution. */ schedule: function (callback, interval, repeat, delay) { @@ -704,7 +704,7 @@ var Component = cc.Class({ cc.assert(interval >= 0, cc._LogInfos.Node.schedule_2); interval = interval || 0; - repeat = isNaN(repeat) ? cc.Macro.REPEAT_FOREVER : repeat; + repeat = isNaN(repeat) ? cc.macro.REPEAT_FOREVER : repeat; delay = delay || 0; cc.director.getScheduler().schedule(callback, this, interval, repeat, delay, !this.enabledInHierarchy, this.__instanceId); diff --git a/cocos2d/core/label/CCSGLabelWebGLRenderCmd.js b/cocos2d/core/label/CCSGLabelWebGLRenderCmd.js index a26447fee5..55ddb784b7 100644 --- a/cocos2d/core/label/CCSGLabelWebGLRenderCmd.js +++ b/cocos2d/core/label/CCSGLabelWebGLRenderCmd.js @@ -37,7 +37,7 @@ this._labelTexture = new cc.Texture2D(); this._quadWebBuffer = cc._renderContext.createBuffer(); - this._shaderProgram = cc.shaderCache.programForKey(cc.Macro.SHADER_POSITION_TEXTURECOLOR); + this._shaderProgram = cc.shaderCache.programForKey(cc.macro.SHADER_POSITION_TEXTURECOLOR); this._quad = new cc.V3F_C4B_T2F_Quad(); this._labelCanvas = document.createElement("canvas"); @@ -72,7 +72,7 @@ cc.glBlendFunc(node._blendFunc.src,node._blendFunc.dst); cc.glBindTexture2DN(0,this._labelTexture); - cc.glEnableVertexAttribs(cc.Macro.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); + cc.glEnableVertexAttribs(cc.macro.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); gl.bindBuffer(gl.ARRAY_BUFFER, this._quadWebBuffer); @@ -81,9 +81,9 @@ this._quadDirty = false; } - gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 24, 0); //cc.Macro.VERTEX_ATTRIB_POSITION - gl.vertexAttribPointer(1, 4, gl.UNSIGNED_BYTE, true, 24, 12); //cc.Macro.VERTEX_ATTRIB_COLOR - gl.vertexAttribPointer(2, 2, gl.FLOAT, false, 24, 16); //cc.Macro.VERTEX_ATTRIB_TEX_COORDS + gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 24, 0); //cc.macro.VERTEX_ATTRIB_POSITION + gl.vertexAttribPointer(1, 4, gl.UNSIGNED_BYTE, true, 24, 12); //cc.macro.VERTEX_ATTRIB_COLOR + gl.vertexAttribPointer(2, 2, gl.FLOAT, false, 24, 16); //cc.macro.VERTEX_ATTRIB_TEX_COORDS gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); } diff --git a/cocos2d/core/labelttf/CCLabelTTF.js b/cocos2d/core/labelttf/CCLabelTTF.js index d8d5ecd10c..ad4084b35c 100644 --- a/cocos2d/core/labelttf/CCLabelTTF.js +++ b/cocos2d/core/labelttf/CCLabelTTF.js @@ -806,10 +806,10 @@ cc.LabelTTF.create = function (text, fontName, fontSize, dimensions, hAlignment, */ cc.LabelTTF.createWithFontDefinition = cc.LabelTTF.create; -if (cc.Macro.USE_LA88_LABELS) - cc.LabelTTF._SHADER_PROGRAM = cc.Macro.SHADER_POSITION_TEXTURECOLOR; +if (cc.macro.USE_LA88_LABELS) + cc.LabelTTF._SHADER_PROGRAM = cc.macro.SHADER_POSITION_TEXTURECOLOR; else - cc.LabelTTF._SHADER_PROGRAM = cc.Macro.SHADER_POSITION_TEXTUREA8COLOR; + cc.LabelTTF._SHADER_PROGRAM = cc.macro.SHADER_POSITION_TEXTUREA8COLOR; cc.LabelTTF.__labelHeightDiv = document.createElement("div"); cc.LabelTTF.__labelHeightDiv.style.fontFamily = "Arial"; diff --git a/cocos2d/core/layers/CCLayer.js b/cocos2d/core/layers/CCLayer.js index 00bce44b87..28cfce1eef 100644 --- a/cocos2d/core/layers/CCLayer.js +++ b/cocos2d/core/layers/CCLayer.js @@ -181,7 +181,7 @@ cc.LayerColor = cc.Layer.extend(/** @lends cc.LayerColor# */{ */ ctor: function(color, width, height){ cc.Layer.prototype.ctor.call(this); - this._blendFunc = new cc.BlendFunc(cc.Macro.SRC_ALPHA, cc.Macro.ONE_MINUS_SRC_ALPHA); + this._blendFunc = new cc.BlendFunc(cc.macro.SRC_ALPHA, cc.macro.ONE_MINUS_SRC_ALPHA); cc.LayerColor.prototype.init.call(this, color, width, height); }, @@ -194,7 +194,7 @@ cc.LayerColor = cc.Layer.extend(/** @lends cc.LayerColor# */{ */ init: function (color, width, height) { if (cc._renderType !== cc.game.RENDER_TYPE_CANVAS) - this.shaderProgram = cc.shaderCache.programForKey(cc.Macro.SHADER_POSITION_COLOR); + this.shaderProgram = cc.shaderCache.programForKey(cc.macro.SHADER_POSITION_COLOR); var winSize = cc.director.getWinSize(); color = color || cc.color(0, 0, 0, 255); diff --git a/cocos2d/core/layers/CCLayerWebGLRenderCmd.js b/cocos2d/core/layers/CCLayerWebGLRenderCmd.js index 78ebbfe8a4..4d6149f475 100644 --- a/cocos2d/core/layers/CCLayerWebGLRenderCmd.js +++ b/cocos2d/core/layers/CCLayerWebGLRenderCmd.js @@ -81,17 +81,17 @@ this._shaderProgram.use(); this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix); - cc.glEnableVertexAttribs(cc.Macro.VERTEX_ATTRIB_FLAG_POSITION | cc.Macro.VERTEX_ATTRIB_FLAG_COLOR); + cc.glEnableVertexAttribs(cc.macro.VERTEX_ATTRIB_FLAG_POSITION | cc.macro.VERTEX_ATTRIB_FLAG_COLOR); cc.glBlendFunc(node._blendFunc.src, node._blendFunc.dst); // // Attributes // context.bindBuffer(context.ARRAY_BUFFER, this._verticesFloat32Buffer); - context.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_POSITION, 2, context.FLOAT, false, 0, 0); + context.vertexAttribPointer(cc.macro.VERTEX_ATTRIB_POSITION, 2, context.FLOAT, false, 0, 0); context.bindBuffer(context.ARRAY_BUFFER, this._colorsUint8Buffer); - context.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_COLOR, 4, context.UNSIGNED_BYTE, true, 0, 0); + context.vertexAttribPointer(cc.macro.VERTEX_ATTRIB_COLOR, 4, context.UNSIGNED_BYTE, true, 0, 0); context.drawArrays(context.TRIANGLE_STRIP, 0, this._squareVertices.length); }; @@ -285,15 +285,15 @@ //draw gradient layer this._shaderProgram.use(); this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix); - cc.glEnableVertexAttribs(cc.Macro.VERTEX_ATTRIB_FLAG_POSITION | cc.Macro.VERTEX_ATTRIB_FLAG_COLOR); + cc.glEnableVertexAttribs(cc.macro.VERTEX_ATTRIB_FLAG_POSITION | cc.macro.VERTEX_ATTRIB_FLAG_COLOR); cc.glBlendFunc(node._blendFunc.src, node._blendFunc.dst); // // Attributes // context.bindBuffer(context.ARRAY_BUFFER, this._verticesFloat32Buffer); - context.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_POSITION, 2, context.FLOAT, false, 0, 0); + context.vertexAttribPointer(cc.macro.VERTEX_ATTRIB_POSITION, 2, context.FLOAT, false, 0, 0); context.bindBuffer(context.ARRAY_BUFFER, this._colorsUint8Buffer); - context.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_COLOR, 4, context.UNSIGNED_BYTE, true, 0, 0); + context.vertexAttribPointer(cc.macro.VERTEX_ATTRIB_COLOR, 4, context.UNSIGNED_BYTE, true, 0, 0); context.drawArrays(context.TRIANGLE_STRIP, 0, this._squareVertices.length); context.disable(context.SCISSOR_TEST); diff --git a/cocos2d/core/platform/CCEGLView.js b/cocos2d/core/platform/CCEGLView.js index c2a07be00d..3c0f917446 100644 --- a/cocos2d/core/platform/CCEGLView.js +++ b/cocos2d/core/platform/CCEGLView.js @@ -182,7 +182,7 @@ cc.EGLView = cc._Class.extend({ _t._hDC = cc.game.canvas; _t._hRC = cc._renderContext; - _t._targetDensityDPI = cc.Macro.DENSITYDPI_HIGH; + _t._targetDensityDPI = cc.macro.DENSITYDPI_HIGH; }, // Resize helper functions @@ -215,10 +215,10 @@ cc.EGLView = cc._Class.extend({ /** *

* Sets view's target-densitydpi for android mobile browser. it can be set to:
- * 1. cc.Macro.DENSITYDPI_DEVICE, value is "device-dpi"
- * 2. cc.Macro.DENSITYDPI_HIGH, value is "high-dpi" (default value)
- * 3. cc.Macro.DENSITYDPI_MEDIUM, value is "medium-dpi" (browser's default value)
- * 4. cc.Macro.DENSITYDPI_LOW, value is "low-dpi"
+ * 1. cc.macro.DENSITYDPI_DEVICE, value is "device-dpi"
+ * 2. cc.macro.DENSITYDPI_HIGH, value is "high-dpi" (default value)
+ * 3. cc.macro.DENSITYDPI_MEDIUM, value is "medium-dpi" (browser's default value)
+ * 4. cc.macro.DENSITYDPI_LOW, value is "low-dpi"
* 5. Custom value, e.g: "480"
*

* diff --git a/cocos2d/core/platform/CCMacro.js b/cocos2d/core/platform/CCMacro.js index 863623b673..4c7b91776e 100644 --- a/cocos2d/core/platform/CCMacro.js +++ b/cocos2d/core/platform/CCMacro.js @@ -795,7 +795,7 @@ cc.getImageFormatByData = function (imgData) { * @type {Object} * @namespace cc */ -cc.Macro = { +cc.macro = { /** * @property INVALID_INDEX * @type {Number} @@ -1563,13 +1563,13 @@ cc.Macro = { * @type {Number} * @readonly */ -cc.defineGetterSetter(cc.Macro, "BLEND_SRC", function (){ +cc.defineGetterSetter(cc.macro, "BLEND_SRC", function (){ if (cc._renderType === cc.game.RENDER_TYPE_WEBGL - && cc.Macro.OPTIMIZE_BLEND_FUNC_FOR_PREMULTIPLIED_ALPHA) { - return cc.Macro.ONE; + && cc.macro.OPTIMIZE_BLEND_FUNC_FOR_PREMULTIPLIED_ALPHA) { + return cc.macro.ONE; } else { - return cc.Macro.SRC_ALPHA; + return cc.macro.SRC_ALPHA; } }); @@ -1612,7 +1612,7 @@ cc.randomMinus1To1 = function () { * @method degreesToRadians */ cc.degreesToRadians = function (angle) { - return angle * cc.Macro.RAD; + return angle * cc.macro.RAD; }; /** @@ -1622,7 +1622,7 @@ cc.degreesToRadians = function (angle) { * @method radiansToDegrees */ cc.radiansToDegrees = function (angle) { - return angle * cc.Macro.DEG; + return angle * cc.macro.DEG; }; /** diff --git a/cocos2d/core/sprites/CCAnimationCache.js b/cocos2d/core/sprites/CCAnimationCache.js index 613150fcdb..7297f19402 100644 --- a/cocos2d/core/sprites/CCAnimationCache.js +++ b/cocos2d/core/sprites/CCAnimationCache.js @@ -172,7 +172,7 @@ cc.spriteFrameAnimationCache = { var isLoop = animationDict["loop"]; var loopsTemp = parseInt(animationDict["loops"]); - var loops = isLoop ? cc.Macro.REPEAT_FOREVER : ((isNaN(loopsTemp)) ? 1 : loopsTemp); + var loops = isLoop ? cc.macro.REPEAT_FOREVER : ((isNaN(loopsTemp)) ? 1 : loopsTemp); var restoreOriginalFrame = (animationDict["restoreOriginalFrame"] && animationDict["restoreOriginalFrame"] == true) ? true : false; var frameArray = animationDict["frames"]; diff --git a/cocos2d/core/sprites/CCSGSprite.js b/cocos2d/core/sprites/CCSGSprite.js index f293277a7b..02db734c08 100644 --- a/cocos2d/core/sprites/CCSGSprite.js +++ b/cocos2d/core/sprites/CCSGSprite.js @@ -130,7 +130,7 @@ _ccsg.Sprite = _ccsg.Node.extend({ self._shouldBeHidden = false; self._offsetPosition = cc.p(0, 0); self._unflippedOffsetPositionFromCenter = cc.p(0, 0); - self._blendFunc = {src: cc.Macro.BLEND_SRC, dst: cc.Macro.BLEND_DST}; + self._blendFunc = {src: cc.macro.BLEND_SRC, dst: cc.macro.BLEND_DST}; self._rect = cc.rect(0, 0, 0, 0); self._softInit(fileName, rect, rotated); @@ -627,8 +627,8 @@ _ccsg.Sprite = _ccsg.Node.extend({ _ccsg.Node.prototype.init.call(_t); _t.dirty = _t._recursiveDirty = false; - _t._blendFunc.src = cc.Macro.BLEND_SRC; - _t._blendFunc.dst = cc.Macro.BLEND_DST; + _t._blendFunc.src = cc.macro.BLEND_SRC; + _t._blendFunc.dst = cc.macro.BLEND_DST; _t.texture = null; _t._flippedX = _t._flippedY = false; @@ -704,8 +704,8 @@ _ccsg.Sprite = _ccsg.Node.extend({ _t.dirty = false; _t._opacityModifyRGB = true; - _t._blendFunc.src = cc.Macro.BLEND_SRC; - _t._blendFunc.dst = cc.Macro.BLEND_DST; + _t._blendFunc.src = cc.macro.BLEND_SRC; + _t._blendFunc.dst = cc.macro.BLEND_DST; _t._flippedX = _t._flippedY = false; diff --git a/cocos2d/core/sprites/CCSGSpriteWebGLRenderCmd.js b/cocos2d/core/sprites/CCSGSpriteWebGLRenderCmd.js index 20ec9c3779..921b7d1cdd 100644 --- a/cocos2d/core/sprites/CCSGSpriteWebGLRenderCmd.js +++ b/cocos2d/core/sprites/CCSGSpriteWebGLRenderCmd.js @@ -22,478 +22,478 @@ THE SOFTWARE. ****************************************************************************/ +var macro = cc.macro; + //Sprite's WebGL render command -(function() { - _ccsg.Sprite.WebGLRenderCmd = function (renderable) { - _ccsg.Node.WebGLRenderCmd.call(this, renderable); - this._needDraw = true; +_ccsg.Sprite.WebGLRenderCmd = function (renderable) { + _ccsg.Node.WebGLRenderCmd.call(this, renderable); + this._needDraw = true; - this._quad = new cc.V3F_C4B_T2F_Quad(); - this._quadWebBuffer = cc._renderContext.createBuffer(); - this._quadDirty = true; + this._quad = new cc.V3F_C4B_T2F_Quad(); + this._quadWebBuffer = cc._renderContext.createBuffer(); + this._quadDirty = true; + this._dirty = false; + this._recursiveDirty = false; +}; + +var proto = _ccsg.Sprite.WebGLRenderCmd.prototype = Object.create(_ccsg.Node.WebGLRenderCmd.prototype); +proto.constructor = _ccsg.Sprite.WebGLRenderCmd; + +proto.updateBlendFunc = function (blendFunc) {}; + +proto.setDirtyFlag = function(dirtyFlag){ + _ccsg.Node.WebGLRenderCmd.prototype.setDirtyFlag.call(this, dirtyFlag); + this._dirty = true; +}; + +proto.setDirtyRecursively = function (value) { + this._recursiveDirty = value; + this._dirty = value; + // recursively set dirty + var locChildren = this._node._children, child, l = locChildren ? locChildren.length : 0; + for (var i = 0; i < l; i++) { + child = locChildren[i]; + (child instanceof _ccsg.Sprite) && child._renderCmd.setDirtyRecursively(value); + } +}; + +proto._setBatchNodeForAddChild = function (child) { + var node = this._node; + if (node._batchNode) { + if (!(child instanceof _ccsg.Sprite)) { + cc.log(cc._LogInfos.Sprite.addChild); + return false; + } + if (child.texture._webTextureObj !== node.textureAtlas.texture._webTextureObj) + cc.log(cc._LogInfos.Sprite_addChild_2); + + //put it in descendants array of batch node + node._batchNode.appendChild(child); + if (!node._reorderChildDirty) + node._setReorderChildDirtyRecursively(); + } + return true; +}; + +proto._handleTextureForRotatedTexture = function (texture) { + return texture; +}; + +proto.isFrameDisplayed = function (frame) { + var node = this._node; + return (cc.rectEqualToRect(frame.getRect(), node._rect) && frame.getTexture().getName() === node._texture.getName() + && cc.pointEqualToPoint(frame.getOffset(), node._unflippedOffsetPositionFromCenter)); +}; + +proto._init = function () { + var tempColor = {r: 255, g: 255, b: 255, a: 255}, quad = this._quad; + quad.bl.colors = tempColor; + quad.br.colors = tempColor; + quad.tl.colors = tempColor; + quad.tr.colors = tempColor; + this._quadDirty = true; +}; + +proto._resetForBatchNode = function () { + var node = this._node; + var x1 = node._offsetPosition.x; + var y1 = node._offsetPosition.y; + var x2 = x1 + node._rect.width; + var y2 = y1 + node._rect.height; + var locQuad = this._quad; + locQuad.bl.vertices = {x: x1, y: y1, z: 0}; + locQuad.br.vertices = {x: x2, y: y1, z: 0}; + locQuad.tl.vertices = {x: x1, y: y2, z: 0}; + locQuad.tr.vertices = {x: x2, y: y2, z: 0}; + this._quadDirty = true; +}; + +proto.getQuad = function () { + return this._quad; +}; + +proto._updateForSetSpriteFrame = function () {}; + +proto._spriteFrameLoadedCallback = function (event) { + var spriteFrame = event.currentTarget; + this._node.setTextureRect(spriteFrame.getRect(), spriteFrame.isRotated(), spriteFrame.getOriginalSize()); + this._node.emit("load"); +}; + +proto._textureLoadedCallback = function (event) { + var node = this._node, sender = event.currentTarget; + if (node._textureLoaded) + return; + + node._textureLoaded = true; + var locRect = node._rect; + if (!locRect) { + locRect = cc.rect(0, 0, sender.width, sender.height); + } else if (cc._rectEqualToZero(locRect)) { + locRect.width = sender.width; + locRect.height = sender.height; + } + + node.texture = sender; + node.setTextureRect(locRect, node._rectRotated); + + // by default use "Self Render". + // if the sprite is added to a batchnode, then it will automatically switch to "batchnode Render" + node.setBatchNode(node._batchNode); + this._quadDirty = true; + node.emit("load"); +}; + +proto._setTextureCoords = function (rect) { + var node = this._node; + + var tex = node._batchNode ? node.textureAtlas.texture : node._texture; + if (!tex) + return; + + var atlasWidth = tex.pixelWidth; + var atlasHeight = tex.pixelHeight; + + var left, right, top, bottom, tempSwap, locQuad = this._quad; + if (node._rectRotated) { + if (macro.FIX_ARTIFACTS_BY_STRECHING_TEXEL) { + left = (2 * rect.x + 1) / (2 * atlasWidth); + right = left + (rect.height * 2 - 2) / (2 * atlasWidth); + top = (2 * rect.y + 1) / (2 * atlasHeight); + bottom = top + (rect.width * 2 - 2) / (2 * atlasHeight); + } else { + left = rect.x / atlasWidth; + right = (rect.x + rect.height) / atlasWidth; + top = rect.y / atlasHeight; + bottom = (rect.y + rect.width) / atlasHeight; + } + + if (node._flippedX) { + tempSwap = top; + top = bottom; + bottom = tempSwap; + } + + if (node._flippedY) { + tempSwap = left; + left = right; + right = tempSwap; + } + + locQuad.bl.texCoords.u = left; + locQuad.bl.texCoords.v = top; + locQuad.br.texCoords.u = left; + locQuad.br.texCoords.v = bottom; + locQuad.tl.texCoords.u = right; + locQuad.tl.texCoords.v = top; + locQuad.tr.texCoords.u = right; + locQuad.tr.texCoords.v = bottom; + } else { + if (macro.FIX_ARTIFACTS_BY_STRECHING_TEXEL) { + left = (2 * rect.x + 1) / (2 * atlasWidth); + right = left + (rect.width * 2 - 2) / (2 * atlasWidth); + top = (2 * rect.y + 1) / (2 * atlasHeight); + bottom = top + (rect.height * 2 - 2) / (2 * atlasHeight); + } else { + left = rect.x / atlasWidth; + right = (rect.x + rect.width) / atlasWidth; + top = rect.y / atlasHeight; + bottom = (rect.y + rect.height) / atlasHeight; + } + + if (node._flippedX) { + tempSwap = left; + left = right; + right = tempSwap; + } + + if (node._flippedY) { + tempSwap = top; + top = bottom; + bottom = tempSwap; + } + + locQuad.bl.texCoords.u = left; + locQuad.bl.texCoords.v = bottom; + locQuad.br.texCoords.u = right; + locQuad.br.texCoords.v = bottom; + locQuad.tl.texCoords.u = left; + locQuad.tl.texCoords.v = top; + locQuad.tr.texCoords.u = right; + locQuad.tr.texCoords.v = top; + } + this._quadDirty = true; +}; + +proto.transform = function(parentCmd, recursive){ + _ccsg.Node.WebGLRenderCmd.prototype.transform.call(this, parentCmd, recursive); + this._dirty = true; //use for batching +}; + +proto._setColorDirty = function () {}; + +proto._updateColor = function () { + var node = this._node, + locDisplayedColor = this._displayedColor, + r = locDisplayedColor.r, + g = locDisplayedColor.g, + b = locDisplayedColor.b, + a = locDisplayedColor.a = this._displayedOpacity; + // special opacity for premultiplied textures + if (node._opacityModifyRGB) { + locDisplayedColor.r *= a / 255.0; + locDisplayedColor.g *= a / 255.0; + locDisplayedColor.b *= a / 255.0; + } + var locQuad = this._quad; + locQuad.bl.colors = locDisplayedColor; + locQuad.br.colors = locDisplayedColor; + locQuad.tl.colors = locDisplayedColor; + locQuad.tr.colors = locDisplayedColor; + + // Roll back color + locDisplayedColor.r = r; + locDisplayedColor.g = g; + locDisplayedColor.b = b; + + // renders using Sprite Manager + if (node._batchNode) { + if (node.atlasIndex !== _ccsg.Sprite.INDEX_NOT_INITIALIZED) { + node.textureAtlas.updateQuad(locQuad, node.atlasIndex) + } else { + // no need to set it recursively + // update dirty_, don't update recursiveDirty_ + this._dirty = true; + } + } + // self render + // do nothing + this._quadDirty = true; +}; + +proto._updateBlendFunc = function () { + if (this._batchNode) { + cc.log(cc._LogInfos.Sprite__updateBlendFunc); + return; + } + + // it's possible to have an untextured sprite + var node = this._node; + if (!node._texture || !node._texture.hasPremultipliedAlpha()) { + node._blendFunc.src = macro.SRC_ALPHA; + node._blendFunc.dst = macro.ONE_MINUS_SRC_ALPHA; + node.opacityModifyRGB = false; + } else { + node._blendFunc.src = macro.BLEND_SRC; + node._blendFunc.dst = macro.BLEND_DST; + node.opacityModifyRGB = true; + } +}; + +proto._setTexture = function (texture) { + var node = this._node; + // If batchnode, then texture id should be the same + if (node._batchNode) { + if(node._batchNode.texture !== texture){ + cc.log(cc._LogInfos.Sprite_setTexture); + return; + } + }else{ + if(node._texture !== texture){ + node._textureLoaded = texture ? texture._textureLoaded : false; + node._texture = texture; + this._updateBlendFunc(); + } + } + + if (texture) + this._shaderProgram = cc.shaderCache.programForKey(macro.SHADER_POSITION_TEXTURECOLOR); + else + this._shaderProgram = cc.shaderCache.programForKey(macro.SHADER_POSITION_COLOR); + +}; + +proto.updateTransform = function () { //called only at batching. + var _t = this, node = this._node; + + // recalculate matrix only if it is dirty + if (this._dirty) { + var locQuad = _t._quad, locParent = node._parent; + // If it is not visible, or one of its ancestors is not visible, then do nothing: + if (!node._visible || ( locParent && locParent !== node._batchNode && locParent._shouldBeHidden)) { + locQuad.br.vertices = locQuad.tl.vertices = locQuad.tr.vertices = locQuad.bl.vertices = {x: 0, y: 0, z: 0}; + node._shouldBeHidden = true; + } else { + node._shouldBeHidden = false; + if(this._dirtyFlag !== 0){ //because changing color and opacity uses dirty flag at visit, but visit doesn't call at batching. + this.updateStatus(); + this._dirtyFlag = 0; + } + + if (!locParent || locParent === node._batchNode) { + node._transformToBatch = _t.getNodeToParentTransform(); + } else { + node._transformToBatch = cc.affineTransformConcat(_t.getNodeToParentTransform(), locParent._transformToBatch); + } + + // + // calculate the Quad based on the Affine Matrix + // + var locTransformToBatch = node._transformToBatch; + var rect = node._rect; + var x1 = node._offsetPosition.x; + var y1 = node._offsetPosition.y; + + var x2 = x1 + rect.width; + var y2 = y1 + rect.height; + var x = locTransformToBatch.tx; + var y = locTransformToBatch.ty; + + var cr = locTransformToBatch.a; + var sr = locTransformToBatch.b; + var cr2 = locTransformToBatch.d; + var sr2 = -locTransformToBatch.c; + var ax = x1 * cr - y1 * sr2 + x; + var ay = x1 * sr + y1 * cr2 + y; + + var bx = x2 * cr - y1 * sr2 + x; + var by = x2 * sr + y1 * cr2 + y; + + var cx = x2 * cr - y2 * sr2 + x; + var cy = x2 * sr + y2 * cr2 + y; + + var dx = x1 * cr - y2 * sr2 + x; + var dy = x1 * sr + y2 * cr2 + y; + + var locVertexZ = node._vertexZ; + if (!macro.SPRITEBATCHNODE_RENDER_SUBPIXEL) { + ax = 0 | ax; + ay = 0 | ay; + bx = 0 | bx; + by = 0 | by; + cx = 0 | cx; + cy = 0 | cy; + dx = 0 | dx; + dy = 0 | dy; + } + locQuad.bl.vertices = {x: ax, y: ay, z: locVertexZ}; + locQuad.br.vertices = {x: bx, y: by, z: locVertexZ}; + locQuad.tl.vertices = {x: dx, y: dy, z: locVertexZ}; + locQuad.tr.vertices = {x: cx, y: cy, z: locVertexZ}; + } + node.textureAtlas.updateQuad(locQuad, node.atlasIndex); + node._recursiveDirty = false; this._dirty = false; - this._recursiveDirty = false; - }; + } - var proto = _ccsg.Sprite.WebGLRenderCmd.prototype = Object.create(_ccsg.Node.WebGLRenderCmd.prototype); - proto.constructor = _ccsg.Sprite.WebGLRenderCmd; + // recursively iterate over children + if (node._hasChildren) + node._arrayMakeObjectsPerformSelector(node._children, _ccsg.Node._stateCallbackType.updateTransform); - proto.updateBlendFunc = function (blendFunc) {}; + /*if (macro.SPRITE_DEBUG_DRAW) { //TODO + // draw bounding box + var vertices = [ + cc.p(_t._quad.bl.vertices.x, _t._quad.bl.vertices.y), + cc.p(_t._quad.br.vertices.x, _t._quad.br.vertices.y), + cc.p(_t._quad.tr.vertices.x, _t._quad.tr.vertices.y), + cc.p(_t._quad.tl.vertices.x, _t._quad.tl.vertices.y) + ]; + cc._drawingUtil.drawPoly(vertices, 4, true); + }*/ +}; - proto.setDirtyFlag = function(dirtyFlag){ - _ccsg.Node.WebGLRenderCmd.prototype.setDirtyFlag.call(this, dirtyFlag); - this._dirty = true; - }; - - proto.setDirtyRecursively = function (value) { - this._recursiveDirty = value; - this._dirty = value; - // recursively set dirty - var locChildren = this._node._children, child, l = locChildren ? locChildren.length : 0; - for (var i = 0; i < l; i++) { - child = locChildren[i]; - (child instanceof _ccsg.Sprite) && child._renderCmd.setDirtyRecursively(value); - } - }; - - proto._setBatchNodeForAddChild = function (child) { - var node = this._node; - if (node._batchNode) { - if (!(child instanceof _ccsg.Sprite)) { - cc.log(cc._LogInfos.Sprite.addChild); - return false; - } - if (child.texture._webTextureObj !== node.textureAtlas.texture._webTextureObj) - cc.log(cc._LogInfos.Sprite_addChild_2); - - //put it in descendants array of batch node - node._batchNode.appendChild(child); - if (!node._reorderChildDirty) - node._setReorderChildDirtyRecursively(); - } - return true; - }; - - proto._handleTextureForRotatedTexture = function (texture) { - return texture; - }; - - proto.isFrameDisplayed = function (frame) { - var node = this._node; - return (cc.rectEqualToRect(frame.getRect(), node._rect) && frame.getTexture().getName() === node._texture.getName() - && cc.pointEqualToPoint(frame.getOffset(), node._unflippedOffsetPositionFromCenter)); - }; - - proto._init = function () { - var tempColor = {r: 255, g: 255, b: 255, a: 255}, quad = this._quad; - quad.bl.colors = tempColor; - quad.br.colors = tempColor; - quad.tl.colors = tempColor; - quad.tr.colors = tempColor; - this._quadDirty = true; - }; - - proto._resetForBatchNode = function () { - var node = this._node; - var x1 = node._offsetPosition.x; - var y1 = node._offsetPosition.y; - var x2 = x1 + node._rect.width; - var y2 = y1 + node._rect.height; - var locQuad = this._quad; - locQuad.bl.vertices = {x: x1, y: y1, z: 0}; - locQuad.br.vertices = {x: x2, y: y1, z: 0}; - locQuad.tl.vertices = {x: x1, y: y2, z: 0}; - locQuad.tr.vertices = {x: x2, y: y2, z: 0}; - this._quadDirty = true; - }; - - proto.getQuad = function () { - return this._quad; - }; - - proto._updateForSetSpriteFrame = function () {}; - - proto._spriteFrameLoadedCallback = function (event) { - var spriteFrame = event.currentTarget; - this._node.setTextureRect(spriteFrame.getRect(), spriteFrame.isRotated(), spriteFrame.getOriginalSize()); - this._node.emit("load"); - }; - - proto._textureLoadedCallback = function (event) { - var node = this._node, sender = event.currentTarget; - if (node._textureLoaded) - return; - - node._textureLoaded = true; - var locRect = node._rect; - if (!locRect) { - locRect = cc.rect(0, 0, sender.width, sender.height); - } else if (cc._rectEqualToZero(locRect)) { - locRect.width = sender.width; - locRect.height = sender.height; - } - - node.texture = sender; - node.setTextureRect(locRect, node._rectRotated); - - // by default use "Self Render". - // if the sprite is added to a batchnode, then it will automatically switch to "batchnode Render" - node.setBatchNode(node._batchNode); - this._quadDirty = true; - node.emit("load"); - }; - - proto._setTextureCoords = function (rect) { - var node = this._node; - - var tex = node._batchNode ? node.textureAtlas.texture : node._texture; - if (!tex) - return; - - var atlasWidth = tex.pixelWidth; - var atlasHeight = tex.pixelHeight; - - var left, right, top, bottom, tempSwap, locQuad = this._quad; - if (node._rectRotated) { - if (cc.Macro.FIX_ARTIFACTS_BY_STRECHING_TEXEL) { - left = (2 * rect.x + 1) / (2 * atlasWidth); - right = left + (rect.height * 2 - 2) / (2 * atlasWidth); - top = (2 * rect.y + 1) / (2 * atlasHeight); - bottom = top + (rect.width * 2 - 2) / (2 * atlasHeight); - } else { - left = rect.x / atlasWidth; - right = (rect.x + rect.height) / atlasWidth; - top = rect.y / atlasHeight; - bottom = (rect.y + rect.width) / atlasHeight; - } - - if (node._flippedX) { - tempSwap = top; - top = bottom; - bottom = tempSwap; - } - - if (node._flippedY) { - tempSwap = left; - left = right; - right = tempSwap; - } - - locQuad.bl.texCoords.u = left; - locQuad.bl.texCoords.v = top; - locQuad.br.texCoords.u = left; - locQuad.br.texCoords.v = bottom; - locQuad.tl.texCoords.u = right; - locQuad.tl.texCoords.v = top; - locQuad.tr.texCoords.u = right; - locQuad.tr.texCoords.v = bottom; +proto._checkTextureBoundary = function (texture, rect, rotated) { + if (texture && texture.url) { + var _x, _y; + if (rotated) { + _x = rect.x + rect.height; + _y = rect.y + rect.width; } else { - if (cc.Macro.FIX_ARTIFACTS_BY_STRECHING_TEXEL) { - left = (2 * rect.x + 1) / (2 * atlasWidth); - right = left + (rect.width * 2 - 2) / (2 * atlasWidth); - top = (2 * rect.y + 1) / (2 * atlasHeight); - bottom = top + (rect.height * 2 - 2) / (2 * atlasHeight); - } else { - left = rect.x / atlasWidth; - right = (rect.x + rect.width) / atlasWidth; - top = rect.y / atlasHeight; - bottom = (rect.y + rect.height) / atlasHeight; - } - - if (node._flippedX) { - tempSwap = left; - left = right; - right = tempSwap; - } - - if (node._flippedY) { - tempSwap = top; - top = bottom; - bottom = tempSwap; - } - - locQuad.bl.texCoords.u = left; - locQuad.bl.texCoords.v = bottom; - locQuad.br.texCoords.u = right; - locQuad.br.texCoords.v = bottom; - locQuad.tl.texCoords.u = left; - locQuad.tl.texCoords.v = top; - locQuad.tr.texCoords.u = right; - locQuad.tr.texCoords.v = top; + _x = rect.x + rect.width; + _y = rect.y + rect.height; } - this._quadDirty = true; - }; - - proto.transform = function(parentCmd, recursive){ - _ccsg.Node.WebGLRenderCmd.prototype.transform.call(this, parentCmd, recursive); - this._dirty = true; //use for batching - }; - - proto._setColorDirty = function () {}; - - proto._updateColor = function () { - var node = this._node, - locDisplayedColor = this._displayedColor, - r = locDisplayedColor.r, - g = locDisplayedColor.g, - b = locDisplayedColor.b, - a = locDisplayedColor.a = this._displayedOpacity; - // special opacity for premultiplied textures - if (node._opacityModifyRGB) { - locDisplayedColor.r *= a / 255.0; - locDisplayedColor.g *= a / 255.0; - locDisplayedColor.b *= a / 255.0; + if (_x > texture.width) { + cc.error(cc._LogInfos.RectWidth, texture.url); } - var locQuad = this._quad; - locQuad.bl.colors = locDisplayedColor; - locQuad.br.colors = locDisplayedColor; - locQuad.tl.colors = locDisplayedColor; - locQuad.tr.colors = locDisplayedColor; - - // Roll back color - locDisplayedColor.r = r; - locDisplayedColor.g = g; - locDisplayedColor.b = b; - - // renders using Sprite Manager - if (node._batchNode) { - if (node.atlasIndex !== _ccsg.Sprite.INDEX_NOT_INITIALIZED) { - node.textureAtlas.updateQuad(locQuad, node.atlasIndex) - } else { - // no need to set it recursively - // update dirty_, don't update recursiveDirty_ - this._dirty = true; - } + if (_y > texture.height) { + cc.error(cc._LogInfos.RectHeight, texture.url); } - // self render - // do nothing - this._quadDirty = true; - }; + } +}; - proto._updateBlendFunc = function () { - if (this._batchNode) { - cc.log(cc._LogInfos.Sprite__updateBlendFunc); - return; - } +proto.rendering = function (ctx) { + var node = this._node, locTexture = node._texture; + if ((locTexture &&!locTexture._textureLoaded) || this._displayedOpacity === 0) + return; - // it's possible to have an untextured sprite - var node = this._node; - if (!node._texture || !node._texture.hasPremultipliedAlpha()) { - node._blendFunc.src = cc.Macro.SRC_ALPHA; - node._blendFunc.dst = cc.Macro.ONE_MINUS_SRC_ALPHA; - node.opacityModifyRGB = false; - } else { - node._blendFunc.src = cc.Macro.BLEND_SRC; - node._blendFunc.dst = cc.Macro.BLEND_DST; - node.opacityModifyRGB = true; - } - }; + var gl = ctx || cc._renderContext; + //cc.assert(!_t._batchNode, "If _ccsg.Sprite is being rendered by cc.SpriteBatchNode, _ccsg.Sprite#draw SHOULD NOT be called"); - proto._setTexture = function (texture) { - var node = this._node; - // If batchnode, then texture id should be the same - if (node._batchNode) { - if(node._batchNode.texture !== texture){ - cc.log(cc._LogInfos.Sprite_setTexture); - return; - } - }else{ - if(node._texture !== texture){ - node._textureLoaded = texture ? texture._textureLoaded : false; - node._texture = texture; - this._updateBlendFunc(); - } - } - - if (texture) - this._shaderProgram = cc.shaderCache.programForKey(cc.Macro.SHADER_POSITION_TEXTURECOLOR); - else - this._shaderProgram = cc.shaderCache.programForKey(cc.Macro.SHADER_POSITION_COLOR); - - }; - - proto.updateTransform = function () { //called only at batching. - var _t = this, node = this._node; - - // recalculate matrix only if it is dirty - if (this._dirty) { - var locQuad = _t._quad, locParent = node._parent; - // If it is not visible, or one of its ancestors is not visible, then do nothing: - if (!node._visible || ( locParent && locParent !== node._batchNode && locParent._shouldBeHidden)) { - locQuad.br.vertices = locQuad.tl.vertices = locQuad.tr.vertices = locQuad.bl.vertices = {x: 0, y: 0, z: 0}; - node._shouldBeHidden = true; - } else { - node._shouldBeHidden = false; - if(this._dirtyFlag !== 0){ //because changing color and opacity uses dirty flag at visit, but visit doesn't call at batching. - this.updateStatus(); - this._dirtyFlag = 0; - } - - if (!locParent || locParent === node._batchNode) { - node._transformToBatch = _t.getNodeToParentTransform(); - } else { - node._transformToBatch = cc.affineTransformConcat(_t.getNodeToParentTransform(), locParent._transformToBatch); - } - - // - // calculate the Quad based on the Affine Matrix - // - var locTransformToBatch = node._transformToBatch; - var rect = node._rect; - var x1 = node._offsetPosition.x; - var y1 = node._offsetPosition.y; - - var x2 = x1 + rect.width; - var y2 = y1 + rect.height; - var x = locTransformToBatch.tx; - var y = locTransformToBatch.ty; - - var cr = locTransformToBatch.a; - var sr = locTransformToBatch.b; - var cr2 = locTransformToBatch.d; - var sr2 = -locTransformToBatch.c; - var ax = x1 * cr - y1 * sr2 + x; - var ay = x1 * sr + y1 * cr2 + y; - - var bx = x2 * cr - y1 * sr2 + x; - var by = x2 * sr + y1 * cr2 + y; - - var cx = x2 * cr - y2 * sr2 + x; - var cy = x2 * sr + y2 * cr2 + y; - - var dx = x1 * cr - y2 * sr2 + x; - var dy = x1 * sr + y2 * cr2 + y; - - var locVertexZ = node._vertexZ; - if (!cc.Macro.SPRITEBATCHNODE_RENDER_SUBPIXEL) { - ax = 0 | ax; - ay = 0 | ay; - bx = 0 | bx; - by = 0 | by; - cx = 0 | cx; - cy = 0 | cy; - dx = 0 | dx; - dy = 0 | dy; - } - locQuad.bl.vertices = {x: ax, y: ay, z: locVertexZ}; - locQuad.br.vertices = {x: bx, y: by, z: locVertexZ}; - locQuad.tl.vertices = {x: dx, y: dy, z: locVertexZ}; - locQuad.tr.vertices = {x: cx, y: cy, z: locVertexZ}; - } - node.textureAtlas.updateQuad(locQuad, node.atlasIndex); - node._recursiveDirty = false; - this._dirty = false; - } - - // recursively iterate over children - if (node._hasChildren) - node._arrayMakeObjectsPerformSelector(node._children, _ccsg.Node._stateCallbackType.updateTransform); - - /*if (cc.Macro.SPRITE_DEBUG_DRAW) { //TODO - // draw bounding box - var vertices = [ - cc.p(_t._quad.bl.vertices.x, _t._quad.bl.vertices.y), - cc.p(_t._quad.br.vertices.x, _t._quad.br.vertices.y), - cc.p(_t._quad.tr.vertices.x, _t._quad.tr.vertices.y), - cc.p(_t._quad.tl.vertices.x, _t._quad.tl.vertices.y) - ]; - cc._drawingUtil.drawPoly(vertices, 4, true); - }*/ - }; - - proto._checkTextureBoundary = function (texture, rect, rotated) { - if (texture && texture.url) { - var _x, _y; - if (rotated) { - _x = rect.x + rect.height; - _y = rect.y + rect.width; - } else { - _x = rect.x + rect.width; - _y = rect.y + rect.height; - } - if (_x > texture.width) { - cc.error(cc._LogInfos.RectWidth, texture.url); - } - if (_y > texture.height) { - cc.error(cc._LogInfos.RectHeight, texture.url); - } - } - }; - - proto.rendering = function (ctx) { - var node = this._node, locTexture = node._texture; - if ((locTexture &&!locTexture._textureLoaded) || this._displayedOpacity === 0) - return; - - var gl = ctx || cc._renderContext; - //cc.assert(!_t._batchNode, "If _ccsg.Sprite is being rendered by cc.SpriteBatchNode, _ccsg.Sprite#draw SHOULD NOT be called"); - - if (locTexture) { - if (locTexture._textureLoaded) { - this._shaderProgram.use(); - this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix); - - cc.glBlendFunc(node._blendFunc.src, node._blendFunc.dst); - //optimize performance for javascript - cc.glBindTexture2DN(0, locTexture); // = cc.glBindTexture2D(locTexture); - cc.glEnableVertexAttribs(cc.Macro.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); - - gl.bindBuffer(gl.ARRAY_BUFFER, this._quadWebBuffer); - if (this._quadDirty) { - gl.bufferData(gl.ARRAY_BUFFER, this._quad.arrayBuffer, gl.DYNAMIC_DRAW); - this._quadDirty = false; - } - gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 24, 0); //cc.Macro.VERTEX_ATTRIB_POSITION - gl.vertexAttribPointer(1, 4, gl.UNSIGNED_BYTE, true, 24, 12); //cc.Macro.VERTEX_ATTRIB_COLOR - gl.vertexAttribPointer(2, 2, gl.FLOAT, false, 24, 16); //cc.Macro.VERTEX_ATTRIB_TEX_COORDS - gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); - } - } else { + if (locTexture) { + if (locTexture._textureLoaded) { this._shaderProgram.use(); this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix); cc.glBlendFunc(node._blendFunc.src, node._blendFunc.dst); - cc.glBindTexture2D(null); - - cc.glEnableVertexAttribs(cc.Macro.VERTEX_ATTRIB_FLAG_POSITION | cc.Macro.VERTEX_ATTRIB_FLAG_COLOR); + //optimize performance for javascript + cc.glBindTexture2DN(0, locTexture); // = cc.glBindTexture2D(locTexture); + cc.glEnableVertexAttribs(macro.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); gl.bindBuffer(gl.ARRAY_BUFFER, this._quadWebBuffer); if (this._quadDirty) { - gl.bufferData(gl.ARRAY_BUFFER, this._quad.arrayBuffer, gl.STATIC_DRAW); + gl.bufferData(gl.ARRAY_BUFFER, this._quad.arrayBuffer, gl.DYNAMIC_DRAW); this._quadDirty = false; } - gl.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_POSITION, 3, gl.FLOAT, false, 24, 0); - gl.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_COLOR, 4, gl.UNSIGNED_BYTE, true, 24, 12); + gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 24, 0); //macro.VERTEX_ATTRIB_POSITION + gl.vertexAttribPointer(1, 4, gl.UNSIGNED_BYTE, true, 24, 12); //macro.VERTEX_ATTRIB_COLOR + gl.vertexAttribPointer(2, 2, gl.FLOAT, false, 24, 16); //macro.VERTEX_ATTRIB_TEX_COORDS gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); } - cc.g_NumberOfDraws++; + } else { + this._shaderProgram.use(); + this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix); - if (cc.Macro.SPRITE_DEBUG_DRAW === 0 && !node._showNode) - return; + cc.glBlendFunc(node._blendFunc.src, node._blendFunc.dst); + cc.glBindTexture2D(null); - cc.math.glMatrixMode(cc.math.KM_GL_MODELVIEW); - //cc.math.glPushMatrixWitMat4(node._stackMatrix); - cc.current_stack.stack.push(cc.current_stack.top); - cc.current_stack.top = this._stackMatrix; + cc.glEnableVertexAttribs(macro.VERTEX_ATTRIB_FLAG_POSITION | macro.VERTEX_ATTRIB_FLAG_COLOR); - if (cc.Macro.SPRITE_DEBUG_DRAW === 1 || node._showNode) { - // draw bounding box - var locQuad = this._quad; - var verticesG1 = [ - cc.p(locQuad.tl.vertices.x, locQuad.tl.vertices.y), - cc.p(locQuad.bl.vertices.x, locQuad.bl.vertices.y), - cc.p(locQuad.br.vertices.x, locQuad.br.vertices.y), - cc.p(locQuad.tr.vertices.x, locQuad.tr.vertices.y) - ]; - cc._drawingUtil.drawPoly(verticesG1, 4, true); - } else if (cc.Macro.SPRITE_DEBUG_DRAW === 2) { - // draw texture box - var drawRectG2 = node.getTextureRect(); - var offsetPixG2 = node.getOffsetPosition(); - var verticesG2 = [cc.p(offsetPixG2.x, offsetPixG2.y), cc.p(offsetPixG2.x + drawRectG2.width, offsetPixG2.y), - cc.p(offsetPixG2.x + drawRectG2.width, offsetPixG2.y + drawRectG2.height), cc.p(offsetPixG2.x, offsetPixG2.y + drawRectG2.height)]; - cc._drawingUtil.drawPoly(verticesG2, 4, true); - } // CC_SPRITE_DEBUG_DRAW - cc.current_stack.top = cc.current_stack.stack.pop(); - }; -})(); \ No newline at end of file + gl.bindBuffer(gl.ARRAY_BUFFER, this._quadWebBuffer); + if (this._quadDirty) { + gl.bufferData(gl.ARRAY_BUFFER, this._quad.arrayBuffer, gl.STATIC_DRAW); + this._quadDirty = false; + } + gl.vertexAttribPointer(macro.VERTEX_ATTRIB_POSITION, 3, gl.FLOAT, false, 24, 0); + gl.vertexAttribPointer(macro.VERTEX_ATTRIB_COLOR, 4, gl.UNSIGNED_BYTE, true, 24, 12); + gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); + } + cc.g_NumberOfDraws++; + + if (macro.SPRITE_DEBUG_DRAW === 0 && !node._showNode) + return; + + cc.math.glMatrixMode(cc.math.KM_GL_MODELVIEW); + //cc.math.glPushMatrixWitMat4(node._stackMatrix); + cc.current_stack.stack.push(cc.current_stack.top); + cc.current_stack.top = this._stackMatrix; + + if (macro.SPRITE_DEBUG_DRAW === 1 || node._showNode) { + // draw bounding box + var locQuad = this._quad; + var verticesG1 = [ + cc.p(locQuad.tl.vertices.x, locQuad.tl.vertices.y), + cc.p(locQuad.bl.vertices.x, locQuad.bl.vertices.y), + cc.p(locQuad.br.vertices.x, locQuad.br.vertices.y), + cc.p(locQuad.tr.vertices.x, locQuad.tr.vertices.y) + ]; + cc._drawingUtil.drawPoly(verticesG1, 4, true); + } else if (macro.SPRITE_DEBUG_DRAW === 2) { + // draw texture box + var drawRectG2 = node.getTextureRect(); + var offsetPixG2 = node.getOffsetPosition(); + var verticesG2 = [cc.p(offsetPixG2.x, offsetPixG2.y), cc.p(offsetPixG2.x + drawRectG2.width, offsetPixG2.y), + cc.p(offsetPixG2.x + drawRectG2.width, offsetPixG2.y + drawRectG2.height), cc.p(offsetPixG2.x, offsetPixG2.y + drawRectG2.height)]; + cc._drawingUtil.drawPoly(verticesG2, 4, true); + } // CC_SPRITE_DEBUG_DRAW + cc.current_stack.top = cc.current_stack.stack.pop(); +}; \ No newline at end of file diff --git a/cocos2d/core/sprites/CCScale9Sprite.js b/cocos2d/core/sprites/CCScale9Sprite.js index 41126849dd..20115ce9e1 100644 --- a/cocos2d/core/sprites/CCScale9Sprite.js +++ b/cocos2d/core/sprites/CCScale9Sprite.js @@ -996,12 +996,12 @@ cc.Scale9Sprite = _ccsg.Node.extend({ */ setBlendFunc: function (blendFunc, dst) { if (dst === undefined) { - this._blendFunc.src = blendFunc.src || cc.Macro.BLEND_SRC; - this._blendFunc.dst = blendFunc.dst || cc.Macro.BLEND_DST; + this._blendFunc.src = blendFunc.src || cc.macro.BLEND_SRC; + this._blendFunc.dst = blendFunc.dst || cc.macro.BLEND_DST; } else { - this._blendFunc.src = blendFunc || cc.Macro.BLEND_SRC; - this._blendFunc.dst = dst || cc.Macro.BLEND_DST; + this._blendFunc.src = blendFunc || cc.macro.BLEND_SRC; + this._blendFunc.dst = dst || cc.macro.BLEND_DST; } }, diff --git a/cocos2d/core/sprites/CCScale9SpriteWebGLRenderCmd.js b/cocos2d/core/sprites/CCScale9SpriteWebGLRenderCmd.js index aa6cef9e48..bf17791f3e 100644 --- a/cocos2d/core/sprites/CCScale9SpriteWebGLRenderCmd.js +++ b/cocos2d/core/sprites/CCScale9SpriteWebGLRenderCmd.js @@ -65,7 +65,7 @@ cc.glBlendFunc(node._blendFunc.src, node._blendFunc.dst); //optimize performance for javascript cc.glBindTexture2DN(0, locTexture); // = cc.glBindTexture2D(locTexture); - cc.glEnableVertexAttribs(cc.Macro.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); + cc.glEnableVertexAttribs(cc.macro.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); gl.bindBuffer(gl.ARRAY_BUFFER, this._quadWebBuffer); @@ -84,9 +84,9 @@ bufferOffset = 0; for(var i = 0; i < quads.length; ++i) { - gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 24, bufferOffset); //cc.Macro.VERTEX_ATTRIB_POSITION - gl.vertexAttribPointer(1, 4, gl.UNSIGNED_BYTE, true, 24, 12 + bufferOffset); //cc.Macro.VERTEX_ATTRIB_COLOR - gl.vertexAttribPointer(2, 2, gl.FLOAT, false, 24, 16 + bufferOffset); //cc.Macro.VERTEX_ATTRIB_TEX_COORDS + gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 24, bufferOffset); //cc.macro.VERTEX_ATTRIB_POSITION + gl.vertexAttribPointer(1, 4, gl.UNSIGNED_BYTE, true, 24, 12 + bufferOffset); //cc.macro.VERTEX_ATTRIB_COLOR + gl.vertexAttribPointer(2, 2, gl.FLOAT, false, 24, 16 + bufferOffset); //cc.macro.VERTEX_ATTRIB_TEX_COORDS if(node._isTriangle) { gl.drawArrays(gl.TRIANGLES, 0, 3); } else { @@ -116,7 +116,7 @@ proto.setState = function (state) { var node = this._node; if (state === cc.Scale9Sprite.state.NORMAL) { - node.setShaderProgram(cc.shaderCache.programForKey(cc.Macro.SHADER_POSITION_TEXTURECOLOR)); + node.setShaderProgram(cc.shaderCache.programForKey(cc.macro.SHADER_POSITION_TEXTURECOLOR)); } else if (state === cc.Scale9Sprite.state.GRAY) { node.setShaderProgram(cc.Scale9Sprite.WebGLRenderCmd._getGrayShaderProgram()); } @@ -130,9 +130,9 @@ grayShader = new cc.GLProgram(); grayShader.initWithVertexShaderByteArray(cc.PresetShaders.POSITION_TEXTURE_COLOR_VERT, cc.Scale9Sprite.WebGLRenderCmd._grayShaderFragment); - grayShader.addAttribute(cc.Macro.ATTRIBUTE_NAME_POSITION, cc.Macro.VERTEX_ATTRIB_POSITION); - grayShader.addAttribute(cc.Macro.ATTRIBUTE_NAME_COLOR, cc.Macro.VERTEX_ATTRIB_COLOR); - grayShader.addAttribute(cc.Macro.ATTRIBUTE_NAME_TEX_COORD, cc.Macro.VERTEX_ATTRIB_TEX_COORDS); + grayShader.addAttribute(cc.macro.ATTRIBUTE_NAME_POSITION, cc.macro.VERTEX_ATTRIB_POSITION); + grayShader.addAttribute(cc.macro.ATTRIBUTE_NAME_COLOR, cc.macro.VERTEX_ATTRIB_COLOR); + grayShader.addAttribute(cc.macro.ATTRIBUTE_NAME_TEX_COORD, cc.macro.VERTEX_ATTRIB_TEX_COORDS); grayShader.link(); grayShader.updateUniforms(); diff --git a/cocos2d/core/sprites/CCSpriteBatchNode.js b/cocos2d/core/sprites/CCSpriteBatchNode.js index 36c196c758..1201979368 100644 --- a/cocos2d/core/sprites/CCSpriteBatchNode.js +++ b/cocos2d/core/sprites/CCSpriteBatchNode.js @@ -64,7 +64,7 @@ cc.SpriteBatchNode = _ccsg.Node.extend(/** @lends cc.SpriteBatchNode# */{ ctor: function (fileImage, capacity) { _ccsg.Node.prototype.ctor.call(this); this._descendants = []; - this._blendFunc = new cc.BlendFunc(cc.Macro.BLEND_SRC, cc.Macro.BLEND_DST); + this._blendFunc = new cc.BlendFunc(cc.macro.BLEND_SRC, cc.macro.BLEND_DST); var texture2D; capacity = capacity || cc.SpriteBatchNode.DEFAULT_CAPACITY; @@ -272,7 +272,7 @@ cc.SpriteBatchNode = _ccsg.Node.extend(/** @lends cc.SpriteBatchNode# */{ // ignore parent Z if parent is spriteSheet var ignoreParent = selParent === this; var previous = null; - if (childIndex > 0 && childIndex < cc.Macro.UINT_MAX) + if (childIndex > 0 && childIndex < cc.macro.UINT_MAX) previous = brothers[childIndex - 1]; // first child of the sprite sheet diff --git a/cocos2d/core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js b/cocos2d/core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js index 87732bffe0..1c3d06397a 100644 --- a/cocos2d/core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js @@ -114,7 +114,7 @@ this._textureAtlas = new cc.TextureAtlas(); this._textureAtlas.initWithTexture(texture, capacity); this._updateBlendFunc(); - this._shaderProgram = cc.shaderCache.programForKey(cc.Macro.SHADER_POSITION_TEXTURECOLOR); + this._shaderProgram = cc.shaderCache.programForKey(cc.macro.SHADER_POSITION_TEXTURECOLOR); }; proto.insertQuad = function(sprite, index){ @@ -224,8 +224,8 @@ proto._updateBlendFunc = function () { if (!this._textureAtlas.texture.hasPremultipliedAlpha()) { var blendFunc = this._node._blendFunc; - blendFunc.src = cc.Macro.SRC_ALPHA; - blendFunc.dst = cc.Macro.ONE_MINUS_SRC_ALPHA; + blendFunc.src = cc.macro.SRC_ALPHA; + blendFunc.dst = cc.macro.ONE_MINUS_SRC_ALPHA; } }; diff --git a/cocos2d/core/textures/CCTextureAtlas.js b/cocos2d/core/textures/CCTextureAtlas.js index ddc01ea42b..cbc065eb57 100644 --- a/cocos2d/core/textures/CCTextureAtlas.js +++ b/cocos2d/core/textures/CCTextureAtlas.js @@ -179,7 +179,7 @@ var TextureAtlas = Class.extend(/** @lends cc.TextureAtlas# */{ //WebGL only return; var locIndices = this._indices, locCapacity = this._capacity; for (var i = 0; i < locCapacity; i++) { - if (cc.Macro.TEXTURE_ATLAS_USE_TRIANGLE_STRIP) { + if (cc.macro.TEXTURE_ATLAS_USE_TRIANGLE_STRIP) { locIndices[i * 6 + 0] = i * 4 + 0; locIndices[i * 6 + 1] = i * 4 + 0; locIndices[i * 6 + 2] = i * 4 + 2; @@ -669,7 +669,7 @@ if (cc._renderType === game.RENDER_TYPE_WEBGL) { //vertices //gl.bindBuffer(gl.ARRAY_BUFFER, _t._buffersVBO[0]); // XXX: update is done in draw... perhaps it should be done in a timer - cc.glEnableVertexAttribs(cc.Macro.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); + cc.glEnableVertexAttribs(cc.macro.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); gl.bindBuffer(gl.ARRAY_BUFFER, _t._quadsWebBuffer); if (_t.dirty){ @@ -677,13 +677,13 @@ if (cc._renderType === game.RENDER_TYPE_WEBGL) { _t.dirty = false; } - gl.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_POSITION, 3, gl.FLOAT, false, 24, 0); // vertices - gl.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_COLOR, 4, gl.UNSIGNED_BYTE, true, 24, 12); // colors - gl.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_TEX_COORDS, 2, gl.FLOAT, false, 24, 16); // tex coords + gl.vertexAttribPointer(cc.macro.VERTEX_ATTRIB_POSITION, 3, gl.FLOAT, false, 24, 0); // vertices + gl.vertexAttribPointer(cc.macro.VERTEX_ATTRIB_COLOR, 4, gl.UNSIGNED_BYTE, true, 24, 12); // colors + gl.vertexAttribPointer(cc.macro.VERTEX_ATTRIB_TEX_COORDS, 2, gl.FLOAT, false, 24, 16); // tex coords gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, _t._buffersVBO[1]); - if (cc.Macro.TEXTURE_ATLAS_USE_TRIANGLE_STRIP) + if (cc.macro.TEXTURE_ATLAS_USE_TRIANGLE_STRIP) gl.drawElements(gl.TRIANGLE_STRIP, n * 6, gl.UNSIGNED_SHORT, start * 6 * _t._indices.BYTES_PER_ELEMENT); else gl.drawElements(gl.TRIANGLES, n * 6, gl.UNSIGNED_SHORT, start * 6 * _t._indices.BYTES_PER_ELEMENT); diff --git a/cocos2d/core/textures/CCTextureCache.js b/cocos2d/core/textures/CCTextureCache.js index 0573eb8264..657c66a408 100644 --- a/cocos2d/core/textures/CCTextureCache.js +++ b/cocos2d/core/textures/CCTextureCache.js @@ -349,7 +349,7 @@ game.once(game.EVENT_RENDERER_INITED, function () { tex = locTexs[url] = new Texture2D(); tex.url = url; } - premultiplied = cc.Macro.AUTO_PREMULTIPLIED_ALPHA_FOR_PNG && (cc.path.extname(url) === ".png"); + premultiplied = cc.macro.AUTO_PREMULTIPLIED_ALPHA_FOR_PNG && (cc.path.extname(url) === ".png"); tex.handleLoadedTexture(premultiplied); }; diff --git a/cocos2d/core/utils/CCProfiler.js b/cocos2d/core/utils/CCProfiler.js index 9ecb57fbc5..7b7d9624cc 100644 --- a/cocos2d/core/utils/CCProfiler.js +++ b/cocos2d/core/utils/CCProfiler.js @@ -45,7 +45,7 @@ cc.profiler = (function () { var createStatsLabel = function () { var fontSize = 0; var w = cc.winSize.width, h = cc.winSize.height; - var locStatsPosition = cc.Macro.DIRECTOR_STATS_POSITION; + var locStatsPosition = cc.macro.DIRECTOR_STATS_POSITION; if (w > h) fontSize = 0 | (h / 320 * 20); else @@ -110,7 +110,7 @@ cc.profiler = (function () { _frames++; _accumDt += cc.director.getDeltaTime(); - if (_accumDt > cc.Macro.DIRECTOR_FPS_INTERVAL) { + if (_accumDt > cc.macro.DIRECTOR_FPS_INTERVAL) { _frameRate = _frames / _accumDt; _frames = 0; _accumDt = 0; @@ -151,7 +151,7 @@ cc.profiler = (function () { setProfileDuration: function (duration) { if (!isNaN(duration) && duration > 0) { - _levelDetCycle = duration / cc.Macro.DIRECTOR_FPS_INTERVAL; + _levelDetCycle = duration / cc.macro.DIRECTOR_FPS_INTERVAL; } }, diff --git a/cocos2d/core/utils/base-node.js b/cocos2d/core/utils/base-node.js index 8d0cd16b44..84bd52f0b5 100644 --- a/cocos2d/core/utils/base-node.js +++ b/cocos2d/core/utils/base-node.js @@ -90,7 +90,7 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{ _skewY: 0, _localZOrder: 0, _globalZOrder: 0, - _tag: cc.Macro.NODE_TAG_INVALID, + _tag: cc.macro.NODE_TAG_INVALID, _opacityModifyRGB: false, // API @@ -1085,7 +1085,7 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{ * @see cc.Node#removeChildByTag */ removeChildByTag: function (tag, cleanup) { - if (tag === cc.Macro.NODE_TAG_INVALID) + if (tag === cc.macro.NODE_TAG_INVALID) cc.log(cc._LogInfos.Node.removeChildByTag); var child = this.getChildByTag(tag); diff --git a/cocos2d/core/value-types/CCTypes.js b/cocos2d/core/value-types/CCTypes.js index f0445309c3..86fae67c79 100644 --- a/cocos2d/core/value-types/CCTypes.js +++ b/cocos2d/core/value-types/CCTypes.js @@ -61,16 +61,16 @@ cc.BlendFunc = function (src1, dst1) { }; var BlendFactor = cc.Enum({ - ONE: 1, //cc.Macro.ONE - ZERO: 0, //cc.Macro.ZERO - SRC_ALPHA: 0x302, //cc.Macro.SRC_ALPHA - SRC_COLOR: 0x300, //cc.Macro.SRC_COLOR - DST_ALPHA: 0x304, //cc.Macro.DST_ALPHA - DST_COLOR: 0x306, //cc.Macro.DST_COLOR - ONE_MINUS_SRC_ALPHA: 0x303, //cc.Macro.ONE_MINUS_SRC_ALPHA - ONE_MINUS_SRC_COLOR: 0x301, //cc.Macro.ONE_MINUS_SRC_COLOR - ONE_MINUS_DST_ALPHA: 0x305, //cc.Macro.ONE_MINUS_DST_ALPHA - ONE_MINUS_DST_COLOR: 0x307, //cc.Macro.ONE_MINUS_DST_COLOR + ONE: 1, //cc.macro.ONE + ZERO: 0, //cc.macro.ZERO + SRC_ALPHA: 0x302, //cc.macro.SRC_ALPHA + SRC_COLOR: 0x300, //cc.macro.SRC_COLOR + DST_ALPHA: 0x304, //cc.macro.DST_ALPHA + DST_COLOR: 0x306, //cc.macro.DST_COLOR + ONE_MINUS_SRC_ALPHA: 0x303, //cc.macro.ONE_MINUS_SRC_ALPHA + ONE_MINUS_SRC_COLOR: 0x301, //cc.macro.ONE_MINUS_SRC_COLOR + ONE_MINUS_DST_ALPHA: 0x305, //cc.macro.ONE_MINUS_DST_ALPHA + ONE_MINUS_DST_COLOR: 0x307, //cc.macro.ONE_MINUS_DST_COLOR }); //var BlendFactor = cc; diff --git a/cocos2d/effects/CCGrid.js b/cocos2d/effects/CCGrid.js index 7b5862a077..64b1141c31 100644 --- a/cocos2d/effects/CCGrid.js +++ b/cocos2d/effects/CCGrid.js @@ -228,7 +228,7 @@ cc.GridBase = cc._Class.extend(/** @lends cc.GridBase# */{ if (!this._grabber) return false; this._grabber.grab(this._texture); - this._shaderProgram = cc.shaderCache.programForKey(cc.Macro.SHADER_POSITION_TEXTURE); + this._shaderProgram = cc.shaderCache.programForKey(cc.macro.SHADER_POSITION_TEXTURE); this.calculateVertexPoints(); return true; }, @@ -436,7 +436,7 @@ cc.Grid3D = cc.GridBase.extend(/** @lends cc.Grid3D# */{ blit:function (target) { var n = this._gridSize.width * this._gridSize.height; - cc.glEnableVertexAttribs(cc.Macro.VERTEX_ATTRIB_FLAG_POSITION | cc.Macro.VERTEX_ATTRIB_FLAG_TEX_COORDS); + cc.glEnableVertexAttribs(cc.macro.VERTEX_ATTRIB_FLAG_POSITION | cc.macro.VERTEX_ATTRIB_FLAG_TEX_COORDS); this._shaderProgram.use(); //this._shaderProgram.setUniformsForBuiltins(); this._shaderProgram._setUniformForMVPMatrixWithMat4(target._renderCmd._stackMatrix); @@ -449,13 +449,13 @@ cc.Grid3D = cc.GridBase.extend(/** @lends cc.Grid3D# */{ gl.bindBuffer(gl.ARRAY_BUFFER, this._verticesBuffer); if (locDirty) gl.bufferData(gl.ARRAY_BUFFER, this._vertices, gl.DYNAMIC_DRAW); - gl.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_POSITION, 3, gl.FLOAT, false, 0, 0); + gl.vertexAttribPointer(cc.macro.VERTEX_ATTRIB_POSITION, 3, gl.FLOAT, false, 0, 0); // texCoords gl.bindBuffer(gl.ARRAY_BUFFER, this._texCoordinateBuffer); if (locDirty) gl.bufferData(gl.ARRAY_BUFFER, this._texCoordinates, gl.DYNAMIC_DRAW); - gl.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_TEX_COORDS, 2, gl.FLOAT, false, 0, 0); + gl.vertexAttribPointer(cc.macro.VERTEX_ATTRIB_TEX_COORDS, 2, gl.FLOAT, false, 0, 0); gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._indicesBuffer); if (locDirty) @@ -690,19 +690,19 @@ cc.TiledGrid3D = cc.GridBase.extend(/** @lends cc.TiledGrid3D# */{ // Attributes // var gl = cc._renderContext, locDirty = this._dirty; - cc.glEnableVertexAttribs(cc.Macro.VERTEX_ATTRIB_FLAG_POSITION | cc.Macro.VERTEX_ATTRIB_FLAG_TEX_COORDS); + cc.glEnableVertexAttribs(cc.macro.VERTEX_ATTRIB_FLAG_POSITION | cc.macro.VERTEX_ATTRIB_FLAG_TEX_COORDS); // position gl.bindBuffer(gl.ARRAY_BUFFER, this._verticesBuffer); if (locDirty) gl.bufferData(gl.ARRAY_BUFFER, this._vertices, gl.DYNAMIC_DRAW); - gl.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_POSITION, 3, gl.FLOAT, false, 0, this._vertices); + gl.vertexAttribPointer(cc.macro.VERTEX_ATTRIB_POSITION, 3, gl.FLOAT, false, 0, this._vertices); // texCoords gl.bindBuffer(gl.ARRAY_BUFFER, this._texCoordinateBuffer); if (locDirty) gl.bufferData(gl.ARRAY_BUFFER, this._texCoordinates, gl.DYNAMIC_DRAW); - gl.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_TEX_COORDS, 2, gl.FLOAT, false, 0, this._texCoordinates); + gl.vertexAttribPointer(cc.macro.VERTEX_ATTRIB_TEX_COORDS, 2, gl.FLOAT, false, 0, this._texCoordinates); gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._indicesBuffer); if (locDirty) diff --git a/cocos2d/kazmath/utility.js b/cocos2d/kazmath/utility.js index 2ffe652038..f3f8ab188f 100644 --- a/cocos2d/kazmath/utility.js +++ b/cocos2d/kazmath/utility.js @@ -35,9 +35,9 @@ */ cc.math = cc.math || {}; -//cc.kmPIOver180 = 0.017453; please use cc.Macro.RAD +//cc.kmPIOver180 = 0.017453; please use cc.macro.RAD -//cc.kmPIUnder180 = 57.295779; please use cc.Macro.DEG +//cc.kmPIUnder180 = 57.295779; please use cc.macro.DEG cc.math.EPSILON = 1.0 / 64.0; //cc.kmEpsilon diff --git a/cocos2d/labels/CCLabelAtlasWebGLRenderCmd.js b/cocos2d/labels/CCLabelAtlasWebGLRenderCmd.js index 3e0b3bccc7..d6bf60bf63 100644 --- a/cocos2d/labels/CCLabelAtlasWebGLRenderCmd.js +++ b/cocos2d/labels/CCLabelAtlasWebGLRenderCmd.js @@ -39,7 +39,7 @@ proto.rendering = function(ctx){ cc.AtlasNode.WebGLRenderCmd.prototype.rendering.call(this, ctx); - if (cc.Macro.LABELATLAS_DEBUG_DRAW) { + if (cc.macro.LABELATLAS_DEBUG_DRAW) { var node = this._node; var s = node.getContentSize(); var locRect = node.getBoundingBoxToWorld(); @@ -82,7 +82,7 @@ cr++; var left, right, top, bottom; - if (cc.Macro.FIX_ARTIFACTS_BY_STRECHING_TEXEL) { + if (cc.macro.FIX_ARTIFACTS_BY_STRECHING_TEXEL) { // Issue #938. Don't use texStepX & texStepY left = (2 * row * itemWidth + 1) / (2 * textureWide); right = left + (itemWidth * 2 - 2) / (2 * textureWide); diff --git a/cocos2d/labels/CCLabelBMFontWebGLRenderCmd.js b/cocos2d/labels/CCLabelBMFontWebGLRenderCmd.js index 37031c5b6a..9c5f202817 100644 --- a/cocos2d/labels/CCLabelBMFontWebGLRenderCmd.js +++ b/cocos2d/labels/CCLabelBMFontWebGLRenderCmd.js @@ -71,7 +71,7 @@ var node = this._node; //LabelBMFont - Debug draw - if (cc.Macro.LABELBMFONT_DEBUG_DRAW) { + if (cc.macro.LABELBMFONT_DEBUG_DRAW) { var size = node.getContentSize(); var pos = cc.p(0 | ( -this._anchorPointInPoints.x), 0 | ( -this._anchorPointInPoints.y)); var vertices = [cc.p(pos.x, pos.y), cc.p(pos.x + size.width, pos.y), cc.p(pos.x + size.width, pos.y + size.height), cc.p(pos.x, pos.y + size.height)]; diff --git a/cocos2d/menus/CCMenuItem.js b/cocos2d/menus/CCMenuItem.js index 7a6ee83580..0774672245 100644 --- a/cocos2d/menus/CCMenuItem.js +++ b/cocos2d/menus/CCMenuItem.js @@ -24,7 +24,7 @@ THE SOFTWARE. ****************************************************************************/ -cc._globalFontSize = cc.Macro.ITEM_SIZE; +cc._globalFontSize = cc.macro.ITEM_SIZE; cc._globalFontName = "Arial"; cc._globalFontNameRelease = false; @@ -362,14 +362,14 @@ cc.MenuItemLabel = cc.MenuItem.extend(/** @lends cc.MenuItemLabel# */{ if (this._enabled) { cc.MenuItem.prototype.selected.call(this); - var action = this.getActionByTag(cc.Macro.ZOOM_ACTION_TAG); + var action = this.getActionByTag(cc.macro.ZOOM_ACTION_TAG); if (action) this.stopAction(action); else this._originalScale = this.scale; var zoomAction = cc.scaleTo(0.1, this._originalScale * 1.2); - zoomAction.setTag(cc.Macro.ZOOM_ACTION_TAG); + zoomAction.setTag(cc.macro.ZOOM_ACTION_TAG); this.runAction(zoomAction); } }, @@ -380,9 +380,9 @@ cc.MenuItemLabel = cc.MenuItem.extend(/** @lends cc.MenuItemLabel# */{ unselected: function () { if (this._enabled) { cc.MenuItem.prototype.unselected.call(this); - this.stopActionByTag(cc.Macro.ZOOM_ACTION_TAG); + this.stopActionByTag(cc.macro.ZOOM_ACTION_TAG); var zoomAction = cc.scaleTo(0.1, this._originalScale); - zoomAction.setTag(cc.Macro.ZOOM_ACTION_TAG); + zoomAction.setTag(cc.macro.ZOOM_ACTION_TAG); this.runAction(zoomAction); } } @@ -732,7 +732,7 @@ cc.MenuItemSprite = cc.MenuItem.extend(/** @lends cc.MenuItemSprite# */{ return; } if (normalImage) { - this.addChild(normalImage, 0, cc.Macro.NORMAL_TAG); + this.addChild(normalImage, 0, cc.macro.NORMAL_TAG); normalImage.anchorX = 0; normalImage.anchorY = 0; } @@ -773,7 +773,7 @@ cc.MenuItemSprite = cc.MenuItem.extend(/** @lends cc.MenuItemSprite# */{ return; if (selectedImage) { - this.addChild(selectedImage, 0, cc.Macro.SELECTED_TAG); + this.addChild(selectedImage, 0, cc.macro.SELECTED_TAG); selectedImage.anchorX = 0; selectedImage.anchorY = 0; } @@ -803,7 +803,7 @@ cc.MenuItemSprite = cc.MenuItem.extend(/** @lends cc.MenuItemSprite# */{ return; if (disabledImage) { - this.addChild(disabledImage, 0, cc.Macro.DISABLE_TAG); + this.addChild(disabledImage, 0, cc.macro.DISABLE_TAG); disabledImage.anchorX = 0; disabledImage.anchorY = 0; } @@ -1180,12 +1180,12 @@ cc.MenuItemToggle = cc.MenuItem.extend(/** @lends cc.MenuItemToggle# */{ setSelectedIndex: function (SelectedIndex) { if (SelectedIndex !== this._selectedIndex) { this._selectedIndex = SelectedIndex; - var currItem = this.getChildByTag(cc.Macro.CURRENT_ITEM); + var currItem = this.getChildByTag(cc.macro.CURRENT_ITEM); if (currItem) currItem.removeFromParent(false); var item = this.subItems[this._selectedIndex]; - this.addChild(item, 0, cc.Macro.CURRENT_ITEM); + this.addChild(item, 0, cc.macro.CURRENT_ITEM); var w = item.width, h = item.height; this.width = w; this.height = h; @@ -1235,7 +1235,7 @@ cc.MenuItemToggle = cc.MenuItem.extend(/** @lends cc.MenuItemToggle# */{ if (args[i]) locSubItems.push(args[i]); } - this._selectedIndex = cc.Macro.UINT_MAX; + this._selectedIndex = cc.macro.UINT_MAX; this.setSelectedIndex(0); this.setCascadeColorEnabled(true); diff --git a/cocos2d/motion-streak/CCMotionStreak.js b/cocos2d/motion-streak/CCMotionStreak.js index 66d533c48d..17bcbb59c4 100644 --- a/cocos2d/motion-streak/CCMotionStreak.js +++ b/cocos2d/motion-streak/CCMotionStreak.js @@ -84,7 +84,7 @@ cc.MotionStreak = _ccsg.Node.extend(/** @lends cc.MotionStreak# */{ ctor: function (fade, minSeg, stroke, color, texture) { _ccsg.Node.prototype.ctor.call(this); this._positionR = cc.p(0, 0); - this._blendFunc = new cc.BlendFunc(cc.Macro.SRC_ALPHA, cc.Macro.ONE_MINUS_SRC_ALPHA); + this._blendFunc = new cc.BlendFunc(cc.macro.SRC_ALPHA, cc.macro.ONE_MINUS_SRC_ALPHA); this.fastMode = false; this.startingPositionInitialized = false; diff --git a/cocos2d/motion-streak/CCMotionStreakWebGLRenderCmd.js b/cocos2d/motion-streak/CCMotionStreakWebGLRenderCmd.js index b47388541a..25ab3c3058 100644 --- a/cocos2d/motion-streak/CCMotionStreakWebGLRenderCmd.js +++ b/cocos2d/motion-streak/CCMotionStreakWebGLRenderCmd.js @@ -25,7 +25,7 @@ cc.MotionStreak.WebGLRenderCmd = function(renderableObject){ _ccsg.Node.WebGLRenderCmd.call(this, renderableObject); this._needDraw = true; - this._shaderProgram = cc.shaderCache.programForKey(cc.Macro.SHADER_POSITION_TEXTURECOLOR); + this._shaderProgram = cc.shaderCache.programForKey(cc.macro.SHADER_POSITION_TEXTURECOLOR); }; cc.MotionStreak.WebGLRenderCmd.prototype = Object.create(_ccsg.Node.WebGLRenderCmd.prototype); @@ -40,7 +40,7 @@ cc.MotionStreak.WebGLRenderCmd.prototype.rendering = function(ctx){ ctx = ctx || cc._renderContext; this._shaderProgram.use(); this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix); - cc.glEnableVertexAttribs(cc.Macro.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); + cc.glEnableVertexAttribs(cc.macro.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); cc.glBlendFunc(node._blendFunc.src, node._blendFunc.dst); cc.glBindTexture2D(node.texture); @@ -48,17 +48,17 @@ cc.MotionStreak.WebGLRenderCmd.prototype.rendering = function(ctx){ //position ctx.bindBuffer(ctx.ARRAY_BUFFER, node._verticesBuffer); ctx.bufferData(ctx.ARRAY_BUFFER, node._vertices, ctx.DYNAMIC_DRAW); - ctx.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_POSITION, 2, ctx.FLOAT, false, 0, 0); + ctx.vertexAttribPointer(cc.macro.VERTEX_ATTRIB_POSITION, 2, ctx.FLOAT, false, 0, 0); //texcoords ctx.bindBuffer(ctx.ARRAY_BUFFER, node._texCoordsBuffer); ctx.bufferData(ctx.ARRAY_BUFFER, node._texCoords, ctx.DYNAMIC_DRAW); - ctx.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_TEX_COORDS, 2, ctx.FLOAT, false, 0, 0); + ctx.vertexAttribPointer(cc.macro.VERTEX_ATTRIB_TEX_COORDS, 2, ctx.FLOAT, false, 0, 0); //colors ctx.bindBuffer(ctx.ARRAY_BUFFER, node._colorPointerBuffer); ctx.bufferData(ctx.ARRAY_BUFFER, node._colorPointer, ctx.DYNAMIC_DRAW); - ctx.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_COLOR, 4, ctx.UNSIGNED_BYTE, true, 0, 0); + ctx.vertexAttribPointer(cc.macro.VERTEX_ATTRIB_COLOR, 4, ctx.UNSIGNED_BYTE, true, 0, 0); ctx.drawArrays(ctx.TRIANGLE_STRIP, 0, node._nuPoints * 2); cc.g_NumberOfDraws++; diff --git a/cocos2d/node-grid/CCNodeGrid.js b/cocos2d/node-grid/CCNodeGrid.js index 89db688496..0e59aa5904 100644 --- a/cocos2d/node-grid/CCNodeGrid.js +++ b/cocos2d/node-grid/CCNodeGrid.js @@ -109,7 +109,7 @@ cc.NodeGrid = _ccsg.Node.extend({ apx = app.x, apy = app.y, translate = (apx !== 0.0 || apy !== 0.0); if (translate) { - if(!cc.Macro.SPRITEBATCHNODE_RENDER_SUBPIXEL) { + if(!cc.macro.SPRITEBATCHNODE_RENDER_SUBPIXEL) { apx = 0 | apx; apy = 0 | apy; } diff --git a/cocos2d/particle/CCParticleBatchNode.js b/cocos2d/particle/CCParticleBatchNode.js index daff2faf5b..505c738357 100644 --- a/cocos2d/particle/CCParticleBatchNode.js +++ b/cocos2d/particle/CCParticleBatchNode.js @@ -93,7 +93,7 @@ cc.ParticleBatchNode = _ccsg.Node.extend(/** @lends cc.ParticleBatchNode# */{ */ ctor:function (fileImage, capacity) { _ccsg.Node.prototype.ctor.call(this); - this._blendFunc = {src:cc.Macro.BLEND_SRC, dst:cc.Macro.BLEND_DST}; + this._blendFunc = {src:cc.macro.BLEND_SRC, dst:cc.macro.BLEND_DST}; if (cc.js.isString(fileImage)) { this.init(fileImage, capacity); } else if (fileImage instanceof cc.Texture2D) { @@ -350,9 +350,9 @@ cc.ParticleBatchNode = _ccsg.Node.extend(/** @lends cc.ParticleBatchNode# */{ // If the new texture has No premultiplied alpha, AND the blendFunc hasn't been changed, then update it var locBlendFunc = this._blendFunc; - if (texture && !texture.hasPremultipliedAlpha() && ( locBlendFunc.src === cc.Macro.BLEND_SRC && locBlendFunc.dst === cc.Macro.BLEND_DST )) { - locBlendFunc.src = cc.Macro.SRC_ALPHA; - locBlendFunc.dst = cc.Macro.ONE_MINUS_SRC_ALPHA; + if (texture && !texture.hasPremultipliedAlpha() && ( locBlendFunc.src === cc.macro.BLEND_SRC && locBlendFunc.dst === cc.macro.BLEND_DST )) { + locBlendFunc.src = cc.macro.SRC_ALPHA; + locBlendFunc.dst = cc.macro.ONE_MINUS_SRC_ALPHA; } }, @@ -485,8 +485,8 @@ cc.ParticleBatchNode = _ccsg.Node.extend(/** @lends cc.ParticleBatchNode# */{ _updateBlendFunc:function () { if (!this.textureAtlas.texture.hasPremultipliedAlpha()) { - this._blendFunc.src = cc.Macro.SRC_ALPHA; - this._blendFunc.dst = cc.Macro.ONE_MINUS_SRC_ALPHA; + this._blendFunc.src = cc.macro.SRC_ALPHA; + this._blendFunc.dst = cc.macro.ONE_MINUS_SRC_ALPHA; } }, diff --git a/cocos2d/particle/CCParticleBatchNodeWebGLRenderCmd.js b/cocos2d/particle/CCParticleBatchNodeWebGLRenderCmd.js index 7cfaf72dcb..669d30d764 100644 --- a/cocos2d/particle/CCParticleBatchNodeWebGLRenderCmd.js +++ b/cocos2d/particle/CCParticleBatchNodeWebGLRenderCmd.js @@ -46,7 +46,7 @@ }; proto._initWithTexture = function(){ - this._shaderProgram = cc.shaderCache.programForKey(cc.Macro.SHADER_POSITION_TEXTURECOLOR); + this._shaderProgram = cc.shaderCache.programForKey(cc.macro.SHADER_POSITION_TEXTURECOLOR); }; proto.visit = function(parentCmd){ diff --git a/cocos2d/particle/CCSGParticleSystem.js b/cocos2d/particle/CCSGParticleSystem.js index c05f659798..1c04be344f 100644 --- a/cocos2d/particle/CCSGParticleSystem.js +++ b/cocos2d/particle/CCSGParticleSystem.js @@ -290,7 +290,7 @@ _ccsg.ParticleSystem = _ccsg.Node.extend({ this.emitterMode = _ccsg.ParticleSystem.Mode.GRAVITY; this.modeA = new _ccsg.ParticleSystem.ModeA(); this.modeB = new _ccsg.ParticleSystem.ModeB(); - this._blendFunc = {src:cc.Macro.BLEND_SRC, dst:cc.Macro.BLEND_DST}; + this._blendFunc = {src:cc.macro.BLEND_SRC, dst:cc.macro.BLEND_DST}; this._particles = []; this._sourcePosition = cc.p(0, 0); @@ -1128,8 +1128,8 @@ _ccsg.ParticleSystem = _ccsg.Node.extend({ * dest blend function = GL_ONE; */ isBlendAdditive:function () { - return (( this._blendFunc.src === cc.Macro.SRC_ALPHA && this._blendFunc.dst === cc.Macro.ONE) || - (this._blendFunc.src === cc.Macro.ONE && this._blendFunc.dst === cc.Macro.ONE)); + return (( this._blendFunc.src === cc.macro.SRC_ALPHA && this._blendFunc.dst === cc.macro.ONE) || + (this._blendFunc.src === cc.macro.ONE && this._blendFunc.dst === cc.macro.ONE)); }, /** @@ -1141,8 +1141,8 @@ _ccsg.ParticleSystem = _ccsg.Node.extend({ setBlendAdditive:function (isBlendAdditive) { var locBlendFunc = this._blendFunc; if (isBlendAdditive) { - locBlendFunc.src = cc.Macro.SRC_ALPHA; - locBlendFunc.dst = cc.Macro.ONE; + locBlendFunc.src = cc.macro.SRC_ALPHA; + locBlendFunc.dst = cc.macro.ONE; } else { this._renderCmd._setBlendAdditive(); } @@ -1445,8 +1445,8 @@ _ccsg.ParticleSystem = _ccsg.Node.extend({ this._isActive = true; // default blend function - this._blendFunc.src = cc.Macro.BLEND_SRC; - this._blendFunc.dst = cc.Macro.BLEND_DST; + this._blendFunc.src = cc.macro.BLEND_SRC; + this._blendFunc.dst = cc.macro.BLEND_DST; // default movement type; this.positionType = _ccsg.ParticleSystem.Type.FREE; @@ -1831,12 +1831,12 @@ _ccsg.ParticleSystem = _ccsg.Node.extend({ if (locTexture && locTexture instanceof cc.Texture2D) { this._opacityModifyRGB = false; var locBlendFunc = this._blendFunc; - if (locBlendFunc.src === cc.Macro.BLEND_SRC && locBlendFunc.dst === cc.Macro.BLEND_DST) { + if (locBlendFunc.src === cc.macro.BLEND_SRC && locBlendFunc.dst === cc.macro.BLEND_DST) { if (locTexture.hasPremultipliedAlpha()) { this._opacityModifyRGB = true; } else { - locBlendFunc.src = cc.Macro.SRC_ALPHA; - locBlendFunc.dst = cc.Macro.ONE_MINUS_SRC_ALPHA; + locBlendFunc.src = cc.macro.SRC_ALPHA; + locBlendFunc.dst = cc.macro.ONE_MINUS_SRC_ALPHA; } } } diff --git a/cocos2d/particle/CCSGParticleSystemCanvasRenderCmd.js b/cocos2d/particle/CCSGParticleSystemCanvasRenderCmd.js index b206c2a3ff..67c2e52945 100644 --- a/cocos2d/particle/CCSGParticleSystemCanvasRenderCmd.js +++ b/cocos2d/particle/CCSGParticleSystemCanvasRenderCmd.js @@ -182,8 +182,8 @@ proto._setBlendAdditive = function(){ var locBlendFunc = this._node._blendFunc; - locBlendFunc.src = cc.Macro.BLEND_SRC; - locBlendFunc.dst = cc.Macro.BLEND_DST; + locBlendFunc.src = cc.macro.BLEND_SRC; + locBlendFunc.dst = cc.macro.BLEND_DST; }; proto._initWithTotalParticles = function(totalParticles){}; diff --git a/cocos2d/particle/CCSGParticleSystemWebGLRenderCmd.js b/cocos2d/particle/CCSGParticleSystemWebGLRenderCmd.js index 48c7834c18..caa6f99d02 100644 --- a/cocos2d/particle/CCSGParticleSystemWebGLRenderCmd.js +++ b/cocos2d/particle/CCSGParticleSystemWebGLRenderCmd.js @@ -195,12 +195,12 @@ // // Using VBO without VAO // - cc.glEnableVertexAttribs(cc.Macro.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); + cc.glEnableVertexAttribs(cc.macro.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); gl.bindBuffer(gl.ARRAY_BUFFER, this._buffersVBO[0]); - gl.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_POSITION, 3, gl.FLOAT, false, 24, 0); // vertices - gl.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_COLOR, 4, gl.UNSIGNED_BYTE, true, 24, 12); // colors - gl.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_TEX_COORDS, 2, gl.FLOAT, false, 24, 16); // tex coords + gl.vertexAttribPointer(cc.macro.VERTEX_ATTRIB_POSITION, 3, gl.FLOAT, false, 24, 0); // vertices + gl.vertexAttribPointer(cc.macro.VERTEX_ATTRIB_COLOR, 4, gl.UNSIGNED_BYTE, true, 24, 12); // colors + gl.vertexAttribPointer(cc.macro.VERTEX_ATTRIB_TEX_COORDS, 2, gl.FLOAT, false, 24, 16); // tex coords gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._buffersVBO[1]); gl.drawElements(gl.TRIANGLES, node._particleIdx * 6, gl.UNSIGNED_SHORT, 0); @@ -219,7 +219,7 @@ } var left, bottom, right, top; - if (cc.Macro.FIX_ARTIFACTS_BY_STRECHING_TEXEL) { + if (cc.macro.FIX_ARTIFACTS_BY_STRECHING_TEXEL) { left = (pointRect.x * 2 + 1) / (wide * 2); bottom = (pointRect.y * 2 + 1) / (high * 2); right = left + (pointRect.width * 2 - 2) / (wide * 2); @@ -365,11 +365,11 @@ proto._setBlendAdditive = function(){ var locBlendFunc = this._node._blendFunc; if (this._texture && !this._texture.hasPremultipliedAlpha()) { - locBlendFunc.src = cc.Macro.SRC_ALPHA; - locBlendFunc.dst = cc.Macro.ONE_MINUS_SRC_ALPHA; + locBlendFunc.src = cc.macro.SRC_ALPHA; + locBlendFunc.dst = cc.macro.ONE_MINUS_SRC_ALPHA; } else { - locBlendFunc.src = cc.Macro.BLEND_SRC; - locBlendFunc.dst = cc.Macro.BLEND_DST; + locBlendFunc.src = cc.macro.BLEND_SRC; + locBlendFunc.dst = cc.macro.BLEND_DST; } }; @@ -381,7 +381,7 @@ this.initIndices(totalParticles); this._setupVBO(); - this._shaderProgram = cc.shaderCache.programForKey(cc.Macro.SHADER_POSITION_TEXTURECOLOR); + this._shaderProgram = cc.shaderCache.programForKey(cc.macro.SHADER_POSITION_TEXTURECOLOR); }; proto._updateDeltaColor = function (selParticle, dt) { diff --git a/cocos2d/progress-timer/CCProgressTimerWebGLRenderCmd.js b/cocos2d/progress-timer/CCProgressTimerWebGLRenderCmd.js index 47406e3808..58a7a53b7b 100644 --- a/cocos2d/progress-timer/CCProgressTimerWebGLRenderCmd.js +++ b/cocos2d/progress-timer/CCProgressTimerWebGLRenderCmd.js @@ -51,7 +51,7 @@ var blendFunc = node._sprite._blendFunc; cc.glBlendFunc(blendFunc.src, blendFunc.dst); - cc.glEnableVertexAttribs(cc.Macro.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); + cc.glEnableVertexAttribs(cc.macro.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); cc.glBindTexture2D(node._sprite.texture); @@ -61,9 +61,9 @@ this._vertexDataDirty = false; } var locVertexDataLen = cc.V2F_C4B_T2F.BYTES_PER_ELEMENT; - context.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_POSITION, 2, context.FLOAT, false, locVertexDataLen, 0); - context.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_COLOR, 4, context.UNSIGNED_BYTE, true, locVertexDataLen, 8); - context.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_TEX_COORDS, 2, context.FLOAT, false, locVertexDataLen, 12); + context.vertexAttribPointer(cc.macro.VERTEX_ATTRIB_POSITION, 2, context.FLOAT, false, locVertexDataLen, 0); + context.vertexAttribPointer(cc.macro.VERTEX_ATTRIB_COLOR, 4, context.UNSIGNED_BYTE, true, locVertexDataLen, 8); + context.vertexAttribPointer(cc.macro.VERTEX_ATTRIB_TEX_COORDS, 2, context.FLOAT, false, locVertexDataLen, 12); if (node._type === cc.ProgressTimer.Type.RADIAL) context.drawArrays(context.TRIANGLE_FAN, 0, this._vertexDataCount); @@ -169,7 +169,7 @@ this._vertexDataCount = 0; //shader program - this._shaderProgram = cc.shaderCache.programForKey(cc.Macro.SHADER_POSITION_TEXTURECOLOR); + this._shaderProgram = cc.shaderCache.programForKey(cc.macro.SHADER_POSITION_TEXTURECOLOR); }; proto._updateProgress = function(){ @@ -342,7 +342,7 @@ // intersection point // We loop through five points since the top is split in half - var min_t = cc.Macro.FLT_MAX; + var min_t = cc.macro.FLT_MAX; var locProTextCoordsCount = cc.ProgressTimer.TEXTURE_COORDS_COUNT; for (i = 0; i <= locProTextCoordsCount; ++i) { var pIndex = (i + (locProTextCoordsCount - 1)) % locProTextCoordsCount; diff --git a/cocos2d/render-texture/CCRenderTextureCanvasRenderCmd.js b/cocos2d/render-texture/CCRenderTextureCanvasRenderCmd.js index 7172765279..1e31fdbc46 100644 --- a/cocos2d/render-texture/CCRenderTextureCanvasRenderCmd.js +++ b/cocos2d/render-texture/CCRenderTextureCanvasRenderCmd.js @@ -59,7 +59,7 @@ texture.handleLoadedTexture(); var locSprite = node.sprite = new _ccsg.Sprite(texture); - locSprite.setBlendFunc(cc.Macro.ONE, cc.Macro.ONE_MINUS_SRC_ALPHA); + locSprite.setBlendFunc(cc.macro.ONE, cc.macro.ONE_MINUS_SRC_ALPHA); // Disabled by default. node.autoDraw = false; // add sprite for backward compatibility diff --git a/cocos2d/shaders/CCGLProgram.js b/cocos2d/shaders/CCGLProgram.js index 58bb659214..1f35ee6a89 100644 --- a/cocos2d/shaders/CCGLProgram.js +++ b/cocos2d/shaders/CCGLProgram.js @@ -33,6 +33,7 @@ var HashUniformEntry = function (value, location, hh) { }; var math = cc.math; +var macro = cc.macro; /** * Class that implements a WebGL program @@ -263,27 +264,27 @@ cc.GLProgram = cc._Class.extend(/** @lends cc.GLProgram# */{ /** * It will create 4 uniforms: - * cc.Macro.UNIFORM_PMATRIX - * cc.Macro.UNIFORM_MVMATRIX - * cc.Macro.UNIFORM_MVPMATRIX - * cc.Macro.UNIFORM_SAMPLER + * cc.macro.UNIFORM_PMATRIX + * cc.macro.UNIFORM_MVMATRIX + * cc.macro.UNIFORM_MVPMATRIX + * cc.macro.UNIFORM_SAMPLER */ updateUniforms: function () { - this._uniforms[cc.Macro.UNIFORM_PMATRIX] = this._glContext.getUniformLocation(this._programObj, cc.Macro.UNIFORM_PMATRIX_S); - this._uniforms[cc.Macro.UNIFORM_MVMATRIX] = this._glContext.getUniformLocation(this._programObj, cc.Macro.UNIFORM_MVMATRIX_S); - this._uniforms[cc.Macro.UNIFORM_MVPMATRIX] = this._glContext.getUniformLocation(this._programObj, cc.Macro.UNIFORM_MVPMATRIX_S); - this._uniforms[cc.Macro.UNIFORM_TIME] = this._glContext.getUniformLocation(this._programObj, cc.Macro.UNIFORM_TIME_S); - this._uniforms[cc.Macro.UNIFORM_SINTIME] = this._glContext.getUniformLocation(this._programObj, cc.Macro.UNIFORM_SINTIME_S); - this._uniforms[cc.Macro.UNIFORM_COSTIME] = this._glContext.getUniformLocation(this._programObj, cc.Macro.UNIFORM_COSTIME_S); + this._uniforms[macro.UNIFORM_PMATRIX] = this._glContext.getUniformLocation(this._programObj, macro.UNIFORM_PMATRIX_S); + this._uniforms[macro.UNIFORM_MVMATRIX] = this._glContext.getUniformLocation(this._programObj, macro.UNIFORM_MVMATRIX_S); + this._uniforms[macro.UNIFORM_MVPMATRIX] = this._glContext.getUniformLocation(this._programObj, macro.UNIFORM_MVPMATRIX_S); + this._uniforms[macro.UNIFORM_TIME] = this._glContext.getUniformLocation(this._programObj, macro.UNIFORM_TIME_S); + this._uniforms[macro.UNIFORM_SINTIME] = this._glContext.getUniformLocation(this._programObj, macro.UNIFORM_SINTIME_S); + this._uniforms[macro.UNIFORM_COSTIME] = this._glContext.getUniformLocation(this._programObj, macro.UNIFORM_COSTIME_S); - this._usesTime = (this._uniforms[cc.Macro.UNIFORM_TIME] != null || this._uniforms[cc.Macro.UNIFORM_SINTIME] != null || this._uniforms[cc.Macro.UNIFORM_COSTIME] != null); + this._usesTime = (this._uniforms[macro.UNIFORM_TIME] != null || this._uniforms[macro.UNIFORM_SINTIME] != null || this._uniforms[macro.UNIFORM_COSTIME] != null); - this._uniforms[cc.Macro.UNIFORM_RANDOM01] = this._glContext.getUniformLocation(this._programObj, cc.Macro.UNIFORM_RANDOM01_S); - this._uniforms[cc.Macro.UNIFORM_SAMPLER] = this._glContext.getUniformLocation(this._programObj, cc.Macro.UNIFORM_SAMPLER_S); + this._uniforms[macro.UNIFORM_RANDOM01] = this._glContext.getUniformLocation(this._programObj, macro.UNIFORM_RANDOM01_S); + this._uniforms[macro.UNIFORM_SAMPLER] = this._glContext.getUniformLocation(this._programObj, macro.UNIFORM_SAMPLER_S); this.use(); // Since sample most probably won't change, set it to 0 now. - this.setUniformLocationWith1i(this._uniforms[cc.Macro.UNIFORM_SAMPLER], 0); + this.setUniformLocationWith1i(this._uniforms[macro.UNIFORM_SAMPLER], 0); }, /** @@ -305,7 +306,7 @@ cc.GLProgram = cc._Class.extend(/** @lends cc.GLProgram# */{ * @returns {WebGLUniformLocation} */ getUniformMVPMatrix: function () { - return this._uniforms[cc.Macro.UNIFORM_MVPMATRIX]; + return this._uniforms[macro.UNIFORM_MVPMATRIX]; }, /** @@ -313,7 +314,7 @@ cc.GLProgram = cc._Class.extend(/** @lends cc.GLProgram# */{ * @returns {WebGLUniformLocation} */ getUniformSampler: function () { - return this._uniforms[cc.Macro.UNIFORM_SAMPLER]; + return this._uniforms[macro.UNIFORM_SAMPLER]; }, /** @@ -554,9 +555,9 @@ cc.GLProgram = cc._Class.extend(/** @lends cc.GLProgram# */{ math.mat4Multiply(matrixMVP, matrixP, matrixMV); - this.setUniformLocationWithMatrix4fv(this._uniforms[cc.Macro.UNIFORM_PMATRIX], matrixP.mat, 1); - this.setUniformLocationWithMatrix4fv(this._uniforms[cc.Macro.UNIFORM_MVMATRIX], matrixMV.mat, 1); - this.setUniformLocationWithMatrix4fv(this._uniforms[cc.Macro.UNIFORM_MVPMATRIX], matrixMVP.mat, 1); + this.setUniformLocationWithMatrix4fv(this._uniforms[macro.UNIFORM_PMATRIX], matrixP.mat, 1); + this.setUniformLocationWithMatrix4fv(this._uniforms[macro.UNIFORM_MVMATRIX], matrixMV.mat, 1); + this.setUniformLocationWithMatrix4fv(this._uniforms[macro.UNIFORM_MVPMATRIX], matrixMVP.mat, 1); if (this._usesTime) { var director = cc.director; @@ -565,13 +566,13 @@ cc.GLProgram = cc._Class.extend(/** @lends cc.GLProgram# */{ // Getting Mach time per frame per shader using time could be extremely expensive. var time = director.getTotalFrames() * director.getAnimationInterval(); - this.setUniformLocationWith4f(this._uniforms[cc.Macro.UNIFORM_TIME], time / 10.0, time, time * 2, time * 4); - this.setUniformLocationWith4f(this._uniforms[cc.Macro.UNIFORM_SINTIME], time / 8.0, time / 4.0, time / 2.0, Math.sin(time)); - this.setUniformLocationWith4f(this._uniforms[cc.Macro.UNIFORM_COSTIME], time / 8.0, time / 4.0, time / 2.0, Math.cos(time)); + this.setUniformLocationWith4f(this._uniforms[macro.UNIFORM_TIME], time / 10.0, time, time * 2, time * 4); + this.setUniformLocationWith4f(this._uniforms[macro.UNIFORM_SINTIME], time / 8.0, time / 4.0, time / 2.0, Math.sin(time)); + this.setUniformLocationWith4f(this._uniforms[macro.UNIFORM_COSTIME], time / 8.0, time / 4.0, time / 2.0, Math.cos(time)); } - if (this._uniforms[cc.Macro.UNIFORM_RANDOM01] !== -1) - this.setUniformLocationWith4f(this._uniforms[cc.Macro.UNIFORM_RANDOM01], Math.random(), Math.random(), Math.random(), Math.random()); + if (this._uniforms[macro.UNIFORM_RANDOM01] !== -1) + this.setUniformLocationWith4f(this._uniforms[macro.UNIFORM_RANDOM01], Math.random(), Math.random(), Math.random(), Math.random()); }, _setUniformsForBuiltinsForRenderer: function (node) { @@ -587,9 +588,9 @@ cc.GLProgram = cc._Class.extend(/** @lends cc.GLProgram# */{ math.mat4Multiply(matrixMVP, matrixP, node._renderCmd._stackMatrix); - this.setUniformLocationWithMatrix4fv(this._uniforms[cc.Macro.UNIFORM_PMATRIX], matrixP.mat, 1); - this.setUniformLocationWithMatrix4fv(this._uniforms[cc.Macro.UNIFORM_MVMATRIX], node._renderCmd._stackMatrix.mat, 1); - this.setUniformLocationWithMatrix4fv(this._uniforms[cc.Macro.UNIFORM_MVPMATRIX], matrixMVP.mat, 1); + this.setUniformLocationWithMatrix4fv(this._uniforms[macro.UNIFORM_PMATRIX], matrixP.mat, 1); + this.setUniformLocationWithMatrix4fv(this._uniforms[macro.UNIFORM_MVMATRIX], node._renderCmd._stackMatrix.mat, 1); + this.setUniformLocationWithMatrix4fv(this._uniforms[macro.UNIFORM_MVPMATRIX], matrixMVP.mat, 1); if (this._usesTime) { var director = cc.director; @@ -598,38 +599,38 @@ cc.GLProgram = cc._Class.extend(/** @lends cc.GLProgram# */{ // Getting Mach time per frame per shader using time could be extremely expensive. var time = director.getTotalFrames() * director.getAnimationInterval(); - this.setUniformLocationWith4f(this._uniforms[cc.Macro.UNIFORM_TIME], time / 10.0, time, time * 2, time * 4); - this.setUniformLocationWith4f(this._uniforms[cc.Macro.UNIFORM_SINTIME], time / 8.0, time / 4.0, time / 2.0, Math.sin(time)); - this.setUniformLocationWith4f(this._uniforms[cc.Macro.UNIFORM_COSTIME], time / 8.0, time / 4.0, time / 2.0, Math.cos(time)); + this.setUniformLocationWith4f(this._uniforms[macro.UNIFORM_TIME], time / 10.0, time, time * 2, time * 4); + this.setUniformLocationWith4f(this._uniforms[macro.UNIFORM_SINTIME], time / 8.0, time / 4.0, time / 2.0, Math.sin(time)); + this.setUniformLocationWith4f(this._uniforms[macro.UNIFORM_COSTIME], time / 8.0, time / 4.0, time / 2.0, Math.cos(time)); } - if (this._uniforms[cc.Macro.UNIFORM_RANDOM01] !== -1) - this.setUniformLocationWith4f(this._uniforms[cc.Macro.UNIFORM_RANDOM01], Math.random(), Math.random(), Math.random(), Math.random()); + if (this._uniforms[macro.UNIFORM_RANDOM01] !== -1) + this.setUniformLocationWith4f(this._uniforms[macro.UNIFORM_RANDOM01], Math.random(), Math.random(), Math.random(), Math.random()); }, /** * will update the MVP matrix on the MVP uniform if it is different than the previous call for this same shader program. */ setUniformForModelViewProjectionMatrix: function () { - this._glContext.uniformMatrix4fv(this._uniforms[cc.Macro.UNIFORM_MVPMATRIX], false, + this._glContext.uniformMatrix4fv(this._uniforms[macro.UNIFORM_MVPMATRIX], false, math.getMat4MultiplyValue(math.projection_matrix_stack.top, math.modelview_matrix_stack.top)); }, setUniformForModelViewProjectionMatrixWithMat4: function (swapMat4) { math.mat4Multiply(swapMat4, math.projection_matrix_stack.top, math.modelview_matrix_stack.top); - this._glContext.uniformMatrix4fv(this._uniforms[cc.Macro.UNIFORM_MVPMATRIX], false, swapMat4.mat); + this._glContext.uniformMatrix4fv(this._uniforms[macro.UNIFORM_MVPMATRIX], false, swapMat4.mat); }, setUniformForModelViewAndProjectionMatrixWithMat4: function () { - this._glContext.uniformMatrix4fv(this._uniforms[cc.Macro.UNIFORM_MVMATRIX], false, math.modelview_matrix_stack.top.mat); - this._glContext.uniformMatrix4fv(this._uniforms[cc.Macro.UNIFORM_PMATRIX], false, math.projection_matrix_stack.top.mat); + this._glContext.uniformMatrix4fv(this._uniforms[macro.UNIFORM_MVMATRIX], false, math.modelview_matrix_stack.top.mat); + this._glContext.uniformMatrix4fv(this._uniforms[macro.UNIFORM_PMATRIX], false, math.projection_matrix_stack.top.mat); }, _setUniformForMVPMatrixWithMat4: function(modelViewMatrix){ if(!modelViewMatrix) throw new Error("modelView matrix is undefined."); - this._glContext.uniformMatrix4fv(this._uniforms[cc.Macro.UNIFORM_MVMATRIX], false, modelViewMatrix.mat); - this._glContext.uniformMatrix4fv(this._uniforms[cc.Macro.UNIFORM_PMATRIX], false, math.projection_matrix_stack.top.mat); + this._glContext.uniformMatrix4fv(this._uniforms[macro.UNIFORM_MVMATRIX], false, modelViewMatrix.mat); + this._glContext.uniformMatrix4fv(this._uniforms[macro.UNIFORM_PMATRIX], false, math.projection_matrix_stack.top.mat); }, /** @@ -755,7 +756,7 @@ cc.GLProgram._isHighpSupported = function(){ * @param {_ccsg.Node} node * @param {cc.GLProgram} program The shader program which fetches from CCShaderCache. * @example - * cc.setGLProgram(node, cc.shaderCache.programForKey(cc.Macro.SHADER_POSITION_TEXTURECOLOR)); + * cc.setGLProgram(node, cc.shaderCache.programForKey(cc.macro.SHADER_POSITION_TEXTURECOLOR)); */ cc.setProgram = function (node, program) { node.shaderProgram = program; diff --git a/cocos2d/shaders/CCGLStateCache.js b/cocos2d/shaders/CCGLStateCache.js index 93ee076ad3..ea2442c61d 100644 --- a/cocos2d/shaders/CCGLStateCache.js +++ b/cocos2d/shaders/CCGLStateCache.js @@ -29,7 +29,9 @@ cc._vertexAttribPosition = false; cc._vertexAttribColor = false; cc._vertexAttribTexCoords = false; -var ENABLE_GL_STATE_CACHE = cc.Macro.ENABLE_GL_STATE_CACHE; +var macro = cc.macro; + +var ENABLE_GL_STATE_CACHE = macro.ENABLE_GL_STATE_CACHE; if (ENABLE_GL_STATE_CACHE) { cc.MAX_ACTIVETEXTURE = 16; @@ -39,7 +41,7 @@ if (ENABLE_GL_STATE_CACHE) { cc._blendingSource = -1; cc._blendingDest = -1; cc._GLServerState = 0; - if(cc.Macro.TEXTURE_ATLAS_USE_VAO) + if(macro.TEXTURE_ATLAS_USE_VAO) cc._uVAO = 0; } @@ -47,7 +49,7 @@ if (ENABLE_GL_STATE_CACHE) { /** * Invalidates the GL state cache.
- * If cc.Macro.ENABLE_GL_STATE_CACHE it will reset the GL state cache. + * If cc.macro.ENABLE_GL_STATE_CACHE it will reset the GL state cache. * @function */ cc.glInvalidateStateCache = function () { @@ -69,7 +71,7 @@ cc.glInvalidateStateCache = function () { /** * Uses the GL program in case program is different than the current one.
- * If cc.Macro.ENABLE_GL_STATE_CACHE is disabled, it will the glUseProgram() directly. + * If cc.macro.ENABLE_GL_STATE_CACHE is disabled, it will the glUseProgram() directly. * @function * @param {WebGLProgram} program */ @@ -88,7 +90,7 @@ if(!ENABLE_GL_STATE_CACHE){ /** * Deletes the GL program. If it is the one that is being used, it invalidates it.
- * If cc.Macro.ENABLE_GL_STATE_CACHE is disabled, it will the glDeleteProgram() directly. + * If cc.macro.ENABLE_GL_STATE_CACHE is disabled, it will the glDeleteProgram() directly. * @function * @param {WebGLProgram} program */ @@ -102,7 +104,7 @@ cc.glDeleteProgram = function (program) { /** * Uses a blending function in case it not already used.
- * If cc.Macro.ENABLE_GL_STATE_CACHE is disabled, it will the glBlendFunc() directly. + * If cc.macro.ENABLE_GL_STATE_CACHE is disabled, it will the glBlendFunc() directly. * @function * @param {Number} sfactor * @param {Number} dfactor @@ -158,7 +160,7 @@ if(!ENABLE_GL_STATE_CACHE){ /** * Resets the blending mode back to the cached state in case you used glBlendFuncSeparate() or glBlendEquation().
- * If cc.Macro.ENABLE_GL_STATE_CACHE is disabled, it will just set the default blending mode using GL_FUNC_ADD. + * If cc.macro.ENABLE_GL_STATE_CACHE is disabled, it will just set the default blending mode using GL_FUNC_ADD. * @function */ cc.glBlendResetToCache = function () { @@ -182,51 +184,51 @@ cc.setProjectionMatrixDirty = function () { *

* Will enable the vertex attribs that are passed as flags.
* Possible flags:
- * cc.Macro.VERTEX_ATTRIB_FLAG_POSITION
- * cc.Macro.VERTEX_ATTRIB_FLAG_COLOR
- * cc.Macro.VERTEX_ATTRIB_FLAG_TEX_COORDS
+ * cc.macro.VERTEX_ATTRIB_FLAG_POSITION
+ * cc.macro.VERTEX_ATTRIB_FLAG_COLOR
+ * cc.macro.VERTEX_ATTRIB_FLAG_TEX_COORDS
*
* These flags can be ORed. The flags that are not present, will be disabled. *

* @function - * @param {cc.Macro.VERTEX_ATTRIB_FLAG_POSITION | cc.Macro.VERTEX_ATTRIB_FLAG_COLOR | cc.Macro.VERTEX_ATTRIB_FLAG_TEX_OORDS} flags + * @param {cc.macro.VERTEX_ATTRIB_FLAG_POSITION | cc.macro.VERTEX_ATTRIB_FLAG_COLOR | cc.macro.VERTEX_ATTRIB_FLAG_TEX_OORDS} flags */ cc.glEnableVertexAttribs = function (flags) { /* Position */ var ctx = cc._renderContext; - var enablePosition = ( flags & cc.Macro.VERTEX_ATTRIB_FLAG_POSITION ); + var enablePosition = ( flags & macro.VERTEX_ATTRIB_FLAG_POSITION ); if (enablePosition !== cc._vertexAttribPosition) { if (enablePosition) - ctx.enableVertexAttribArray(cc.Macro.VERTEX_ATTRIB_POSITION); + ctx.enableVertexAttribArray(macro.VERTEX_ATTRIB_POSITION); else - ctx.disableVertexAttribArray(cc.Macro.VERTEX_ATTRIB_POSITION); + ctx.disableVertexAttribArray(macro.VERTEX_ATTRIB_POSITION); cc._vertexAttribPosition = enablePosition; } /* Color */ - var enableColor = (flags & cc.Macro.VERTEX_ATTRIB_FLAG_COLOR); + var enableColor = (flags & macro.VERTEX_ATTRIB_FLAG_COLOR); if (enableColor !== cc._vertexAttribColor) { if (enableColor) - ctx.enableVertexAttribArray(cc.Macro.VERTEX_ATTRIB_COLOR); + ctx.enableVertexAttribArray(macro.VERTEX_ATTRIB_COLOR); else - ctx.disableVertexAttribArray(cc.Macro.VERTEX_ATTRIB_COLOR); + ctx.disableVertexAttribArray(macro.VERTEX_ATTRIB_COLOR); cc._vertexAttribColor = enableColor; } /* Tex Coords */ - var enableTexCoords = (flags & cc.Macro.VERTEX_ATTRIB_FLAG_TEX_COORDS); + var enableTexCoords = (flags & macro.VERTEX_ATTRIB_FLAG_TEX_COORDS); if (enableTexCoords !== cc._vertexAttribTexCoords) { if (enableTexCoords) - ctx.enableVertexAttribArray(cc.Macro.VERTEX_ATTRIB_TEX_COORDS); + ctx.enableVertexAttribArray(macro.VERTEX_ATTRIB_TEX_COORDS); else - ctx.disableVertexAttribArray(cc.Macro.VERTEX_ATTRIB_TEX_COORDS); + ctx.disableVertexAttribArray(macro.VERTEX_ATTRIB_TEX_COORDS); cc._vertexAttribTexCoords = enableTexCoords; } }; /** * If the texture is not already bound, it binds it.
- * If cc.Macro.ENABLE_GL_STATE_CACHE is disabled, it will call glBindTexture() directly. + * If cc.macro.ENABLE_GL_STATE_CACHE is disabled, it will call glBindTexture() directly. * @function * @param {cc.Texture2D} textureId */ @@ -236,7 +238,7 @@ cc.glBindTexture2D = function (textureId) { /** * If the texture is not already bound to a given unit, it binds it.
- * If cc.Macro.ENABLE_GL_STATE_CACHE is disabled, it will call glBindTexture() directly. + * If cc.macro.ENABLE_GL_STATE_CACHE is disabled, it will call glBindTexture() directly. * @function * @param {Number} textureUnit * @param {cc.Texture2D} textureId @@ -266,7 +268,7 @@ if (!ENABLE_GL_STATE_CACHE){ /** * It will delete a given texture. If the texture was bound, it will invalidate the cached.
- * If cc.Macro.ENABLE_GL_STATE_CACHE is disabled, it will call glDeleteTextures() directly. + * If cc.macro.ENABLE_GL_STATE_CACHE is disabled, it will call glDeleteTextures() directly. * @function * @param {cc.Texture2D} textureId */ @@ -276,7 +278,7 @@ cc.glDeleteTexture2D = function (textureId) { /** * It will delete a given texture. If the texture was bound, it will invalidate the cached for the given texture unit.
- * If cc.Macro.ENABLE_GL_STATE_CACHE is disabled, it will call glDeleteTextures() directly. + * If cc.macro.ENABLE_GL_STATE_CACHE is disabled, it will call glDeleteTextures() directly. * @function * @param {Number} textureUnit * @param {cc.Texture2D} textureId @@ -291,12 +293,12 @@ cc.glDeleteTexture2DN = function (textureUnit, textureId) { /** * If the vertex array is not already bound, it binds it.
- * If cc.Macro.ENABLE_GL_STATE_CACHE is disabled, it will call glBindVertexArray() directly. + * If cc.macro.ENABLE_GL_STATE_CACHE is disabled, it will call glBindVertexArray() directly. * @function * @param {Number} vaoId */ cc.glBindVAO = function (vaoId) { - if (!cc.Macro.TEXTURE_ATLAS_USE_VAO) + if (!macro.TEXTURE_ATLAS_USE_VAO) return; if (ENABLE_GL_STATE_CACHE) { @@ -312,7 +314,7 @@ cc.glBindVAO = function (vaoId) { /** * It will enable / disable the server side GL states.
- * If cc.Macro.ENABLE_GL_STATE_CACHE is disabled, it will call glEnable() directly. + * If cc.macro.ENABLE_GL_STATE_CACHE is disabled, it will call glEnable() directly. * @function * @param {Number} flags */ diff --git a/cocos2d/shaders/CCShaderCache.js b/cocos2d/shaders/CCShaderCache.js index 79767387cc..c004f2a359 100644 --- a/cocos2d/shaders/CCShaderCache.js +++ b/cocos2d/shaders/CCShaderCache.js @@ -25,7 +25,7 @@ ****************************************************************************/ var shaders = cc.PresetShaders; -var macro = cc.Macro; +var macro = cc.macro; /** * cc.shaderCache is a singleton object that stores manages GL shaders diff --git a/cocos2d/shape-nodes/CCDrawNode.js b/cocos2d/shape-nodes/CCDrawNode.js index ee4a0febf4..9622a74b41 100644 --- a/cocos2d/shape-nodes/CCDrawNode.js +++ b/cocos2d/shape-nodes/CCDrawNode.js @@ -198,7 +198,7 @@ cc.game.once(cc.game.EVENT_RENDERER_INITED, function () { var locCmd = this._renderCmd; locCmd._buffer = this._buffer = []; locCmd._drawColor = this._drawColor = cc.color(255, 255, 255, 255); - locCmd._blendFunc = this._blendFunc = new cc.BlendFunc(cc.Macro.SRC_ALPHA, cc.Macro.ONE_MINUS_SRC_ALPHA); + locCmd._blendFunc = this._blendFunc = new cc.BlendFunc(cc.macro.SRC_ALPHA, cc.macro.ONE_MINUS_SRC_ALPHA); this.init(); }, @@ -527,7 +527,7 @@ cc.game.once(cc.game.EVENT_RENDERER_INITED, function () { ctor:function () { _ccsg.Node.prototype.ctor.call(this); this._buffer = []; - this._blendFunc = new cc.BlendFunc(cc.Macro.SRC_ALPHA, cc.Macro.ONE_MINUS_SRC_ALPHA); + this._blendFunc = new cc.BlendFunc(cc.macro.SRC_ALPHA, cc.macro.ONE_MINUS_SRC_ALPHA); this._drawColor = new cc.WebGLColor(255,255,255,255); this.init(); @@ -535,7 +535,7 @@ cc.game.once(cc.game.EVENT_RENDERER_INITED, function () { init:function () { if (_ccsg.Node.prototype.init.call(this)) { - this.shaderProgram = cc.shaderCache.programForKey(cc.Macro.SHADER_POSITION_LENGTHTEXTURECOLOR); + this.shaderProgram = cc.shaderCache.programForKey(cc.macro.SHADER_POSITION_LENGTHTEXTURECOLOR); this._ensureCapacity(64); this._trianglesWebBuffer = cc._renderContext.createBuffer(); this._dirty = true; @@ -649,7 +649,7 @@ cc.game.once(cc.game.EVENT_RENDERER_INITED, function () { _render:function () { var gl = cc._renderContext; - cc.glEnableVertexAttribs(cc.Macro.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); + cc.glEnableVertexAttribs(cc.macro.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); gl.bindBuffer(gl.ARRAY_BUFFER, this._trianglesWebBuffer); if (this._dirty) { gl.bufferData(gl.ARRAY_BUFFER, this._trianglesArrayBuffer, gl.STREAM_DRAW); @@ -658,11 +658,11 @@ cc.game.once(cc.game.EVENT_RENDERER_INITED, function () { var triangleSize = cc.V2F_C4B_T2F.BYTES_PER_ELEMENT; // vertex - gl.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, triangleSize, 0); + gl.vertexAttribPointer(cc.macro.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, triangleSize, 0); // color - gl.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_COLOR, 4, gl.UNSIGNED_BYTE, true, triangleSize, 8); + gl.vertexAttribPointer(cc.macro.VERTEX_ATTRIB_COLOR, 4, gl.UNSIGNED_BYTE, true, triangleSize, 8); // texcood - gl.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_TEX_COORDS, 2, gl.FLOAT, false, triangleSize, 12); + gl.vertexAttribPointer(cc.macro.VERTEX_ATTRIB_TEX_COORDS, 2, gl.FLOAT, false, triangleSize, 12); gl.drawArrays(gl.TRIANGLES, 0, this._buffer.length * 3); cc.incrementGLDraws(1); diff --git a/cocos2d/shape-nodes/CCDrawNodeCanvasRenderCmd.js b/cocos2d/shape-nodes/CCDrawNodeCanvasRenderCmd.js index eb3af4bd14..e244adfd1a 100644 --- a/cocos2d/shape-nodes/CCDrawNodeCanvasRenderCmd.js +++ b/cocos2d/shape-nodes/CCDrawNodeCanvasRenderCmd.js @@ -45,7 +45,7 @@ //context.save(); wrapper.setGlobalAlpha(alpha); - if ((this._blendFunc && (this._blendFunc.src === cc.Macro.SRC_ALPHA) && (this._blendFunc.dst === cc.Macro.ONE))) + if ((this._blendFunc && (this._blendFunc.src === cc.macro.SRC_ALPHA) && (this._blendFunc.dst === cc.macro.ONE))) wrapper.setCompositeOperation('lighter'); //todo: need refactor var locBuffer = this._buffer; for (var i = 0, len = locBuffer.length; i < len; i++) { diff --git a/cocos2d/tilemap/CCSGTMXLayer.js b/cocos2d/tilemap/CCSGTMXLayer.js index 54ab7da302..26d349f679 100644 --- a/cocos2d/tilemap/CCSGTMXLayer.js +++ b/cocos2d/tilemap/CCSGTMXLayer.js @@ -766,8 +766,8 @@ _ccsg.TMXLayer = cc.SpriteBatchNode.extend(/** @lends _ccsg.TMXLayer# */{ alphaFuncValue = parseFloat(alphaFuncVal); if (cc._renderType === cc.game.RENDER_TYPE_WEBGL) { //todo: need move to WebGL render cmd - this.shaderProgram = cc.shaderCache.programForKey(cc.Macro.SHADER_POSITION_TEXTURECOLORALPHATEST); - var alphaValueLocation = cc._renderContext.getUniformLocation(this.shaderProgram.getProgram(), cc.Macro.UNIFORM_ALPHA_TEST_VALUE_S); + this.shaderProgram = cc.shaderCache.programForKey(cc.macro.SHADER_POSITION_TEXTURECOLORALPHATEST); + var alphaValueLocation = cc._renderContext.getUniformLocation(this.shaderProgram.getProgram(), cc.macro.UNIFORM_ALPHA_TEST_VALUE_S); // NOTE: alpha test shader is hard-coded to use the equivalent of a glAlphaFunc(GL_GREATER) comparison this.shaderProgram.use(); this.shaderProgram.setUniformLocationWith1f(alphaValueLocation, alphaFuncValue); diff --git a/cocos2d/transitions/CCTransition.js b/cocos2d/transitions/CCTransition.js index b041faf0f3..c586437d66 100644 --- a/cocos2d/transitions/CCTransition.js +++ b/cocos2d/transitions/CCTransition.js @@ -1518,8 +1518,8 @@ cc.TransitionCrossFade = cc.TransitionScene.extend(/** @lends cc.TransitionCross this._outScene.visit(); outTexture.end(); - inTexture.sprite.setBlendFunc(cc.Macro.ONE, cc.Macro.ONE); // inScene will lay on background and will not be used with alpha - outTexture.sprite.setBlendFunc(cc.Macro.SRC_ALPHA, cc.Macro.ONE_MINUS_SRC_ALPHA); // we are going to blend outScene via alpha + inTexture.sprite.setBlendFunc(cc.macro.ONE, cc.macro.ONE); // inScene will lay on background and will not be used with alpha + outTexture.sprite.setBlendFunc(cc.macro.SRC_ALPHA, cc.macro.ONE_MINUS_SRC_ALPHA); // we are going to blend outScene via alpha // add render textures to the layer layer.addChild(inTexture); diff --git a/extensions/ccui/base-classes/CCProtectedNode.js b/extensions/ccui/base-classes/CCProtectedNode.js index 52a88592db..889240886b 100644 --- a/extensions/ccui/base-classes/CCProtectedNode.js +++ b/extensions/ccui/base-classes/CCProtectedNode.js @@ -85,7 +85,7 @@ cc.ProtectedNode = _ccsg.Node.extend(/** @lends cc.ProtectedNode# */{ * @return {_ccsg.Node} a Node object whose tag equals to the input parameter */ getProtectedChildByTag: function(tag){ - cc.assert(tag !== cc.Macro.NODE_TAG_INVALID, "Invalid tag"); + cc.assert(tag !== cc.macro.NODE_TAG_INVALID, "Invalid tag"); var locChildren = this._protectedChildren; for(var i = 0, len = locChildren.length; i < len; i++) if(locChildren.getTag() === tag) @@ -129,7 +129,7 @@ cc.ProtectedNode = _ccsg.Node.extend(/** @lends cc.ProtectedNode# */{ * @param {Boolean} [cleanup=true] */ removeProtectedChildByTag: function(tag, cleanup){ - cc.assert( tag !== cc.Macro.NODE_TAG_INVALID, "Invalid tag"); + cc.assert( tag !== cc.macro.NODE_TAG_INVALID, "Invalid tag"); if(cleanup == null) cleanup = true; diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index de88174cc3..8b3269143e 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -936,7 +936,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ var index = 0, locChildren = this.getChildren(); var count = locChildren.length, widgetPosition; - var distance = cc.Macro.FLT_MAX, found = 0; + var distance = cc.macro.FLT_MAX, found = 0; if (direction === ccui.Widget.LEFT || direction === ccui.Widget.RIGHT || direction === ccui.Widget.DOWN || direction === ccui.Widget.UP) { widgetPosition = this._getWorldCenterPoint(baseWidget); while (index < count) { @@ -972,7 +972,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ var index = 0, locChildren = this.getChildren(); var count = locChildren.length; - var distance = -cc.Macro.FLT_MAX, found = 0; + var distance = -cc.macro.FLT_MAX, found = 0; if (direction === ccui.Widget.LEFT || direction === ccui.Widget.RIGHT || direction === ccui.Widget.DOWN || direction === ccui.Widget.UP) { var widgetPosition = this._getWorldCenterPoint(baseWidget); while (index < count) { @@ -1000,7 +1000,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ * @private */ _calculateNearestDistance: function(baseWidget){ - var distance = cc.Macro.FLT_MAX; + var distance = cc.macro.FLT_MAX; var widgetPosition = this._getWorldCenterPoint(baseWidget); var locChildren = this._children; @@ -1027,7 +1027,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ * @private */ _calculateFarthestDistance:function(baseWidget){ - var distance = -cc.Macro.FLT_MAX; + var distance = -cc.macro.FLT_MAX; var widgetPosition = this._getWorldCenterPoint(baseWidget); var locChildren = this._children; diff --git a/extensions/cocostudio/action/CCActionObject.js b/extensions/cocostudio/action/CCActionObject.js index a78f0f7b41..bb8959c86b 100644 --- a/extensions/cocostudio/action/CCActionObject.js +++ b/extensions/cocostudio/action/CCActionObject.js @@ -200,7 +200,7 @@ ccs.ActionObject = ccs.Class.extend(/** @lends ccs.ActionObject# */{ locActionNodeList[i].playAction(fun); } if (this._loop) - this._scheduler.schedule(this.simulationActionUpdate, this, 0, cc.Macro.REPEAT_FOREVER, 0, false, this.__instanceId + ""); + this._scheduler.schedule(this.simulationActionUpdate, this, 0, cc.macro.REPEAT_FOREVER, 0, false, this.__instanceId + ""); if(fun !== undefined) this._callback = fun; }, diff --git a/extensions/cocostudio/armature/CCArmature.js b/extensions/cocostudio/armature/CCArmature.js index 8030a42a5c..41778fc45b 100644 --- a/extensions/cocostudio/armature/CCArmature.js +++ b/extensions/cocostudio/armature/CCArmature.js @@ -68,7 +68,7 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ this._armatureIndexDic = {}; this._offsetPoint = cc.p(0, 0); this._armatureTransformDirty = true; - this._blendFunc = {src: cc.Macro.BLEND_SRC, dst: cc.Macro.BLEND_DST}; + this._blendFunc = {src: cc.macro.BLEND_SRC, dst: cc.macro.BLEND_DST}; name && ccs.Armature.prototype.init.call(this, name, parentBone); }, diff --git a/extensions/cocostudio/armature/CCArmatureWebGLRenderCmd.js b/extensions/cocostudio/armature/CCArmatureWebGLRenderCmd.js index ff3019e332..b282271316 100644 --- a/extensions/cocostudio/armature/CCArmatureWebGLRenderCmd.js +++ b/extensions/cocostudio/armature/CCArmatureWebGLRenderCmd.js @@ -92,7 +92,7 @@ }; proto.initShaderCache = function(){ - this._shaderProgram = cc.shaderCache.programForKey(cc.Macro.SHADER_POSITION_TEXTURECOLOR); + this._shaderProgram = cc.shaderCache.programForKey(cc.macro.SHADER_POSITION_TEXTURECOLOR); }; proto.setShaderProgram = function(shaderProgram){ diff --git a/extensions/cocostudio/armature/CCBone.js b/extensions/cocostudio/armature/CCBone.js index 38c5f123a7..0d256735fb 100644 --- a/extensions/cocostudio/armature/CCBone.js +++ b/extensions/cocostudio/armature/CCBone.js @@ -78,7 +78,7 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ this._worldTransform = cc.affineTransformMake(1, 0, 0, 1, 0, 0); this._boneTransformDirty = true; - this._blendFunc = new cc.BlendFunc(cc.Macro.BLEND_SRC, cc.Macro.BLEND_DST); + this._blendFunc = new cc.BlendFunc(cc.macro.BLEND_SRC, cc.macro.BLEND_DST); this.blendDirty = false; this._worldInfo = null; diff --git a/extensions/cocostudio/armature/datas/CCDatas.js b/extensions/cocostudio/armature/datas/CCDatas.js index 5bd84bf0a1..4526071f81 100644 --- a/extensions/cocostudio/armature/datas/CCDatas.js +++ b/extensions/cocostudio/armature/datas/CCDatas.js @@ -557,7 +557,7 @@ ccs.FrameData = ccs.BaseData.extend(/** @lends ccs.FrameData# */{ this.event = ""; this.sound = ""; this.soundEffect = ""; - this.blendFunc = new cc.BlendFunc(cc.Macro.BLEND_SRC, cc.Macro.BLEND_DST); + this.blendFunc = new cc.BlendFunc(cc.macro.BLEND_SRC, cc.macro.BLEND_DST); this.frameID = 0; this.isTween = true; }, diff --git a/extensions/cocostudio/armature/display/CCBatchNode.js b/extensions/cocostudio/armature/display/CCBatchNode.js index 390c744a37..99a626ffb6 100644 --- a/extensions/cocostudio/armature/display/CCBatchNode.js +++ b/extensions/cocostudio/armature/display/CCBatchNode.js @@ -40,7 +40,7 @@ ccs.BatchNode = _ccsg.Node.extend(/** @lends ccs.BatchNode# */{ init:function () { var ret = _ccsg.Node.prototype.init.call(this); - this.setShaderProgram(cc.shaderCache.programForKey(cc.Macro.SHADER_POSITION_TEXTURE_UCOLOR)); + this.setShaderProgram(cc.shaderCache.programForKey(cc.macro.SHADER_POSITION_TEXTURE_UCOLOR)); return ret; }, diff --git a/extensions/cocostudio/armature/display/CCSkinWebGLRenderCmd.js b/extensions/cocostudio/armature/display/CCSkinWebGLRenderCmd.js index f804e6a3aa..0b5f6ae06a 100644 --- a/extensions/cocostudio/armature/display/CCSkinWebGLRenderCmd.js +++ b/extensions/cocostudio/armature/display/CCSkinWebGLRenderCmd.js @@ -65,7 +65,7 @@ var dy = x1 * sr + y2 * cr2 + y; var locVertexZ = node._vertexZ; - if(!cc.Macro.SPRITEBATCHNODE_RENDER_SUBPIXEL) { + if(!cc.macro.SPRITEBATCHNODE_RENDER_SUBPIXEL) { ax = 0 | ax; ay = 0 | ay; bx = 0 | bx; @@ -106,25 +106,25 @@ cc.glBlendFunc(node._blendFunc.src, node._blendFunc.dst); //optimize performance for javascript cc.glBindTexture2DN(0, locTexture); // = cc.glBindTexture2D(locTexture); - cc.glEnableVertexAttribs(cc.Macro.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); + cc.glEnableVertexAttribs(cc.macro.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); gl.bindBuffer(gl.ARRAY_BUFFER, this._quadWebBuffer); if (this._quadDirty) { gl.bufferData(gl.ARRAY_BUFFER, this._quad.arrayBuffer, gl.DYNAMIC_DRAW); this._quadDirty = false; } - gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 24, 0); //cc.Macro.VERTEX_ATTRIB_POSITION - gl.vertexAttribPointer(1, 4, gl.UNSIGNED_BYTE, true, 24, 12); //cc.Macro.VERTEX_ATTRIB_COLOR - gl.vertexAttribPointer(2, 2, gl.FLOAT, false, 24, 16); //cc.Macro.VERTEX_ATTRIB_TEX_COORDS + gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 24, 0); //cc.macro.VERTEX_ATTRIB_POSITION + gl.vertexAttribPointer(1, 4, gl.UNSIGNED_BYTE, true, 24, 12); //cc.macro.VERTEX_ATTRIB_COLOR + gl.vertexAttribPointer(2, 2, gl.FLOAT, false, 24, 16); //cc.macro.VERTEX_ATTRIB_TEX_COORDS gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); } cc.g_NumberOfDraws++; - if (cc.Macro.SPRITE_DEBUG_DRAW === 0 && !node._showNode) + if (cc.macro.SPRITE_DEBUG_DRAW === 0 && !node._showNode) return; - if (cc.Macro.SPRITE_DEBUG_DRAW === 1 || node._showNode) { + if (cc.macro.SPRITE_DEBUG_DRAW === 1 || node._showNode) { // draw bounding box var locQuad = this._quad; var verticesG1 = [ @@ -134,7 +134,7 @@ cc.p(locQuad.tr.vertices.x, locQuad.tr.vertices.y) ]; cc._drawingUtil.drawPoly(verticesG1, 4, true); - } else if (cc.Macro.SPRITE_DEBUG_DRAW === 2) { + } else if (cc.macro.SPRITE_DEBUG_DRAW === 2) { // draw texture box var drawRectG2 = node.getTextureRect(); var offsetPixG2 = node.getOffsetPosition(); diff --git a/extensions/cocostudio/armature/utils/CCDataReaderHelper.js b/extensions/cocostudio/armature/utils/CCDataReaderHelper.js index 99c837dde9..329382ae6f 100644 --- a/extensions/cocostudio/armature/utils/CCDataReaderHelper.js +++ b/extensions/cocostudio/armature/utils/CCDataReaderHelper.js @@ -847,24 +847,24 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ var blendFunc = frameData.blendFunc; switch (blendType) { case ccs.BLEND_TYPE_NORMAL: - blendFunc.src = cc.Macro.BLEND_SRC; - blendFunc.dst = cc.Macro.BLEND_DST; + blendFunc.src = cc.macro.BLEND_SRC; + blendFunc.dst = cc.macro.BLEND_DST; break; case ccs.BLEND_TYPE_ADD: - blendFunc.src = cc.Macro.SRC_ALPHA; - blendFunc.dst = cc.Macro.ONE; + blendFunc.src = cc.macro.SRC_ALPHA; + blendFunc.dst = cc.macro.ONE; break; case ccs.BLEND_TYPE_MULTIPLY: - blendFunc.src = cc.Macro.DST_COLOR; - blendFunc.dst = cc.Macro.ONE_MINUS_SRC_ALPHA; + blendFunc.src = cc.macro.DST_COLOR; + blendFunc.dst = cc.macro.ONE_MINUS_SRC_ALPHA; break; case ccs.BLEND_TYPE_SCREEN: - blendFunc.src = cc.Macro.ONE; - blendFunc.dst = cc.Macro.ONE_MINUS_DST_COLOR; + blendFunc.src = cc.macro.ONE; + blendFunc.dst = cc.macro.ONE_MINUS_DST_COLOR; break; default: - frameData.blendFunc.src = cc.Macro.BLEND_SRC; - frameData.blendFunc.dst = cc.Macro.BLEND_DST; + frameData.blendFunc.src = cc.macro.BLEND_SRC; + frameData.blendFunc.dst = cc.macro.BLEND_DST; break; } } @@ -937,8 +937,8 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ frameData.tweenEasing = json[ccs.CONST_A_TWEEN_EASING] || ccs.TweenType.LINEAR; frameData.displayIndex = json[ccs.CONST_A_DISPLAY_INDEX]; - var bd_src = json[ccs.CONST_A_BLEND_SRC] == null ? cc.Macro.BLEND_SRC : json[ccs.CONST_A_BLEND_SRC]; - var bd_dst = json[ccs.CONST_A_BLEND_DST] == null ? cc.Macro.BLEND_DST : json[ccs.CONST_A_BLEND_DST]; + var bd_src = json[ccs.CONST_A_BLEND_SRC] == null ? cc.macro.BLEND_SRC : json[ccs.CONST_A_BLEND_SRC]; + var bd_dst = json[ccs.CONST_A_BLEND_DST] == null ? cc.macro.BLEND_DST : json[ccs.CONST_A_BLEND_DST]; frameData.blendFunc.src = bd_src; frameData.blendFunc.dst = bd_dst; frameData.isTween = json[ccs.CONST_A_TWEEN_FRAME] == null ? true : json[ccs.CONST_A_TWEEN_FRAME]; diff --git a/extensions/gui/control-extension/CCControlStepper.js b/extensions/gui/control-extension/CCControlStepper.js index fb0e8c97eb..a94c8c11d9 100644 --- a/extensions/gui/control-extension/CCControlStepper.js +++ b/extensions/gui/control-extension/CCControlStepper.js @@ -221,7 +221,7 @@ cc.ControlStepper = cc.Control.extend(/** @lends cc.ControlStepper# */{ startAutorepeat:function () { this._autorepeatCount = -1; - this.schedule(this.update, cc.AUTOREPEAT_DELTATIME, cc.Macro.REPEAT_FOREVER, cc.AUTOREPEAT_DELTATIME * 3); + this.schedule(this.update, cc.AUTOREPEAT_DELTATIME, cc.macro.REPEAT_FOREVER, cc.AUTOREPEAT_DELTATIME * 3); }, /** Stop the autorepeat. */ diff --git a/extensions/gui/scrollview/CCSorting.js b/extensions/gui/scrollview/CCSorting.js index d9e43b88c1..e0064ccf16 100644 --- a/extensions/gui/scrollview/CCSorting.js +++ b/extensions/gui/scrollview/CCSorting.js @@ -108,7 +108,7 @@ cc.ArrayForObjectSorting = cc._Class.extend(/** @lends cc.ArrayForObjectSorting# } var idx = this.indexOfSortedObject(delObject); - if (idx < this.count() && idx !== cc.Macro.INVALID_INDEX) { + if (idx < this.count() && idx !== cc.macro.INVALID_INDEX) { var foundObj = this.objectAtIndex(idx); if (foundObj.getObjectID() === delObject.getObjectID()) { this.removeObjectAtIndex(idx); @@ -129,7 +129,7 @@ cc.ArrayForObjectSorting = cc._Class.extend(/** @lends cc.ArrayForObjectSorting# */ setObjectID_ofSortedObject:function (tag, setObject) { var idx = this.indexOfSortedObject(setObject); - if (idx < this.count() && idx !== cc.Macro.INVALID_INDEX) { + if (idx < this.count() && idx !== cc.macro.INVALID_INDEX) { var foundObj = this.objectAtIndex(idx); if (foundObj.getObjectID() === setObject.getObjectID()) { this.removeObjectAtIndex(idx); @@ -147,7 +147,7 @@ cc.ArrayForObjectSorting = cc._Class.extend(/** @lends cc.ArrayForObjectSorting# foundObj.setObjectID(tag); var idx = this.indexOfSortedObject(foundObj); - if (idx < this.count() && idx !== cc.Macro.INVALID_INDEX) { + if (idx < this.count() && idx !== cc.macro.INVALID_INDEX) { foundObj = this.objectAtIndex(idx); if (foundObj.getObjectID() !== tag) foundObj = null; @@ -201,7 +201,7 @@ cc.ArrayForObjectSorting = cc._Class.extend(/** @lends cc.ArrayForObjectSorting# idx++; } } else { - idx = cc.Macro.INVALID_INDEX; + idx = cc.macro.INVALID_INDEX; } return idx; }, diff --git a/extensions/gui/scrollview/CCTableView.js b/extensions/gui/scrollview/CCTableView.js index f3992593e5..961fb014a6 100644 --- a/extensions/gui/scrollview/CCTableView.js +++ b/extensions/gui/scrollview/CCTableView.js @@ -65,7 +65,7 @@ cc.TableViewCell = _ccsg.Node.extend(/** @lends cc.TableViewCell# */{ * Cleans up any resources linked to this cell and resets idx property. */ reset:function () { - this._idx = cc.Macro.INVALID_INDEX; + this._idx = cc.macro.INVALID_INDEX; }, setObjectID:function (idx) { @@ -257,7 +257,7 @@ cc.TableView = cc.ScrollView.extend(/** @lends cc.TableView# */{ if (index !== -1) { index = Math.max(0, index); if (index > maxIdx) - index = cc.Macro.INVALID_INDEX; + index = cc.macro.INVALID_INDEX; } return index; }, @@ -428,7 +428,7 @@ cc.TableView = cc.ScrollView.extend(/** @lends cc.TableView# */{ * @param idx index to find a cell */ updateCellAtIndex:function (idx) { - if (idx === cc.Macro.INVALID_INDEX || idx > this._dataSource.numberOfCellsInTableView(this) - 1) + if (idx === cc.macro.INVALID_INDEX || idx > this._dataSource.numberOfCellsInTableView(this) - 1) return; var cell = this.cellAtIndex(idx); @@ -446,7 +446,7 @@ cc.TableView = cc.ScrollView.extend(/** @lends cc.TableView# */{ * @param idx location to insert */ insertCellAtIndex:function (idx) { - if (idx === cc.Macro.INVALID_INDEX || idx > this._dataSource.numberOfCellsInTableView(this) - 1) + if (idx === cc.macro.INVALID_INDEX || idx > this._dataSource.numberOfCellsInTableView(this) - 1) return; var newIdx, locCellsUsed = this._cellsUsed; @@ -474,7 +474,7 @@ cc.TableView = cc.ScrollView.extend(/** @lends cc.TableView# */{ * @param idx index to find a cell */ removeCellAtIndex:function (idx) { - if (idx === cc.Macro.INVALID_INDEX || idx > this._dataSource.numberOfCellsInTableView(this) - 1) + if (idx === cc.macro.INVALID_INDEX || idx > this._dataSource.numberOfCellsInTableView(this) - 1) return; var cell = this.cellAtIndex(idx); @@ -569,7 +569,7 @@ cc.TableView = cc.ScrollView.extend(/** @lends cc.TableView# */{ if (this._vOrdering === cc.TABLEVIEW_FILL_TOPDOWN) offset.y = offset.y + locViewSize.height/locContainer.getScaleY(); var startIdx = this._indexFromOffset(offset); - if (startIdx === cc.Macro.INVALID_INDEX) + if (startIdx === cc.macro.INVALID_INDEX) startIdx = countOfItems - 1; if (this._vOrdering === cc.TABLEVIEW_FILL_TOPDOWN) @@ -579,7 +579,7 @@ cc.TableView = cc.ScrollView.extend(/** @lends cc.TableView# */{ offset.x += locViewSize.width/locContainer.getScaleX(); var endIdx = this._indexFromOffset(offset); - if (endIdx === cc.Macro.INVALID_INDEX) + if (endIdx === cc.macro.INVALID_INDEX) endIdx = countOfItems - 1; var cell, locCellsUsed = this._cellsUsed; @@ -656,7 +656,7 @@ cc.TableView = cc.ScrollView.extend(/** @lends cc.TableView# */{ point = this.getContainer().convertTouchToNodeSpace(touch); index = this._indexFromOffset(point); - if (index === cc.Macro.INVALID_INDEX) + if (index === cc.macro.INVALID_INDEX) this._touchedCell = null; else this._touchedCell = this.cellAtIndex(index); diff --git a/extensions/spine/SGSkeleton.js b/extensions/spine/SGSkeleton.js index d96a50c93a..bc98f63f89 100644 --- a/extensions/spine/SGSkeleton.js +++ b/extensions/spine/SGSkeleton.js @@ -40,7 +40,7 @@ sp._SGSkeleton = _ccsg.Node.extend({ ctor: function(skeletonDataFile, atlasFile, scale) { _ccsg.Node.prototype.ctor.call(this); - this._blendFunc = {src: cc.Macro.BLEND_SRC, dst: cc.Macro.BLEND_DST}; + this._blendFunc = {src: cc.macro.BLEND_SRC, dst: cc.macro.BLEND_DST}; if(arguments.length === 0) this.init(); @@ -58,8 +58,8 @@ sp._SGSkeleton = _ccsg.Node.extend({ init: function () { _ccsg.Node.prototype.init.call(this); //this.setOpacityModifyRGB(true); - this._blendFunc.src = cc.Macro.ONE; - this._blendFunc.dst = cc.Macro.ONE_MINUS_SRC_ALPHA; + this._blendFunc.src = cc.macro.ONE; + this._blendFunc.dst = cc.macro.ONE_MINUS_SRC_ALPHA; this.scheduleUpdate(); }, @@ -148,7 +148,7 @@ sp._SGSkeleton = _ccsg.Node.extend({ * @returns {cc.Rect} */ getBoundingBox: function () { - var minX = cc.Macro.FLT_MAX, minY = cc.Macro.FLT_MAX, maxX = cc.Macro.FLT_MIN, maxY = cc.Macro.FLT_MIN; + var minX = cc.macro.FLT_MAX, minY = cc.macro.FLT_MAX, maxX = cc.macro.FLT_MIN, maxY = cc.macro.FLT_MIN; var scaleX = this.getScaleX(), scaleY = this.getScaleY(), vertices = [], slots = this._skeleton.slots, VERTEX = sp.VERTEX_INDEX; diff --git a/extensions/spine/SGSkeletonWebGLRenderCmd.js b/extensions/spine/SGSkeletonWebGLRenderCmd.js index ee25a0a327..e611be7e07 100644 --- a/extensions/spine/SGSkeletonWebGLRenderCmd.js +++ b/extensions/spine/SGSkeletonWebGLRenderCmd.js @@ -28,7 +28,7 @@ var spine = sp.spine; sp._SGSkeleton.WebGLRenderCmd = function (renderableObject) { _ccsg.Node.WebGLRenderCmd.call(this, renderableObject); this._needDraw = true; - this.setShaderProgram(cc.shaderCache.programForKey(cc.Macro.SHADER_POSITION_TEXTURECOLOR)); + this.setShaderProgram(cc.shaderCache.programForKey(cc.macro.SHADER_POSITION_TEXTURECOLOR)); this._tmpQuad = new cc.V3F_C4B_T2F_Quad(); }; @@ -86,13 +86,13 @@ proto.rendering = function (ctx) { blendMode = slot.data.blendMode; switch (blendMode) { case spine.BlendMode.additive: - cc.glBlendFunc(premultiAlpha ? cc.Macro.ONE : cc.Macro.SRC_ALPHA, cc.Macro.ONE); + cc.glBlendFunc(premultiAlpha ? cc.macro.ONE : cc.macro.SRC_ALPHA, cc.macro.ONE); break; case spine.BlendMode.multiply: - cc.glBlendFunc(cc.Macro.DST_COLOR, cc.Macro.ONE_MINUS_SRC_ALPHA); + cc.glBlendFunc(cc.macro.DST_COLOR, cc.macro.ONE_MINUS_SRC_ALPHA); break; case spine.BlendMode.screen: - cc.glBlendFunc(cc.Macro.ONE, cc.Macro.ONE_MINUS_SRC_COLOR); + cc.glBlendFunc(cc.macro.ONE, cc.macro.ONE_MINUS_SRC_COLOR); break; default: cc.glBlendFunc(locBlendFunc.src, locBlendFunc.dst); diff --git a/external/gaf/Library/GAFShaderManager.js b/external/gaf/Library/GAFShaderManager.js index d630fa7221..1de8a28667 100644 --- a/external/gaf/Library/GAFShaderManager.js +++ b/external/gaf/Library/GAFShaderManager.js @@ -14,9 +14,9 @@ gaf._glShaderInit = function() { var program = new cc.GLProgram(); var result = program.initWithVertexShaderByteArray(vs, fs); cc.assert(result, "Shader init error"); - program.addAttribute(cc.Macro.ATTRIBUTE_NAME_POSITION, cc.Macro.VERTEX_ATTRIB_POSITION); - program.addAttribute(cc.Macro.ATTRIBUTE_NAME_COLOR, cc.Macro.VERTEX_ATTRIB_COLOR); - program.addAttribute(cc.Macro.ATTRIBUTE_NAME_TEX_COORD, cc.Macro.VERTEX_ATTRIB_TEX_COORDS); + program.addAttribute(cc.macro.ATTRIBUTE_NAME_POSITION, cc.macro.VERTEX_ATTRIB_POSITION); + program.addAttribute(cc.macro.ATTRIBUTE_NAME_COLOR, cc.macro.VERTEX_ATTRIB_COLOR); + program.addAttribute(cc.macro.ATTRIBUTE_NAME_TEX_COORD, cc.macro.VERTEX_ATTRIB_TEX_COORDS); result = program.link(); cc.assert(result, "Shader linking error"); program.updateUniforms(); diff --git a/external/gaf/Library/GAFSpriteWebGLRenderCmd.js b/external/gaf/Library/GAFSpriteWebGLRenderCmd.js index 127d2a7f6a..de1f92b8d3 100644 --- a/external/gaf/Library/GAFSpriteWebGLRenderCmd.js +++ b/external/gaf/Library/GAFSpriteWebGLRenderCmd.js @@ -2,7 +2,7 @@ (function(){ gaf.Sprite.WebGLRenderCmd = function (renderable) { _ccsg.Sprite.WebGLRenderCmd.call(this, renderable); - this._defualtShader = cc.shaderCache.programForKey(cc.Macro.SHADER_POSITION_TEXTURECOLOR); + this._defualtShader = cc.shaderCache.programForKey(cc.macro.SHADER_POSITION_TEXTURECOLOR); this._customShader = gaf._Shaders.Alpha; //this._shaderProgram = this._defualtShader; diff --git a/test/visual-tests/src/ClippingNodeTest/ClippingNodeTest.js b/test/visual-tests/src/ClippingNodeTest/ClippingNodeTest.js index 9f8e5e4dff..7c307790ed 100644 --- a/test/visual-tests/src/ClippingNodeTest/ClippingNodeTest.js +++ b/test/visual-tests/src/ClippingNodeTest/ClippingNodeTest.js @@ -620,8 +620,8 @@ var RawStencilBufferTest4 = RawStencilBufferTest.extend({ this._super(plane); gl.depthMask(false); - var program = cc.shaderCache.programForKey(cc.Macro.SHADER_POSITION_TEXTURECOLORALPHATEST); - var alphaValueLocation = gl.getUniformLocation(program.getProgram(),cc.Macro.UNIFORM_ALPHA_TEST_VALUE_S); + var program = cc.shaderCache.programForKey(cc.macro.SHADER_POSITION_TEXTURECOLORALPHATEST); + var alphaValueLocation = gl.getUniformLocation(program.getProgram(),cc.macro.UNIFORM_ALPHA_TEST_VALUE_S); cc.glUseProgram(program.getProgram()); program.setUniformLocationWith1f(alphaValueLocation, _alphaThreshold); this._sprite.shaderProgram = program; @@ -644,8 +644,8 @@ var RawStencilBufferTest5 = RawStencilBufferTest.extend({ gl.disable(gl.DEPTH_TEST); gl.depthMask(false); - var program = cc.shaderCache.programForKey(cc.Macro.SHADER_POSITION_TEXTURECOLORALPHATEST); - var alphaValueLocation = gl.getUniformLocation(program.getProgram(), cc.Macro.UNIFORM_ALPHA_TEST_VALUE_S); + var program = cc.shaderCache.programForKey(cc.macro.SHADER_POSITION_TEXTURECOLORALPHATEST); + var alphaValueLocation = gl.getUniformLocation(program.getProgram(), cc.macro.UNIFORM_ALPHA_TEST_VALUE_S); cc.glUseProgram(program.getProgram()); program.setUniformLocationWith1f(alphaValueLocation, _alphaThreshold); this._sprite.shaderProgram = program; @@ -680,8 +680,8 @@ var RawStencilBufferTest6 = RawStencilBufferTest.extend({ gl.disable(gl.DEPTH_TEST); gl.depthMask(false); - var program = cc.shaderCache.programForKey(cc.Macro.SHADER_POSITION_TEXTURECOLORALPHATEST); - var alphaValueLocation = gl.getUniformLocation(program.getProgram(), cc.Macro.UNIFORM_ALPHA_TEST_VALUE_S); + var program = cc.shaderCache.programForKey(cc.macro.SHADER_POSITION_TEXTURECOLORALPHATEST); + var alphaValueLocation = gl.getUniformLocation(program.getProgram(), cc.macro.UNIFORM_ALPHA_TEST_VALUE_S); cc.glUseProgram(program.getProgram()); program.setUniformLocationWith1f(alphaValueLocation, _alphaThreshold); this._sprite.shaderProgram = program; diff --git a/test/visual-tests/src/CocosNodeTest/CocosNodeTest.js b/test/visual-tests/src/CocosNodeTest/CocosNodeTest.js index f11089f687..fa9cb14caf 100644 --- a/test/visual-tests/src/CocosNodeTest/CocosNodeTest.js +++ b/test/visual-tests/src/CocosNodeTest/CocosNodeTest.js @@ -740,7 +740,7 @@ var NodeOpaqueTest = TestNodeDemo.extend({ var background; for (var i = 0; i < 50; i++) { background = new _ccsg.Sprite(s_back1); - background.setBlendFunc(cc.Macro.ONE, cc.Macro.ONE_MINUS_SRC_ALPHA); + background.setBlendFunc(cc.macro.ONE, cc.macro.ONE_MINUS_SRC_ALPHA); background.x = winSize.width / 2; background.y = winSize.height / 2; this.addChild(background); @@ -765,7 +765,7 @@ var NodeNonOpaqueTest = TestNodeDemo.extend({ var background; for (var i = 0; i < 50; i++) { background = new _ccsg.Sprite(s_back1); - background.setBlendFunc(cc.Macro.ONE, cc.Macro.ZERO); + background.setBlendFunc(cc.macro.ONE, cc.macro.ZERO); background.x = winSize.width / 2; background.y = winSize.height / 2; this.addChild(background); diff --git a/test/visual-tests/src/LabelTest/LabelTest.js b/test/visual-tests/src/LabelTest/LabelTest.js index 883fa2fe37..dd18e17111 100644 --- a/test/visual-tests/src/LabelTest/LabelTest.js +++ b/test/visual-tests/src/LabelTest/LabelTest.js @@ -2006,11 +2006,11 @@ var WrapAlgorithmTest = AtlasDemo.extend({ }, onEnter: function(){ this._super(); - cc.Macro.SPRITE_DEBUG_DRAW = 1; + cc.macro.SPRITE_DEBUG_DRAW = 1; }, onExit: function(){ this._super(); - cc.Macro.SPRITE_DEBUG_DRAW = 0; + cc.macro.SPRITE_DEBUG_DRAW = 0; } }); diff --git a/test/visual-tests/src/LayerTest/LayerTest.js b/test/visual-tests/src/LayerTest/LayerTest.js index e73f979a73..d61faa9f7a 100644 --- a/test/visual-tests/src/LayerTest/LayerTest.js +++ b/test/visual-tests/src/LayerTest/LayerTest.js @@ -428,11 +428,11 @@ var LayerTestBlend = LayerTest.extend({ var dst; if (this._blend) { - src = cc.Macro.SRC_ALPHA; - dst = cc.Macro.ONE_MINUS_SRC_ALPHA; + src = cc.macro.SRC_ALPHA; + dst = cc.macro.ONE_MINUS_SRC_ALPHA; } else { - src = cc.Macro.ONE_MINUS_DST_COLOR; - dst = cc.Macro.ZERO; + src = cc.macro.ONE_MINUS_DST_COLOR; + dst = cc.macro.ZERO; } layer.setBlendFunc( src, dst ); this._blend = ! this._blend; diff --git a/test/visual-tests/src/OpenGLTest/OpenGLTest.js b/test/visual-tests/src/OpenGLTest/OpenGLTest.js index 510321b8f5..4fba806585 100644 --- a/test/visual-tests/src/OpenGLTest/OpenGLTest.js +++ b/test/visual-tests/src/OpenGLTest/OpenGLTest.js @@ -458,23 +458,23 @@ var GLNodeCCAPITest = OpenGLTestLayer.extend({ this.shader.use(); this.shader.setUniformsForBuiltins(); - cc.glEnableVertexAttribs( cc.Macro.VERTEX_ATTRIB_FLAG_COLOR | cc.Macro.VERTEX_ATTRIB_FLAG_POSITION); + cc.glEnableVertexAttribs( cc.macro.VERTEX_ATTRIB_FLAG_COLOR | cc.macro.VERTEX_ATTRIB_FLAG_POSITION); // Draw fullscreen Square gl.bindBuffer(gl.ARRAY_BUFFER, this.squareVertexPositionBuffer); - gl.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0); + gl.vertexAttribPointer(cc.macro.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0); gl.bindBuffer(gl.ARRAY_BUFFER, this.squareVertexColorBuffer); - gl.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_COLOR, 4, gl.FLOAT, false, 0, 0); + gl.vertexAttribPointer(cc.macro.VERTEX_ATTRIB_COLOR, 4, gl.FLOAT, false, 0, 0); gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); // Draw fullscreen Triangle gl.bindBuffer(gl.ARRAY_BUFFER, this.triangleVertexPositionBuffer); - gl.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0); + gl.vertexAttribPointer(cc.macro.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0); gl.bindBuffer(gl.ARRAY_BUFFER, this.triangleVertexColorBuffer); - gl.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_COLOR, 4, gl.FLOAT, false, 0, 0); + gl.vertexAttribPointer(cc.macro.VERTEX_ATTRIB_COLOR, 4, gl.FLOAT, false, 0, 0); gl.drawArrays(gl.TRIANGLE_STRIP, 0, 3); @@ -574,7 +574,7 @@ var ShaderNode = cc.GLNode.extend({ this.shader = cc.GLProgram.create(vertexShader, framentShader); this.shader.retain(); - this.shader.addAttribute("aVertex", cc.Macro.VERTEX_ATTRIB_POSITION); + this.shader.addAttribute("aVertex", cc.macro.VERTEX_ATTRIB_POSITION); this.shader.link(); this.shader.updateUniforms(); @@ -604,11 +604,11 @@ var ShaderNode = cc.GLNode.extend({ this.shader.setUniformLocationF32( this.uniformCenter, centerx, centery); this.shader.setUniformLocationF32( this.uniformResolution, 256, 256); - cc.glEnableVertexAttribs( cc.Macro.VERTEX_ATTRIB_FLAG_POSITION ); + cc.glEnableVertexAttribs( cc.macro.VERTEX_ATTRIB_FLAG_POSITION ); // Draw fullscreen Square gl.bindBuffer(gl.ARRAY_BUFFER, this.squareVertexPositionBuffer); - gl.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0); + gl.vertexAttribPointer(cc.macro.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0); gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); gl.bindBuffer(gl.ARRAY_BUFFER, null); @@ -879,9 +879,9 @@ var ShaderOutlineEffect = OpenGLTestLayer.extend({ } else{ this.shader = new cc.GLProgram("res/Shaders/example_Outline.vsh", "res/Shaders/example_Outline.fsh"); - this.shader.addAttribute(cc.Macro.ATTRIBUTE_NAME_POSITION, cc.Macro.VERTEX_ATTRIB_POSITION); - this.shader.addAttribute(cc.Macro.ATTRIBUTE_NAME_TEX_COORD, cc.Macro.VERTEX_ATTRIB_TEX_COORDS); - this.shader.addAttribute(cc.Macro.ATTRIBUTE_NAME_COLOR, cc.Macro.VERTEX_ATTRIB_COLOR); + this.shader.addAttribute(cc.macro.ATTRIBUTE_NAME_POSITION, cc.macro.VERTEX_ATTRIB_POSITION); + this.shader.addAttribute(cc.macro.ATTRIBUTE_NAME_TEX_COORD, cc.macro.VERTEX_ATTRIB_TEX_COORDS); + this.shader.addAttribute(cc.macro.ATTRIBUTE_NAME_COLOR, cc.macro.VERTEX_ATTRIB_COLOR); this.shader.link(); this.shader.updateUniforms(); @@ -950,8 +950,8 @@ var ShaderRetroEffect = OpenGLTestLayer.extend({ if( 'opengl' in cc.sys.capabilities ) { var program = new cc.GLProgram("res/Shaders/example_ColorBars.vsh", "res/Shaders/example_ColorBars.fsh"); - program.addAttribute(cc.Macro.ATTRIBUTE_NAME_POSITION, cc.Macro.VERTEX_ATTRIB_POSITION); - program.addAttribute(cc.Macro.ATTRIBUTE_NAME_TEX_COORD, cc.Macro.VERTEX_ATTRIB_TEX_COORDS); + program.addAttribute(cc.macro.ATTRIBUTE_NAME_POSITION, cc.macro.VERTEX_ATTRIB_POSITION); + program.addAttribute(cc.macro.ATTRIBUTE_NAME_TEX_COORD, cc.macro.VERTEX_ATTRIB_TEX_COORDS); program.link(); program.updateUniforms(); @@ -1088,14 +1088,14 @@ var TexImage2DTest = OpenGLTestLayer.extend({ this.shader.setUniformsForBuiltins(); gl.bindTexture(gl.TEXTURE_2D, this.my_texture); - cc.glEnableVertexAttribs( cc.Macro.VERTEX_ATTRIB_FLAG_TEX_COORDS | cc.Macro.VERTEX_ATTRIB_FLAG_POSITION); + cc.glEnableVertexAttribs( cc.macro.VERTEX_ATTRIB_FLAG_TEX_COORDS | cc.macro.VERTEX_ATTRIB_FLAG_POSITION); // Draw fullscreen Square gl.bindBuffer(gl.ARRAY_BUFFER, this.squareVertexPositionBuffer); - gl.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0); + gl.vertexAttribPointer(cc.macro.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0); gl.bindBuffer(gl.ARRAY_BUFFER, this.squareVertexTextureBuffer); - gl.vertexAttribPointer(cc.Macro.VERTEX_ATTRIB_TEX_COORDS, 2, gl.FLOAT, false, 0, 0); + gl.vertexAttribPointer(cc.macro.VERTEX_ATTRIB_TEX_COORDS, 2, gl.FLOAT, false, 0, 0); gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); diff --git a/test/visual-tests/src/SchedulerTest/SchedulerTest.js b/test/visual-tests/src/SchedulerTest/SchedulerTest.js index 050f7be692..916208139f 100644 --- a/test/visual-tests/src/SchedulerTest/SchedulerTest.js +++ b/test/visual-tests/src/SchedulerTest/SchedulerTest.js @@ -496,7 +496,7 @@ var ScheduleUsingSchedulerTest = SchedulerTestLayer.extend({ scheduler.scheduleUpdateForTarget(this, priority, paused); var interval = 0.25; // every 1/4 of second - var repeat = cc.Macro.REPEAT_FOREVER; // how many repeats. cc.Macro.REPEAT_FOREVER means forever + var repeat = cc.macro.REPEAT_FOREVER; // how many repeats. cc.macro.REPEAT_FOREVER means forever var delay = 2; // start after 2 seconds; paused = false; // not paused. queue it now. scheduler.scheduleCallbackForTarget(this, this.onSchedUpdate, interval, repeat, delay, paused); diff --git a/test/visual-tests/src/SpriteTest/SpriteTest.js b/test/visual-tests/src/SpriteTest/SpriteTest.js index ef6e0606bf..cd15652482 100644 --- a/test/visual-tests/src/SpriteTest/SpriteTest.js +++ b/test/visual-tests/src/SpriteTest/SpriteTest.js @@ -994,7 +994,7 @@ var SpriteZVertex = SpriteTestDemo.extend({ // var alphaTestShader = cc.shaderCache.getProgram("ShaderPositionTextureColorAlphaTest"); var glprogram = alphaTestShader.getProgram(); - var alphaValueLocation = gl.getUniformLocation(glprogram, cc.Macro.UNIFORM_ALPHA_TEST_VALUE_S); + var alphaValueLocation = gl.getUniformLocation(glprogram, cc.macro.UNIFORM_ALPHA_TEST_VALUE_S); // set alpha test value // NOTE: alpha test shader is hard-coded to use the equivalent of a glAlphaFunc(GL_GREATER) comparison @@ -1118,7 +1118,7 @@ var SpriteBatchNodeZVertex = SpriteTestDemo.extend({ // var alphaTestShader = cc.shaderCache.getProgram("ShaderPositionTextureColorAlphaTest"); var glprogram = alphaTestShader.getProgram(); - var alphaValueLocation = gl.getUniformLocation(glprogram, cc.Macro.UNIFORM_ALPHA_TEST_VALUE_S); + var alphaValueLocation = gl.getUniformLocation(glprogram, cc.macro.UNIFORM_ALPHA_TEST_VALUE_S); // set alpha test value // NOTE: alpha test shader is hard-coded to use the equivalent of a glAlphaFunc(GL_GREATER) comparison @@ -5200,7 +5200,7 @@ var TextureRotatedSpriteFrame = SpriteTestDemo.extend({ var SpriteWithRepeatingTexture = SpriteTestDemo.extend({ _title:"Sprite with Repeating texture", - _subtitle:"aTexture.setTexParameters(cc.Macro.LINEAR, cc.Macro.LINEAR, cc.Texture2D.WrapMode.REPEAT, cc.Texture2D.WrapMode.REPEAT);", + _subtitle:"aTexture.setTexParameters(cc.macro.LINEAR, cc.macro.LINEAR, cc.Texture2D.WrapMode.REPEAT, cc.Texture2D.WrapMode.REPEAT);", ctor:function () { //----start58----ctor @@ -5212,7 +5212,7 @@ var SpriteWithRepeatingTexture = SpriteTestDemo.extend({ block.setTextureRect(cc.rect(0,0, 320,240)); block.setPosition(x, y); - block.getTexture().setTexParameters(cc.Macro.LINEAR, cc.Macro.LINEAR, cc.Texture2D.WrapMode.REPEAT, cc.Texture2D.WrapMode.REPEAT); + block.getTexture().setTexParameters(cc.macro.LINEAR, cc.macro.LINEAR, cc.Texture2D.WrapMode.REPEAT, cc.Texture2D.WrapMode.REPEAT); this.addChild(block); //----end58---- } @@ -5227,8 +5227,8 @@ var SpriteBlendFuncTest = SpriteTestDemo.extend({ //----start59----ctor this._super(); - var destFactors = [cc.Macro.ZERO, cc.Macro.ONE, cc.Macro.DST_COLOR, cc.Macro.ONE_MINUS_DST_COLOR, cc.Macro.DST_ALPHA, cc.Macro.ONE_MINUS_DST_ALPHA], - srcFactors = [cc.Macro.ZERO, cc.Macro.ONE, cc.Macro.SRC_COLOR, cc.Macro.ONE_MINUS_SRC_COLOR, cc.Macro.SRC_ALPHA, cc.Macro.ONE_MINUS_SRC_ALPHA]; + var destFactors = [cc.macro.ZERO, cc.macro.ONE, cc.macro.DST_COLOR, cc.macro.ONE_MINUS_DST_COLOR, cc.macro.DST_ALPHA, cc.macro.ONE_MINUS_DST_ALPHA], + srcFactors = [cc.macro.ZERO, cc.macro.ONE, cc.macro.SRC_COLOR, cc.macro.ONE_MINUS_SRC_COLOR, cc.macro.SRC_ALPHA, cc.macro.ONE_MINUS_SRC_ALPHA]; var destTitles = ["ZERO", "ONE", "DST_COLOR", "ONE_MINUS_DST_COLOR", "DST_ALPHA", "ONE_MINUS_DST_ALPHA"], srcTitles = ["ZERO", "ONE", "SRC_COLOR", "ONE_MINUS_SRC_COLOR", "SRC_ALPHA", "ONE_MINUS_SRC_ALPHA"];