From faade239021c8cad02926384d0a355fd13c31714 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Thu, 10 Apr 2014 16:11:29 +0800 Subject: [PATCH 1/4] REFixed #4706: Fixed IE incompatible issue with __lookupGetter__ --- cocos2d/core/platform/CCClass.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cocos2d/core/platform/CCClass.js b/cocos2d/core/platform/CCClass.js index fa4c3e4a5f..fa61107aae 100644 --- a/cocos2d/core/platform/CCClass.js +++ b/cocos2d/core/platform/CCClass.js @@ -252,7 +252,12 @@ cc.defineGetterSetter = function (proto, prop, getter, setter, getterName, sette var hasGetter = (getter != null), hasSetter = (setter != undefined), props = Object.getOwnPropertyNames(proto); for (var i = 0; i < props.length; i++) { var name = props[i]; - if( proto.__lookupGetter__(name) || typeof proto[name] !== "function" ) continue; + + if( (Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(proto, name) + : proto.__lookupGetter__(name)) + || typeof proto[name] !== "function" ) + continue; + var func = proto[name]; if (hasGetter && func === getter) { getterName = name; From 91de1f0d712365a21658d2342eb3811f8826f649 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Thu, 10 Apr 2014 22:06:51 +0800 Subject: [PATCH 2/4] Issue #4580: Fix CONSTANTS inconsistence between h5 and JSB --- cocos2d/core/CCDirector.js | 98 +++----- cocos2d/core/CCDirectorWebGL.js | 6 +- cocos2d/core/platform/CCMacro.js | 287 ++++++++++++++++++++++ cocos2d/core/sprites/CCSprite.js | 28 +-- cocos2d/core/sprites/SpritesWebGL.js | 2 +- cocos2d/menus/CCMenuItem.js | 41 ---- cocos2d/render-texture/CCRenderTexture.js | 2 +- cocos2d/shaders/CCGLProgram.js | 175 ------------- cocos2d/shaders/CCGLStateCache.js | 34 --- 9 files changed, 332 insertions(+), 341 deletions(-) diff --git a/cocos2d/core/CCDirector.js b/cocos2d/core/CCDirector.js index 63b8b6abea..e4f4742815 100644 --- a/cocos2d/core/CCDirector.js +++ b/cocos2d/core/CCDirector.js @@ -24,75 +24,8 @@ THE SOFTWARE. ****************************************************************************/ -//Possible OpenGL projections used by director -/** - * sets a 2D projection (orthogonal projection) - * @constant - * @type Number - */ -cc.DIRECTOR_PROJECTION_2D = 0; - cc.g_NumberOfDraws = 0; -/** - * sets a 3D projection with a fovy=60, znear=0.5f and zfar=1500. - * @constant - * @type Number - */ -cc.DIRECTOR_PROJECTION_3D = 1; - -/** - * it calls "updateProjection" on the projection delegate. - * @constant - * @type Number - */ -cc.DIRECTOR_PROJECTION_CUSTOM = 3; - -/** - * Default projection is 3D projection - * @constant - * @type Number - */ -cc.DIRECTOR_PROJECTION_DEFAULT = cc.DIRECTOR_PROJECTION_3D; - -//---------------------------------------------------------------------------------------------------------------------- -//Possible device orientations -/** - * Device oriented vertically, home button on the bottom (UIDeviceOrientationPortrait) - * @constant - * @type Number - */ -cc.DEVICE_ORIENTATION_PORTRAIT = 0; - -/** - * Device oriented horizontally, home button on the right (UIDeviceOrientationLandscapeLeft) - * @constant - * @type Number - */ -cc.DEVICE_ORIENTATION_LANDSCAPE_LEFT = 1; - -/** - * Device oriented vertically, home button on the top (UIDeviceOrientationPortraitUpsideDown) - * @constant - * @type Number - */ -cc.DEVICE_ORIENTATION_PORTRAIT_UPSIDE_DOWN = 2; - -/** - * Device oriented horizontally, home button on the left (UIDeviceOrientationLandscapeRight) - * @constant - * @type Number - */ -cc.DEVICE_ORIENTATION_LANDSCAPE_RIGHT = 3; - -/** - * In browsers, we only support 2 orientations by change window size. - * @constant - * @type Number - */ -cc.DEVICE_MAX_ORIENTATIONS = 2; - - cc.GLToClipTransform = function (transformOut) { var projection = new cc.kmMat4(); cc.kmGLGetMatrix(cc.KM_GL_PROJECTION, projection); @@ -197,7 +130,7 @@ cc.Director = cc.Class.extend(/** @lends cc.director# */{ this._oldAnimationInterval = this._animationInterval = 1.0 / cc.defaultFPS; this._scenesStack = []; // Set default projection (3D) - this._projection = cc.DIRECTOR_PROJECTION_DEFAULT; + this._projection = cc.Director.PROJECTION_DEFAULT; // projection delegate if "Custom" projection is used this._projectionDelegate = null; @@ -868,6 +801,35 @@ cc.Director._getInstance = function () { */ cc.defaultFPS = 60; +//Possible OpenGL projections used by director +/** + * sets a 2D projection (orthogonal projection) + * @constant + * @type Number + */ +cc.Director.PROJECTION_2D = 0; + +/** + * sets a 3D projection with a fovy=60, znear=0.5f and zfar=1500. + * @constant + * @type Number + */ +cc.Director.PROJECTION_3D = 1; + +/** + * it calls "updateProjection" on the projection delegate. + * @constant + * @type Number + */ +cc.Director.PROJECTION_CUSTOM = 3; + +/** + * Default projection is 3D projection + * @constant + * @type Number + */ +cc.Director.PROJECTION_DEFAULT = cc.Director.PROJECTION_3D; + if (cc._renderType === cc._RENDER_TYPE_CANVAS) { var _p = cc.Director.prototype; diff --git a/cocos2d/core/CCDirectorWebGL.js b/cocos2d/core/CCDirectorWebGL.js index 617cbfde42..19208ca638 100644 --- a/cocos2d/core/CCDirectorWebGL.js +++ b/cocos2d/core/CCDirectorWebGL.js @@ -49,7 +49,7 @@ if (cc._renderType === cc._RENDER_TYPE_WEBGL) { _t.setViewport(); switch (projection) { - case cc.DIRECTOR_PROJECTION_2D: + case cc.Director.PROJECTION_2D: cc.kmGLMatrixMode(cc.KM_GL_PROJECTION); cc.kmGLLoadIdentity(); var orthoMatrix = new cc.kmMat4(); @@ -58,7 +58,7 @@ if (cc._renderType === cc._RENDER_TYPE_WEBGL) { cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); cc.kmGLLoadIdentity(); break; - case cc.DIRECTOR_PROJECTION_3D: + case cc.Director.PROJECTION_3D: var zeye = _t.getZEye(); var matrixPerspective = new cc.kmMat4(), matrixLookup = new cc.kmMat4(); cc.kmGLMatrixMode(cc.KM_GL_PROJECTION); @@ -77,7 +77,7 @@ if (cc._renderType === cc._RENDER_TYPE_WEBGL) { cc.kmMat4LookAt(matrixLookup, eye, center, up); cc.kmGLMultMatrix(matrixLookup); break; - case cc.DIRECTOR_PROJECTION_CUSTOM: + case cc.Director.PROJECTION_CUSTOM: if (_t._projectionDelegate) _t._projectionDelegate.updateProjection(); break; diff --git a/cocos2d/core/platform/CCMacro.js b/cocos2d/core/platform/CCMacro.js index ff68d5e53d..16a82fc979 100644 --- a/cocos2d/core/platform/CCMacro.js +++ b/cocos2d/core/platform/CCMacro.js @@ -414,3 +414,290 @@ cc.checkGLErrorDebug = function () { } } }; + +//Possible device orientations +/** + * Device oriented vertically, home button on the bottom (UIDeviceOrientationPortrait) + * @constant + * @type Number + */ +cc.DEVICE_ORIENTATION_PORTRAIT = 0; + +/** + * Device oriented horizontally, home button on the right (UIDeviceOrientationLandscapeLeft) + * @constant + * @type Number + */ +cc.DEVICE_ORIENTATION_LANDSCAPE_LEFT = 1; + +/** + * Device oriented vertically, home button on the top (UIDeviceOrientationPortraitUpsideDown) + * @constant + * @type Number + */ +cc.DEVICE_ORIENTATION_PORTRAIT_UPSIDE_DOWN = 2; + +/** + * Device oriented horizontally, home button on the left (UIDeviceOrientationLandscapeRight) + * @constant + * @type Number + */ +cc.DEVICE_ORIENTATION_LANDSCAPE_RIGHT = 3; + +/** + * In browsers, we only support 2 orientations by change window size. + * @constant + * @type Number + */ +cc.DEVICE_MAX_ORIENTATIONS = 2; + + +// ------------------- vertex attrib flags ----------------------------- +/** + * @constant + * @type {Number} + */ +cc.VERTEX_ATTRIB_FLAG_NONE = 0; +/** + * @constant + * @type {Number} + */ +cc.VERTEX_ATTRIB_FLAG_POSITION = 1 << 0; +/** + * @constant + * @type {Number} + */ +cc.VERTEX_ATTRIB_FLAG_COLOR = 1 << 1; +/** + * @constant + * @type {Number} + */ +cc.VERTEX_ATTRIB_FLAG_TEX_COORDS = 1 << 2; +/** + * @constant + * @type {Number} + */ +cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX = ( cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_COLOR | cc.VERTEX_ATTRIB_FLAG_TEX_COORDS ); + +/** + * GL server side states + * @constant + * @type {Number} + */ +cc.GL_ALL = 0; + +//-------------Vertex Attributes----------- +/** + * @constant + * @type {Number} + */ +cc.VERTEX_ATTRIB_POSITION = 0; +/** + * @constant + * @type {Number} + */ +cc.VERTEX_ATTRIB_COLOR = 1; +/** + * @constant + * @type {Number} + */ +cc.VERTEX_ATTRIB_TEX_COORDS = 2; +/** + * @constant + * @type {Number} + */ +cc.VERTEX_ATTRIB_MAX = 3; + +//------------Uniforms------------------ +/** + * @constant + * @type {Number} + */ +cc.UNIFORM_PMATRIX = 0; +/** + * @constant + * @type {Number} + */ +cc.UNIFORM_MVMATRIX = 1; +/** + * @constant + * @type {Number} + */ +cc.UNIFORM_MVPMATRIX = 2; +/** + * @constant + * @type {Number} + */ +cc.UNIFORM_TIME = 3; +/** + * @constant + * @type {Number} + */ +cc.UNIFORM_SINTIME = 4; +/** + * @constant + * @type {Number} + */ +cc.UNIFORM_COSTIME = 5; +/** + * @constant + * @type {Number} + */ +cc.UNIFORM_RANDOM01 = 6; +/** + * @constant + * @type {Number} + */ +cc.UNIFORM_SAMPLER = 7; +/** + * @constant + * @type {Number} + */ +cc.UNIFORM_MAX = 8; + +//------------Shader Name--------------- +/** + * @constant + * @type {String} + */ +cc.SHADER_POSITION_TEXTURECOLOR = "ShaderPositionTextureColor"; +/** + * @constant + * @type {String} + */ +cc.SHADER_POSITION_TEXTURECOLORALPHATEST = "ShaderPositionTextureColorAlphaTest"; +/** + * @constant + * @type {String} + */ +cc.SHADER_POSITION_COLOR = "ShaderPositionColor"; +/** + * @constant + * @type {String} + */ +cc.SHADER_POSITION_TEXTURE = "ShaderPositionTexture"; +/** + * @constant + * @type {String} + */ +cc.SHADER_POSITION_TEXTURE_UCOLOR = "ShaderPositionTexture_uColor"; +/** + * @constant + * @type {String} + */ +cc.SHADER_POSITION_TEXTUREA8COLOR = "ShaderPositionTextureA8Color"; +/** + * @constant + * @type {String} + */ +cc.SHADER_POSITION_UCOLOR = "ShaderPosition_uColor"; +/** + * @constant + * @type {String} + */ +cc.SHADER_POSITION_LENGTHTEXTURECOLOR = "ShaderPositionLengthTextureColor"; + +//------------uniform names---------------- +/** + * @constant + * @type {String} + */ +cc.UNIFORM_PMATRIX_S = "CC_PMatrix"; +/** + * @constant + * @type {String} + */ +cc.UNIFORM_MVMATRIX_S = "CC_MVMatrix"; +/** + * @constant + * @type {String} + */ +cc.UNIFORM_MVPMATRIX_S = "CC_MVPMatrix"; +/** + * @constant + * @type {String} + */ +cc.UNIFORM_TIME_S = "CC_Time"; +/** + * @constant + * @type {String} + */ +cc.UNIFORM_SINTIME_S = "CC_SinTime"; +/** + * @constant + * @type {String} + */ +cc.UNIFORM_COSTIME_S = "CC_CosTime"; +/** + * @constant + * @type {String} + */ +cc.UNIFORM_RANDOM01_S = "CC_Random01"; +/** + * @constant + * @type {String} + */ +cc.UNIFORM_SAMPLER_S = "CC_Texture0"; +/** + * @constant + * @type {String} + */ +cc.UNIFORM_ALPHA_TEST_VALUE_S = "CC_alpha_value"; + +//------------Attribute names-------------- +/** + * @constant + * @type {String} + */ +cc.ATTRIBUTE_NAME_COLOR = "a_color"; +/** + * @constant + * @type {String} + */ +cc.ATTRIBUTE_NAME_POSITION = "a_position"; +/** + * @constant + * @type {String} + */ +cc.ATTRIBUTE_NAME_TEX_COORD = "a_texCoord"; + + +/** + * default size for font size + * @constant + * @type Number + */ +cc.ITEM_SIZE = 32; + +/** + * default tag for current item + * @constant + * @type Number + */ +cc.CURRENT_ITEM = 0xc0c05001; +/** + * default tag for zoom action tag + * @constant + * @type Number + */ +cc.ZOOM_ACTION_TAG = 0xc0c05002; +/** + * default tag for normal + * @constant + * @type Number + */ +cc.NORMAL_TAG = 8801; + +/** + * default selected tag + * @constant + * @type Number + */ +cc.SELECTED_TAG = 8802; + +/** + * default disabled tag + * @constant + * @type Number + */ +cc.DISABLE_TAG = 8803; \ No newline at end of file diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index 5522b4f7e2..06ba4d45f4 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -24,13 +24,6 @@ THE SOFTWARE. ****************************************************************************/ -/** - * cc.Sprite invalid index on the cc.SpriteBatchNode - * @constant - * @type Number - */ -cc.SPRITE_INDEX_NOT_INITIALIZED = -1; - /** * generate texture's cache for texture tint * @function @@ -224,15 +217,6 @@ cc.cutRotateImageToCanvas = function (texture, rect) { return nCanvas; }; -cc.RENDER_IN_SUBPIXEL = function (A) { - return (0 | A); -}; -if (cc.SPRITEBATCHNODE_RENDER_SUBPIXEL) { - cc.RENDER_IN_SUBPIXEL = function (A) { - return A; - }; -} - /** *

