Skip to content

Commit

Permalink
Refactor cc.Macro to cc.macro
Browse files Browse the repository at this point in the history
  • Loading branch information
pandamicro committed Mar 14, 2016
1 parent 6a3bc53 commit 1d8a6f2
Show file tree
Hide file tree
Showing 79 changed files with 809 additions and 804 deletions.
4 changes: 2 additions & 2 deletions cocos2d/actions/CCActionCamera.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion cocos2d/actions/CCActionCatmullRom.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions cocos2d/actions/CCActionInterval.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions cocos2d/clipping-nodes/CCClippingNodeWebGLRenderCmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion cocos2d/core/CCCamera.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
4 changes: 2 additions & 2 deletions cocos2d/core/CCConfiguration.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
},

Expand Down Expand Up @@ -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("")
Expand Down
4 changes: 2 additions & 2 deletions cocos2d/core/CCDirectorWebGL.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
};

Expand Down
4 changes: 2 additions & 2 deletions cocos2d/core/CCDrawingPrimitivesCanvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
40 changes: 21 additions & 19 deletions cocos2d/core/CCDrawingPrimitivesWebGL.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
THE SOFTWARE.
****************************************************************************/

var macro = cc.macro;

/**
* Canvas of DrawingPrimitive implement version use for WebGlMode
* @class
Expand Down Expand Up @@ -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");

Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down
8 changes: 4 additions & 4 deletions cocos2d/core/CCScheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(){
Expand Down Expand Up @@ -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.<br/>
* If 'interval' is 0, it will be called every frame, but if so, it recommended to use 'scheduleUpdateForTarget:' instead.<br/>
* If the callback function is already scheduled, then only the interval parameter will be updated without re-scheduling it again.<br/>
* repeat let the action be repeated repeat + 1 times, use cc.Macro.REPEAT_FOREVER to let the action run continuously<br/>
* repeat let the action be repeated repeat + 1 times, use cc.macro.REPEAT_FOREVER to let the action run continuously<br/>
* delay is the amount of time the action will wait before it'll start<br/>
* </p>
* @method scheduleCallbackForTarget
Expand Down Expand Up @@ -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;
}
}
Expand Down
2 changes: 1 addition & 1 deletion cocos2d/core/base-nodes/CCAtlasNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
},
Expand Down
10 changes: 5 additions & 5 deletions cocos2d/core/base-nodes/CCAtlasNodeWebGLRenderCmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
};

Expand All @@ -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;
}
};

Expand Down Expand Up @@ -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]);
Expand Down
Loading

0 comments on commit 1d8a6f2

Please sign in to comment.