cc.Sprite is a 2d image ( http://en.wikipedia.org/wiki/Sprite_(computer_graphics) )
* @@ -910,7 +894,7 @@ cc.Sprite = cc.NodeRGBA.extend(/** @lends cc.Sprite# */{ // renders using Sprite Manager if (this._batchNode) { - if (this.atlasIndex != cc.SPRITE_INDEX_NOT_INITIALIZED) { + if (this.atlasIndex != cc.Sprite.INDEX_NOT_INITIALIZED) { this.textureAtlas.updateQuad(locQuad, this.atlasIndex) } else { // no need to set it recursively @@ -1158,6 +1142,14 @@ cc.Sprite.create = function (fileName, rect) { }; +/** + * cc.Sprite invalid index on the cc.SpriteBatchNode + * @constant + * @type Number + */ +cc.Sprite.INDEX_NOT_INITIALIZED = -1; + + if (cc._renderType === cc._RENDER_TYPE_CANVAS) { @@ -1494,7 +1486,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { // self render if (!_t._batchNode) { - _t.atlasIndex = cc.SPRITE_INDEX_NOT_INITIALIZED; + _t.atlasIndex = cc.Sprite.INDEX_NOT_INITIALIZED; _t.textureAtlas = null; _t._recursiveDirty = false; _t.dirty = false; diff --git a/cocos2d/core/sprites/SpritesWebGL.js b/cocos2d/core/sprites/SpritesWebGL.js index 4a0cad6c60..c26970f7eb 100644 --- a/cocos2d/core/sprites/SpritesWebGL.js +++ b/cocos2d/core/sprites/SpritesWebGL.js @@ -423,7 +423,7 @@ if (cc._renderType === cc._RENDER_TYPE_WEBGL) { // self render if (!_t._batchNode) { - _t.atlasIndex = cc.SPRITE_INDEX_NOT_INITIALIZED; + _t.atlasIndex = cc.Sprite.INDEX_NOT_INITIALIZED; _t.textureAtlas = null; _t._recursiveDirty = false; _t.dirty = false; diff --git a/cocos2d/menus/CCMenuItem.js b/cocos2d/menus/CCMenuItem.js index 00899c34dc..e366f25418 100644 --- a/cocos2d/menus/CCMenuItem.js +++ b/cocos2d/menus/CCMenuItem.js @@ -24,51 +24,10 @@ THE SOFTWARE. ****************************************************************************/ - -/** - * default size for font size - * @constant - * @type Number - */ -cc.ITEM_SIZE = 32; - cc._globalFontSize = cc.ITEM_SIZE; cc._globalFontName = "Arial"; cc._globalFontNameRelease = false; -/** - * default tag for current item - * @constant - * @type Number - */ -cc.CURRENT_ITEM = 0xc0c05001; -/** - * default tag for zoom action tag - * @constant - * @type Number - */ -cc.ZOOM_ACTION_TAG = 0xc0c05002; -/** - * default tag for normal - * @constant - * @type Number - */ -cc.NORMAL_TAG = 8801; - -/** - * default selected tag - * @constant - * @type Number - */ -cc.SELECTED_TAG = 8802; - -/** - * default disabled tag - * @constant - * @type Number - */ -cc.DISABLE_TAG = 8803; - /** * Subclass cc.MenuItem (or any subclass) to create your custom cc.MenuItem objects. * @class diff --git a/cocos2d/render-texture/CCRenderTexture.js b/cocos2d/render-texture/CCRenderTexture.js index bd48dcc2a6..e41a78ee9b 100644 --- a/cocos2d/render-texture/CCRenderTexture.js +++ b/cocos2d/render-texture/CCRenderTexture.js @@ -491,7 +491,7 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ gl.viewport(0, 0, size.width * cc.contentScaleFactor(), size.height * cc.contentScaleFactor()); // special viewport for 3d projection + retina display - if (director.getProjection() == cc.DIRECTOR_PROJECTION_3D && cc.contentScaleFactor() != 1) { + if (director.getProjection() == cc.Director.PROJECTION_3D && cc.contentScaleFactor() != 1) { gl.viewport((-size.width / 2), (-size.height / 2), (size.width * cc.contentScaleFactor()), (size.height * cc.contentScaleFactor())); } diff --git a/cocos2d/shaders/CCGLProgram.js b/cocos2d/shaders/CCGLProgram.js index 703f9dfde8..991efd0722 100644 --- a/cocos2d/shaders/CCGLProgram.js +++ b/cocos2d/shaders/CCGLProgram.js @@ -26,181 +26,6 @@ THE SOFTWARE. ****************************************************************************/ -//-------------Vertex Attributes----------- -/** - * @constant - * @type {Number} - */ -cc.VERTEX_ATTRIB_POSITION = 0; -/** - * @constant - * @type {Number} - */ -cc.VERTEX_ATTRIB_COLOR = 1; -/** - * @constant - * @type {Number} - */ -cc.VERTEX_ATTRIB_TEX_COORDS = 2; -/** - * @constant - * @type {Number} - */ -cc.VERTEX_ATTRIB_MAX = 3; - -//------------Uniforms------------------ -/** - * @constant - * @type {Number} - */ -cc.UNIFORM_PMATRIX = 0; -/** - * @constant - * @type {Number} - */ -cc.UNIFORM_MVMATRIX = 1; -/** - * @constant - * @type {Number} - */ -cc.UNIFORM_MVPMATRIX = 2; -/** - * @constant - * @type {Number} - */ -cc.UNIFORM_TIME = 3; -/** - * @constant - * @type {Number} - */ -cc.UNIFORM_SINTIME = 4; -/** - * @constant - * @type {Number} - */ -cc.UNIFORM_COSTIME = 5; -/** - * @constant - * @type {Number} - */ -cc.UNIFORM_RANDOM01 = 6; -/** - * @constant - * @type {Number} - */ -cc.UNIFORM_SAMPLER = 7; -/** - * @constant - * @type {Number} - */ -cc.UNIFORM_MAX = 8; - -//------------Shader Name--------------- -/** - * @constant - * @type {String} - */ -cc.SHADER_POSITION_TEXTURECOLOR = "ShaderPositionTextureColor"; -/** - * @constant - * @type {String} - */ -cc.SHADER_POSITION_TEXTURECOLORALPHATEST = "ShaderPositionTextureColorAlphaTest"; -/** - * @constant - * @type {String} - */ -cc.SHADER_POSITION_COLOR = "ShaderPositionColor"; -/** - * @constant - * @type {String} - */ -cc.SHADER_POSITION_TEXTURE = "ShaderPositionTexture"; -/** - * @constant - * @type {String} - */ -cc.SHADER_POSITION_TEXTURE_UCOLOR = "ShaderPositionTexture_uColor"; -/** - * @constant - * @type {String} - */ -cc.SHADER_POSITION_TEXTUREA8COLOR = "ShaderPositionTextureA8Color"; -/** - * @constant - * @type {String} - */ -cc.SHADER_POSITION_UCOLOR = "ShaderPosition_uColor"; -/** - * @constant - * @type {String} - */ -cc.SHADER_POSITION_LENGTHTEXTURECOLOR = "ShaderPositionLengthTextureColor"; - -//------------uniform names---------------- -/** - * @constant - * @type {String} - */ -cc.UNIFORM_PMATRIX_S = "CC_PMatrix"; -/** - * @constant - * @type {String} - */ -cc.UNIFORM_MVMATRIX_S = "CC_MVMatrix"; -/** - * @constant - * @type {String} - */ -cc.UNIFORM_MVPMATRIX_S = "CC_MVPMatrix"; -/** - * @constant - * @type {String} - */ -cc.UNIFORM_TIME_S = "CC_Time"; -/** - * @constant - * @type {String} - */ -cc.UNIFORM_SINTIME_S = "CC_SinTime"; -/** - * @constant - * @type {String} - */ -cc.UNIFORM_COSTIME_S = "CC_CosTime"; -/** - * @constant - * @type {String} - */ -cc.UNIFORM_RANDOM01_S = "CC_Random01"; -/** - * @constant - * @type {String} - */ -cc.UNIFORM_SAMPLER_S = "CC_Texture0"; -/** - * @constant - * @type {String} - */ -cc.UNIFORM_ALPHA_TEST_VALUE_S = "CC_alpha_value"; - -//------------Attribute names-------------- -/** - * @constant - * @type {String} - */ -cc.ATTRIBUTE_NAME_COLOR = "a_color"; -/** - * @constant - * @type {String} - */ -cc.ATTRIBUTE_NAME_POSITION = "a_position"; -/** - * @constant - * @type {String} - */ -cc.ATTRIBUTE_NAME_TEX_COORD = "a_texCoord"; - cc.HashUniformEntry = function (value, location, hh) { this.value = value; this.location = location; diff --git a/cocos2d/shaders/CCGLStateCache.js b/cocos2d/shaders/CCGLStateCache.js index 401ff36a72..c8d890ae32 100644 --- a/cocos2d/shaders/CCGLStateCache.js +++ b/cocos2d/shaders/CCGLStateCache.js @@ -24,40 +24,6 @@ THE SOFTWARE. ****************************************************************************/ -// ------------------- vertex attrib flags ----------------------------- -/** - * @constant - * @type {Number} - */ -cc.VERTEX_ATTRIB_FLAG_NONE = 0; -/** - * @constant - * @type {Number} - */ -cc.VERTEX_ATTRIB_FLAG_POSITION = 1 << 0; -/** - * @constant - * @type {Number} - */ -cc.VERTEX_ATTRIB_FLAG_COLOR = 1 << 1; -/** - * @constant - * @type {Number} - */ -cc.VERTEX_ATTRIB_FLAG_TEX_COORDS = 1 << 2; -/** - * @constant - * @type {Number} - */ -cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX = ( cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_COLOR | cc.VERTEX_ATTRIB_FLAG_TEX_COORDS ); - -/** - * GL server side states - * @constant - * @type {Number} - */ -cc.GL_ALL = 0; - cc._currentProjectionMatrix = -1; cc._vertexAttribPosition = false; cc._vertexAttribColor = false; From ae9ec2783fc132a578c37d6d8ca71b03c7b856cd Mon Sep 17 00:00:00 2001 From: pandamicro Date: Thu, 10 Apr 2014 22:08:04 +0800 Subject: [PATCH 3/4] Fixed #4747: cc.RENDER_IN_SUBPIXEL removed --- cocos2d/core/base-nodes/BaseNodesWebGL.js | 8 ++++++-- cocos2d/core/sprites/SpritesWebGL.js | 18 ++++++++++++++---- cocos2d/node-grid/CCNodeGrid.js | 8 ++++++-- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/cocos2d/core/base-nodes/BaseNodesWebGL.js b/cocos2d/core/base-nodes/BaseNodesWebGL.js index 6596029bef..e01a840dba 100644 --- a/cocos2d/core/base-nodes/BaseNodesWebGL.js +++ b/cocos2d/core/base-nodes/BaseNodesWebGL.js @@ -131,9 +131,13 @@ if (cc._renderType === cc._RENDER_TYPE_WEBGL) { var apx = _t._anchorPointInPoints.x, apy = _t._anchorPointInPoints.y; var translate = (apx !== 0.0 || apy !== 0.0); if (translate){ - cc.kmGLTranslatef(cc.RENDER_IN_SUBPIXEL(apx), cc.RENDER_IN_SUBPIXEL(apy), 0); + if(!cc.SPRITEBATCHNODE_RENDER_SUBPIXEL) { + apx = 0 | apx; + apy = 0 | apy; + } + cc.kmGLTranslatef(apx, apy, 0); _t._camera.locate(); - cc.kmGLTranslatef(cc.RENDER_IN_SUBPIXEL(-apx), cc.RENDER_IN_SUBPIXEL(-apy), 0); + cc.kmGLTranslatef(-apx, -apy, 0); } else { _t._camera.locate(); } diff --git a/cocos2d/core/sprites/SpritesWebGL.js b/cocos2d/core/sprites/SpritesWebGL.js index c26970f7eb..d57c1e82d9 100644 --- a/cocos2d/core/sprites/SpritesWebGL.js +++ b/cocos2d/core/sprites/SpritesWebGL.js @@ -306,10 +306,20 @@ if (cc._renderType === cc._RENDER_TYPE_WEBGL) { var dy = x1 * sr + y2 * cr2 + y; var locVertexZ = _t._vertexZ; - locQuad.bl.vertices = {x: cc.RENDER_IN_SUBPIXEL(ax), y: cc.RENDER_IN_SUBPIXEL(ay), z: locVertexZ}; - locQuad.br.vertices = {x: cc.RENDER_IN_SUBPIXEL(bx), y: cc.RENDER_IN_SUBPIXEL(by), z: locVertexZ}; - locQuad.tl.vertices = {x: cc.RENDER_IN_SUBPIXEL(dx), y: cc.RENDER_IN_SUBPIXEL(dy), z: locVertexZ}; - locQuad.tr.vertices = {x: cc.RENDER_IN_SUBPIXEL(cx), y: cc.RENDER_IN_SUBPIXEL(cy), z: locVertexZ}; + if(!cc.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}; } _t.textureAtlas.updateQuad(locQuad, _t.atlasIndex); _t._recursiveDirty = false; diff --git a/cocos2d/node-grid/CCNodeGrid.js b/cocos2d/node-grid/CCNodeGrid.js index adb4dffbcb..7a487255cf 100644 --- a/cocos2d/node-grid/CCNodeGrid.js +++ b/cocos2d/node-grid/CCNodeGrid.js @@ -113,9 +113,13 @@ cc.NodeGrid = cc.Node.extend({ var apx = this._anchorPointInPoints.x, apy = this._anchorPointInPoints.y; var translate = (apx !== 0.0 || apy !== 0.0); if (translate) { - cc.kmGLTranslatef(cc.RENDER_IN_SUBPIXEL(apx), cc.RENDER_IN_SUBPIXEL(apy), 0); + if(!cc.SPRITEBATCHNODE_RENDER_SUBPIXEL) { + apx = 0 | apx; + apy = 0 | apy; + } + cc.kmGLTranslatef(apx, apy, 0); this._camera.locate(); - cc.kmGLTranslatef(cc.RENDER_IN_SUBPIXEL(-apx), cc.RENDER_IN_SUBPIXEL(-apy), 0); + cc.kmGLTranslatef(-apx, -apy, 0); } else { this._camera.locate(); } From 0fcbe087274098966d1d55a7d02849eb0623255b Mon Sep 17 00:00:00 2001 From: pandamicro Date: Thu, 10 Apr 2014 22:08:16 +0800 Subject: [PATCH 4/4] Update version number --- cocos2d/core/platform/CCConfig.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/core/platform/CCConfig.js b/cocos2d/core/platform/CCConfig.js index 8d63ca65a1..2b52726809 100644 --- a/cocos2d/core/platform/CCConfig.js +++ b/cocos2d/core/platform/CCConfig.js @@ -33,7 +33,7 @@ * @constant * @type String */ -cc.ENGINE_VERSION = "Cocos2d-html5-v3.0 alpha"; +cc.ENGINE_VERSION = "Cocos2d-html5-v3.0 alpha 2"; /** *