diff --git a/cocos2dx/CCDirector.cpp b/cocos2dx/CCDirector.cpp index 33979967ce..cb187d7308 100644 --- a/cocos2dx/CCDirector.cpp +++ b/cocos2dx/CCDirector.cpp @@ -345,7 +345,9 @@ void CCDirector::setProjection(ccDirectorProjection kProjection) kmGLMatrixMode(KM_GL_PROJECTION); kmGLLoadIdentity(); - kmMat4PerspectiveProjection( &matrixPerspective, 60, (GLfloat)sizePoint.width/sizePoint.height, 0.5f, 1500.0f ); + // issue #1334 + kmMat4PerspectiveProjection( &matrixPerspective, 60, (GLfloat)size.width/size.height, 0.1f, zeye*2); +// kmMat4PerspectiveProjection( &matrixPerspective, 60, (GLfloat)size.width/size.height, 0.1f, 1500); kmGLMultMatrix(&matrixPerspective); kmGLMatrixMode(KM_GL_MODELVIEW); @@ -367,7 +369,7 @@ void CCDirector::setProjection(ccDirectorProjection kProjection) break; default: - CCLOG("cocos2d: Director: unrecognized projecgtion"); + CCLOG("cocos2d: Director: unrecognized projection"); break; } @@ -397,8 +399,8 @@ void CCDirector::setAlphaBlending(bool bOn) { glDisable(GL_BLEND); } - // TODO: - //CHECK_GL_ERROR_DEBUG(); + + CHECK_GL_ERROR_DEBUG(); } void CCDirector::setDepthTest(bool bOn) diff --git a/cocos2dx/actions/CCActionInterval.cpp b/cocos2dx/actions/CCActionInterval.cpp index b86ba9c89d..c614b77d54 100644 --- a/cocos2dx/actions/CCActionInterval.cpp +++ b/cocos2dx/actions/CCActionInterval.cpp @@ -2045,12 +2045,12 @@ bool CCAnimate::initWithAnimation(CCAnimation *pAnimation) if ( CCActionInterval::initWithDuration(singleDuration * pAnimation->getLoops() ) ) { - nextFrame_ = 0; - m_pAnimation = pAnimation; + m_nNextFrame = 0; + setAnimation(pAnimation); m_pOrigFrame = NULL; - executedLoops_ = 0; + m_uExecutedLoops = 0; - splitTimes_->reserve(pAnimation->getFrames()->count()); + m_pSplitTimes->reserve(pAnimation->getFrames()->count()); float accumUnitsOfTime = 0; float newUnitOfTimeValue = singleDuration / pAnimation->getTotalDelayUnits(); @@ -2061,7 +2061,7 @@ bool CCAnimate::initWithAnimation(CCAnimation *pAnimation) CCAnimationFrame *frame = *iterFrame; float value = (accumUnitsOfTime * newUnitOfTimeValue) / singleDuration; accumUnitsOfTime += frame->getDelayUnits(); - splitTimes_->push_back(value); + m_pSplitTimes->push_back(value); } return true; } @@ -2093,10 +2093,10 @@ CCObject* CCAnimate::copyWithZone(CCZone *pZone) CCAnimate::CCAnimate() : m_pAnimation(NULL) -, splitTimes_(new std::vector) -, nextFrame_(0) +, m_pSplitTimes(new std::vector) +, m_nNextFrame(0) , m_pOrigFrame(NULL) -, executedLoops_(0) +, m_uExecutedLoops(0) { } @@ -2105,7 +2105,7 @@ CCAnimate::~CCAnimate() { CC_SAFE_RELEASE(m_pAnimation); CC_SAFE_RELEASE(m_pOrigFrame); - CC_SAFE_DELETE(splitTimes_); + CC_SAFE_DELETE(m_pSplitTimes); } void CCAnimate::startWithTarget(CCNode *pTarget) @@ -2120,8 +2120,8 @@ void CCAnimate::startWithTarget(CCNode *pTarget) m_pOrigFrame = pSprite->displayFrame(); m_pOrigFrame->retain(); } - nextFrame_ = 0; - executedLoops_ = 0; + m_nNextFrame = 0; + m_uExecutedLoops = 0; } void CCAnimate::stop(void) @@ -2142,9 +2142,9 @@ void CCAnimate::update(ccTime t) // new loop? If so, reset frame counter unsigned int loopNumber = (unsigned int)t; - if( loopNumber > executedLoops_ ) { - nextFrame_ = 0; - executedLoops_++; + if( loopNumber > m_uExecutedLoops ) { + m_nNextFrame = 0; + m_uExecutedLoops++; } // new t for animations @@ -2155,8 +2155,8 @@ void CCAnimate::update(ccTime t) unsigned int numberOfFrames = frames->count(); CCSpriteFrame *frameToDisplay = NULL; - for( unsigned int i=nextFrame_; i < numberOfFrames; i++ ) { - float splitTime = splitTimes_->at(i); + for( unsigned int i=m_nNextFrame; i < numberOfFrames; i++ ) { + float splitTime = m_pSplitTimes->at(i); if( splitTime <= t ) { CCAnimationFrame *frame = frames->getObjectAtIndex(i); @@ -2168,7 +2168,7 @@ void CCAnimate::update(ccTime t) { //TODO: [[NSNotificationCenter defaultCenter] postNotificationName:CCAnimationFrameDisplayedNotification object:target_ userInfo:dict]; } - nextFrame_ = i+1; + m_nNextFrame = i+1; break; } diff --git a/cocos2dx/base_nodes/CCAtlasNode.cpp b/cocos2dx/base_nodes/CCAtlasNode.cpp index adb84ac1f1..91aa4489c7 100644 --- a/cocos2dx/base_nodes/CCAtlasNode.cpp +++ b/cocos2dx/base_nodes/CCAtlasNode.cpp @@ -108,7 +108,7 @@ bool CCAtlasNode::initWithTileFile(const char *tile, unsigned int tileWidth, uns // shader stuff setShaderProgram(CCShaderCache::sharedShaderCache()->programForKey(kCCShader_PositionTexture_uColor)); - m_nUniformColor = glGetUniformLocation( m_pShaderProgram->getProgram(), "u_color"); + m_nUniformColor = glGetUniformLocation( getShaderProgram()->getProgram(), "u_color"); return true; } @@ -137,7 +137,7 @@ void CCAtlasNode::draw() ccGLBlendFunc( m_tBlendFunc.src, m_tBlendFunc.dst ); GLfloat colors[4] = {m_tColor.r / 255.0f, m_tColor.g / 255.0f, m_tColor.b / 255.0f, m_cOpacity / 255.0f}; - m_pShaderProgram->setUniformLocationWith4fv(m_nUniformColor, colors, 1); + getShaderProgram()->setUniformLocationWith4fv(m_nUniformColor, colors, 1); m_pTextureAtlas->drawNumberOfQuads(m_uQuadsToDraw, 0); } diff --git a/cocos2dx/base_nodes/CCNode.cpp b/cocos2dx/base_nodes/CCNode.cpp index 84d92e10d5..7309b27594 100644 --- a/cocos2dx/base_nodes/CCNode.cpp +++ b/cocos2dx/base_nodes/CCNode.cpp @@ -642,7 +642,7 @@ void CCNode::insertChild(CCNode* child, int z) { m_bReorderChildDirty = true; ccArrayAppendObjectWithResize(m_pChildren->data, child); - child->setZOrder(z); + child->_setZOrder(z); } void CCNode::reorderChild(CCNode *child, int zOrder) @@ -650,7 +650,7 @@ void CCNode::reorderChild(CCNode *child, int zOrder) CCAssert( child != NULL, "Child must be non-nil"); m_bReorderChildDirty = true; child->setOrderOfArrival(s_globalOrderOfArrival++); - child->setZOrder(zOrder); + child->_setZOrder(zOrder); } void CCNode::sortAllChildren() @@ -900,21 +900,6 @@ unsigned int CCNode::numberOfRunningActions() return m_pActionManager->numberOfRunningActionsInTarget(this); } -void CCNode::setShaderProgram(CCGLProgram* pShaderProgram) -{ - if (m_pShaderProgram != pShaderProgram) - { - CC_SAFE_RETAIN(pShaderProgram); - CC_SAFE_RELEASE(m_pShaderProgram); - m_pShaderProgram = pShaderProgram; - } -} - -CCGLProgram* CCNode::getShaderProgram(void) -{ - return m_pShaderProgram; -} - // CCNode - Callbacks void CCNode::setScheduler(CCScheduler* scheduler) diff --git a/cocos2dx/gles2/CCGLProgram.cpp b/cocos2dx/gles2/CCGLProgram.cpp index fd9bb058a5..d2d95591d9 100644 --- a/cocos2dx/gles2/CCGLProgram.cpp +++ b/cocos2dx/gles2/CCGLProgram.cpp @@ -272,8 +272,10 @@ void CCGLProgram::setUniformLocationWith1i(unsigned int location, GLint i1) { bool updated = updateUniformLocation(location, &i1, sizeof(i1)*1); - if( updated ) + if( updated ) + { glUniform1i( (GLint)location, i1); + } } void CCGLProgram::setUniformLocationWith1f(unsigned int location, GLfloat f1) @@ -281,7 +283,9 @@ void CCGLProgram::setUniformLocationWith1f(unsigned int location, GLfloat f1) bool updated = updateUniformLocation(location, &f1, sizeof(f1)*1); if( updated ) + { glUniform1f( (GLint)location, f1); + } } void CCGLProgram::setUniformLocationWith2f(unsigned int location, GLfloat f1, GLfloat f2) @@ -290,7 +294,9 @@ void CCGLProgram::setUniformLocationWith2f(unsigned int location, GLfloat f1, GL bool updated = updateUniformLocation(location, floats, sizeof(floats)); if( updated ) + { glUniform2f( (GLint)location, f1, f2); + } } void CCGLProgram::setUniformLocationWith3f(unsigned int location, GLfloat f1, GLfloat f2, GLfloat f3) @@ -299,7 +305,9 @@ void CCGLProgram::setUniformLocationWith3f(unsigned int location, GLfloat f1, GL bool updated = updateUniformLocation(location, floats, sizeof(floats)); if( updated ) + { glUniform3f( (GLint)location, f1, f2, f3); + } } void CCGLProgram::setUniformLocationWith4f(unsigned int location, GLfloat f1, GLfloat f2, GLfloat f3, GLfloat f4) @@ -308,7 +316,9 @@ void CCGLProgram::setUniformLocationWith4f(unsigned int location, GLfloat f1, GL bool updated = updateUniformLocation(location, floats, sizeof(floats)); if( updated ) + { glUniform4f( (GLint)location, f1, f2, f3,f4); + } } void CCGLProgram::setUniformLocationWith2fv(unsigned int location, GLfloat* floats, unsigned int numberOfArrays) @@ -316,7 +326,9 @@ void CCGLProgram::setUniformLocationWith2fv(unsigned int location, GLfloat* floa bool updated = updateUniformLocation(location, floats, sizeof(float)*2*numberOfArrays); if( updated ) + { glUniform2fv( (GLint)location, (GLsizei)numberOfArrays, floats ); + } } void CCGLProgram::setUniformLocationWith3fv(unsigned int location, GLfloat* floats, unsigned int numberOfArrays) @@ -324,7 +336,9 @@ void CCGLProgram::setUniformLocationWith3fv(unsigned int location, GLfloat* floa bool updated = updateUniformLocation(location, floats, sizeof(float)*3*numberOfArrays); if( updated ) + { glUniform3fv( (GLint)location, (GLsizei)numberOfArrays, floats ); + } } void CCGLProgram::setUniformLocationWith4fv(unsigned int location, GLfloat* floats, unsigned int numberOfArrays) @@ -332,7 +346,9 @@ void CCGLProgram::setUniformLocationWith4fv(unsigned int location, GLfloat* floa bool updated = updateUniformLocation(location, floats, sizeof(float)*4*numberOfArrays); if( updated ) + { glUniform4fv( (GLint)location, (GLsizei)numberOfArrays, floats ); + } } @@ -341,7 +357,9 @@ void CCGLProgram::setUniformLocationwithMatrix4fv(unsigned int location, GLfloat bool updated = updateUniformLocation(location, matrixArray, sizeof(float)*16*numberOfMatrices); if( updated ) + { glUniformMatrix4fv( (GLint)location, (GLsizei)numberOfMatrices, GL_FALSE, matrixArray); + } } void CCGLProgram::setUniformForModelViewProjectionMatrix() diff --git a/cocos2dx/gles2/CCShaderCache.cpp b/cocos2dx/gles2/CCShaderCache.cpp index 151aebdcb5..6233440821 100644 --- a/cocos2dx/gles2/CCShaderCache.cpp +++ b/cocos2dx/gles2/CCShaderCache.cpp @@ -51,7 +51,7 @@ void CCShaderCache::purgeSharedShaderCache() } CCShaderCache::CCShaderCache() -: programs_(0) +: m_pPrograms(0) { } @@ -59,12 +59,12 @@ CCShaderCache::CCShaderCache() CCShaderCache::~CCShaderCache() { CCLOGINFO("cocos2d deallocing 0x%X", this); - programs_->release(); + m_pPrograms->release(); } bool CCShaderCache::init() { - programs_ = new CCMutableDictionary(); + m_pPrograms = new CCMutableDictionary(); loadDefaultShaders(); return true; } @@ -82,7 +82,7 @@ void CCShaderCache::loadDefaultShaders() p->link(); p->updateUniforms(); - programs_->setObject(p, kCCShader_PositionTextureColor); + m_pPrograms->setObject(p, kCCShader_PositionTextureColor); p->release(); CHECK_GL_ERROR_DEBUG(); @@ -98,7 +98,7 @@ void CCShaderCache::loadDefaultShaders() p->link(); p->updateUniforms(); - programs_->setObject(p, kCCShader_PositionTextureColorAlphaTest); + m_pPrograms->setObject(p, kCCShader_PositionTextureColorAlphaTest); p->release(); CHECK_GL_ERROR_DEBUG(); @@ -115,7 +115,7 @@ void CCShaderCache::loadDefaultShaders() p->link(); p->updateUniforms(); - programs_->setObject(p, kCCShader_PositionColor); + m_pPrograms->setObject(p, kCCShader_PositionColor); p->release(); CHECK_GL_ERROR_DEBUG(); @@ -131,7 +131,7 @@ void CCShaderCache::loadDefaultShaders() p->link(); p->updateUniforms(); - programs_->setObject(p, kCCShader_PositionTexture); + m_pPrograms->setObject(p, kCCShader_PositionTexture); p->release(); CHECK_GL_ERROR_DEBUG(); @@ -148,7 +148,7 @@ void CCShaderCache::loadDefaultShaders() p->link(); p->updateUniforms(); - programs_->setObject(p ,kCCShader_PositionTexture_uColor); + m_pPrograms->setObject(p ,kCCShader_PositionTexture_uColor); p->release(); CHECK_GL_ERROR_DEBUG(); @@ -166,7 +166,7 @@ void CCShaderCache::loadDefaultShaders() p->link(); p->updateUniforms(); - programs_->setObject(p, kCCShader_PositionTextureA8Color); + m_pPrograms->setObject(p, kCCShader_PositionTextureA8Color); p->release(); CHECK_GL_ERROR_DEBUG(); @@ -182,7 +182,7 @@ void CCShaderCache::loadDefaultShaders() p->link(); p->updateUniforms(); - programs_->setObject(p, kCCShader_Position_uColor); + m_pPrograms->setObject(p, kCCShader_Position_uColor); p->release(); CHECK_GL_ERROR_DEBUG(); @@ -190,12 +190,12 @@ void CCShaderCache::loadDefaultShaders() CCGLProgram* CCShaderCache::programForKey(const char* key) { - return programs_->objectForKey(key); + return m_pPrograms->objectForKey(key); } void CCShaderCache::addProgram(CCGLProgram* program, const char* key) { - programs_->setObject(program, key); + m_pPrograms->setObject(program, key); } NS_CC_END diff --git a/cocos2dx/gles2/ccGLStateCache.cpp b/cocos2dx/gles2/ccGLStateCache.cpp index d5253d8510..067ee2e569 100644 --- a/cocos2dx/gles2/ccGLStateCache.cpp +++ b/cocos2dx/gles2/ccGLStateCache.cpp @@ -35,46 +35,52 @@ THE SOFTWARE. NS_CC_BEGIN -static GLuint _ccCurrentProjectionMatrix = -1; -static bool _vertexAttribPosition = false; -static bool _vertexAttribColor = false; -static bool _vertexAttribTexCoords = false; +static GLuint s_uCurrentProjectionMatrix = -1; +static bool s_bVertexAttribPosition = false; +static bool s_bVertexAttribColor = false; +static bool s_bVertexAttribTexCoords = false; + #if CC_ENABLE_GL_STATE_CACHE + #define kCCMaxActiveTexture 16 -static GLuint _ccCurrentShaderProgram = -1; -static GLuint _ccCurrentBoundTexture[kCCMaxActiveTexture] = {-1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, }; -static GLenum _ccCurrentActiveTexture = (GL_TEXTURE0 - GL_TEXTURE0); -static GLenum _ccBlendingSource = -1; -static GLenum _ccBlendingDest = -1; -static int _ccGLServerState = 0; + +static GLuint s_uCurrentShaderProgram = -1; +static GLuint s_uCurrentBoundTexture[kCCMaxActiveTexture] = {-1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, }; +static GLenum s_eCurrentActiveTexture = (GL_TEXTURE0 - GL_TEXTURE0); +static GLenum s_eBlendingSource = -1; +static GLenum s_eBlendingDest = -1; +static int s_eGLServerState = 0; + #endif // CC_ENABLE_GL_STATE_CACHE -//#pragma mark - GL State Cache functions +// GL State Cache functions void ccGLInvalidateStateCache( void ) { kmGLFreeAll(); - _ccCurrentProjectionMatrix = -1; - _vertexAttribPosition = false; - _vertexAttribColor = false; - _vertexAttribTexCoords = false; + s_uCurrentProjectionMatrix = -1; + s_bVertexAttribPosition = false; + s_bVertexAttribColor = false; + s_bVertexAttribTexCoords = false; #if CC_ENABLE_GL_STATE_CACHE - _ccCurrentShaderProgram = -1; + s_uCurrentShaderProgram = -1; for( int i=0; i < kCCMaxActiveTexture; i++ ) - _ccCurrentBoundTexture[i] = -1; - _ccCurrentActiveTexture = (GL_TEXTURE0 - GL_TEXTURE0); - _ccBlendingSource = -1; - _ccBlendingDest = -1; - _ccGLServerState = 0; + { + s_uCurrentBoundTexture[i] = -1; + } + s_eCurrentActiveTexture = (GL_TEXTURE0 - GL_TEXTURE0); + s_eBlendingSource = -1; + s_eBlendingDest = -1; + s_eGLServerState = 0; #endif } void ccGLDeleteProgram( GLuint program ) { #if CC_ENABLE_GL_STATE_CACHE - if( program == _ccCurrentShaderProgram ) - _ccCurrentShaderProgram = -1; + if( program == s_uCurrentShaderProgram ) + s_uCurrentShaderProgram = -1; #endif // CC_ENABLE_GL_STATE_CACHE glDeleteProgram( program ); @@ -83,8 +89,8 @@ void ccGLDeleteProgram( GLuint program ) void ccGLUseProgram( GLuint program ) { #if CC_ENABLE_GL_STATE_CACHE - if( program != _ccCurrentShaderProgram ) { - _ccCurrentShaderProgram = program; + if( program != s_uCurrentShaderProgram ) { + s_uCurrentShaderProgram = program; glUseProgram(program); } #else @@ -96,9 +102,9 @@ void ccGLUseProgram( GLuint program ) void ccGLBlendFunc(GLenum sfactor, GLenum dfactor) { #if CC_ENABLE_GL_STATE_CACHE - if( sfactor != _ccBlendingSource || dfactor != _ccBlendingDest ) { - _ccBlendingSource = sfactor; - _ccBlendingDest = dfactor; + if( sfactor != s_eBlendingSource || dfactor != s_eBlendingDest ) { + s_eBlendingSource = sfactor; + s_eBlendingDest = dfactor; glBlendFunc( sfactor, dfactor ); } #else @@ -109,7 +115,7 @@ void ccGLBlendFunc(GLenum sfactor, GLenum dfactor) GLenum ccGLGetActiveTexture( void ) { #if CC_ENABLE_GL_STATE_CACHE - return _ccCurrentActiveTexture + GL_TEXTURE0; + return s_eCurrentActiveTexture + GL_TEXTURE0; #else GLenum activeTexture; glGetIntegerv(GL_ACTIVE_TEXTURE, (GLint*)&activeTexture); @@ -120,9 +126,9 @@ GLenum ccGLGetActiveTexture( void ) void ccGLActiveTexture( GLenum textureEnum ) { #if CC_ENABLE_GL_STATE_CACHE - CCAssert( (textureEnum - GL_TEXTURE0) < kCCMaxActiveTexture, "cocos2d ERROR: Increase kCCMaxActiveTexture to %d!", (textureEnum-GL_TEXTURE0) ); - if( (textureEnum - GL_TEXTURE0) != _ccCurrentActiveTexture ) { - _ccCurrentActiveTexture = (textureEnum - GL_TEXTURE0); + CCAssert( (textureEnum - GL_TEXTURE0) < kCCMaxActiveTexture, "cocos2d ERROR: Increase kCCMaxActiveTexture to kCCMaxActiveTexture!"); + if( (textureEnum - GL_TEXTURE0) != s_eCurrentActiveTexture ) { + s_eCurrentActiveTexture = (textureEnum - GL_TEXTURE0); glActiveTexture( textureEnum ); } #else @@ -133,9 +139,9 @@ void ccGLActiveTexture( GLenum textureEnum ) void ccGLBindTexture2D( GLuint textureId ) { #if CC_ENABLE_GL_STATE_CACHE - if( _ccCurrentBoundTexture[ _ccCurrentActiveTexture ] != textureId ) + if( s_uCurrentBoundTexture[ s_eCurrentActiveTexture ] != textureId ) { - _ccCurrentBoundTexture[ _ccCurrentActiveTexture ] = textureId; + s_uCurrentBoundTexture[ s_eCurrentActiveTexture ] = textureId; glBindTexture(GL_TEXTURE_2D, textureId ); } #else @@ -147,8 +153,8 @@ void ccGLBindTexture2D( GLuint textureId ) void ccGLDeleteTexture( GLuint textureId ) { #if CC_ENABLE_GL_STATE_CACHE - if( textureId == _ccCurrentBoundTexture[ _ccCurrentActiveTexture ] ) - _ccCurrentBoundTexture[ _ccCurrentActiveTexture ] = -1; + if( textureId == s_uCurrentBoundTexture[ s_eCurrentActiveTexture ] ) + s_uCurrentBoundTexture[ s_eCurrentActiveTexture ] = -1; #endif glDeleteTextures(1, &textureId ); } @@ -160,13 +166,13 @@ void ccGLEnable( ccGLServerState flags ) bool enabled = false; /* GL_BLEND */ - if( (enabled=(flags & CC_GL_BLEND)) != (_ccGLServerState & CC_GL_BLEND) ) { + if( (enabled=(flags & CC_GL_BLEND)) != (s_eGLServerState & CC_GL_BLEND) ) { if( enabled ) { glEnable( GL_BLEND ); - _ccGLServerState |= CC_GL_BLEND; + s_eGLServerState |= CC_GL_BLEND; } else { glDisable( GL_BLEND ); - _ccGLServerState &= ~CC_GL_BLEND; + s_eGLServerState &= ~CC_GL_BLEND; } } @@ -185,37 +191,37 @@ void ccGLEnableVertexAttribs( unsigned int flags ) /* Position */ bool enablePosition = flags & kCCVertexAttribFlag_Position; - if( enablePosition != _vertexAttribPosition ) { + if( enablePosition != s_bVertexAttribPosition ) { if( enablePosition ) glEnableVertexAttribArray( kCCVertexAttrib_Position ); else glDisableVertexAttribArray( kCCVertexAttrib_Position ); - _vertexAttribPosition = enablePosition; + s_bVertexAttribPosition = enablePosition; } /* Color */ bool enableColor = (flags & kCCVertexAttribFlag_Color) != 0 ? true : false; - if( enableColor != _vertexAttribColor ) { + if( enableColor != s_bVertexAttribColor ) { if( enableColor ) glEnableVertexAttribArray( kCCVertexAttrib_Color ); else glDisableVertexAttribArray( kCCVertexAttrib_Color ); - _vertexAttribColor = enableColor; + s_bVertexAttribColor = enableColor; } /* Tex Coords */ bool enableTexCoords = (flags & kCCVertexAttribFlag_TexCoords) != 0 ? true : false; - if( enableTexCoords != _vertexAttribTexCoords ) { + if( enableTexCoords != s_bVertexAttribTexCoords ) { if( enableTexCoords ) glEnableVertexAttribArray( kCCVertexAttrib_TexCoords ); else glDisableVertexAttribArray( kCCVertexAttrib_TexCoords ); - _vertexAttribTexCoords = enableTexCoords; + s_bVertexAttribTexCoords = enableTexCoords; } } @@ -223,7 +229,7 @@ void ccGLEnableVertexAttribs( unsigned int flags ) void ccSetProjectionMatrixDirty( void ) { - _ccCurrentProjectionMatrix = -1; + s_uCurrentProjectionMatrix = -1; } NS_CC_END diff --git a/cocos2dx/include/CCActionInterval.h b/cocos2dx/include/CCActionInterval.h index 5bad294883..559ae092b7 100755 --- a/cocos2dx/include/CCActionInterval.h +++ b/cocos2dx/include/CCActionInterval.h @@ -686,10 +686,10 @@ public: CC_SYNTHESIZE_RETAIN(CCAnimation*, m_pAnimation, Animation) protected: - std::vector* splitTimes_; - int nextFrame_; + std::vector* m_pSplitTimes; + int m_nNextFrame; CCSpriteFrame* m_pOrigFrame; - unsigned int executedLoops_; + unsigned int m_uExecutedLoops; }; /** Overrides the target of an action so that it always runs on the target diff --git a/cocos2dx/include/CCNode.h b/cocos2dx/include/CCNode.h index 0432bd04a6..c9384f17b0 100755 --- a/cocos2dx/include/CCNode.h +++ b/cocos2dx/include/CCNode.h @@ -33,6 +33,7 @@ #include "CCArray.h" #include "CCGL.h" #include "ccGLStateCache.h" +#include "CCGLProgram.h" #include "kazmath/kazmath.h" namespace cocos2d { @@ -42,8 +43,7 @@ namespace cocos2d { class CCTouch; class CCAction; class CCRGBAProtocol; - class CCLabelProtocol; - class CCGLProgram; + class CCLabelProtocol; class CCScheduler; class CCActionManager; @@ -259,7 +259,7 @@ while(false) /** Shader Program @since v2.0 */ - CC_PROPERTY(CCGLProgram*, m_pShaderProgram, ShaderProgram); + CC_SYNTHESIZE_RETAIN(CCGLProgram*, m_pShaderProgram, ShaderProgram); /** used internally for zOrder sorting, don't change this manually */ CC_SYNTHESIZE(int, m_nOrderOfArrival, OrderOfArrival); diff --git a/cocos2dx/include/CCShaderCache.h b/cocos2dx/include/CCShaderCache.h index 496dac8aac..c0f1a80d38 100644 --- a/cocos2dx/include/CCShaderCache.h +++ b/cocos2dx/include/CCShaderCache.h @@ -61,7 +61,7 @@ public: private: bool init(); - CCMutableDictionary* programs_; + CCMutableDictionary* m_pPrograms; }; diff --git a/cocos2dx/include/CCTMXTiledMap.h b/cocos2dx/include/CCTMXTiledMap.h index 8ba06db577..091b280baa 100755 --- a/cocos2dx/include/CCTMXTiledMap.h +++ b/cocos2dx/include/CCTMXTiledMap.h @@ -117,11 +117,17 @@ namespace cocos2d { virtual ~CCTMXTiledMap(); /** creates a TMX Tiled Map with a TMX file.*/ - static CCTMXTiledMap * tiledMapWithTMXFile(const char *tmxFile); + static CCTMXTiledMap* tiledMapWithTMXFile(const char *tmxFile); + + /** initializes a TMX Tiled Map with a TMX formatted XML string and a path to TMX resources */ + static CCTMXTiledMap* tiledMapWithXML(const char* tmxString, const char* resourcePath); /** initializes a TMX Tiled Map with a TMX file */ bool initWithTMXFile(const char *tmxFile); + /** initializes a TMX Tiled Map with a TMX formatted XML string and a path to TMX resources */ + bool initWithXML(const char* tmxString, const char* resourcePath); + /** return the TMXLayer for the specific layer */ CCTMXLayer* layerNamed(const char *layerName); @@ -137,11 +143,10 @@ namespace cocos2d { private: CCTMXLayer * parseLayer(CCTMXLayerInfo *layerInfo, CCTMXMapInfo *mapInfo); CCTMXTilesetInfo * tilesetForLayer(CCTMXLayerInfo *layerInfo, CCTMXMapInfo *mapInfo); - + void buildWithMapInfo(CCTMXMapInfo* mapInfo); protected: //! tile properties CCDictionary *m_pTileProperties; - CCDictionary *m_pTMXLayers; }; diff --git a/cocos2dx/include/ccMacros.h b/cocos2dx/include/ccMacros.h index afc271cabc..c1a6f5d790 100644 --- a/cocos2dx/include/ccMacros.h +++ b/cocos2dx/include/ccMacros.h @@ -91,11 +91,14 @@ default gl blend src function. Compatible with premultiplied alpha images. Helpful macro that setups the GL server state, the correct GL program and sets the Model View Projection matrix @since v2.0 */ -#define CC_NODE_DRAW_SETUP() \ -do { \ - ccGLEnable( m_glServerState ); \ - m_pShaderProgram->use(); \ - m_pShaderProgram->setUniformForModelViewProjectionMatrix(); \ +#define CC_NODE_DRAW_SETUP() \ +do { \ + ccGLEnable( m_glServerState ); \ + if (getShaderProgram() != NULL) \ + { \ + getShaderProgram()->use(); \ + getShaderProgram()->setUniformForModelViewProjectionMatrix(); \ + } \ } while(0) @@ -246,7 +249,13 @@ It should work same as apples CFSwapInt32LittleToHost(..) #if !defined(COCOS2D_DEBUG) || COCOS2D_DEBUG == 0 #define CHECK_GL_ERROR_DEBUG() #else -#define CHECK_GL_ERROR_DEBUG() ({ GLenum __error = glGetError(); if(__error) CCLog("OpenGL error 0x%04X in %s %d\n", __error, __FUNCTION__, __LINE__); }) +#define CHECK_GL_ERROR_DEBUG() \ + do { \ + GLenum __error = glGetError(); \ + if(__error) { \ + CCLog("OpenGL error 0x%04X in %s %d\n", __error, __FUNCTION__, __LINE__); \ + } \ + } while (false) #endif /** @def CC_INCREMENT_GL_DRAWS_BY_ONE diff --git a/cocos2dx/particle_nodes/CCParticleBatchNode.cpp b/cocos2dx/particle_nodes/CCParticleBatchNode.cpp index 6fb10405ab..efff5fc216 100644 --- a/cocos2dx/particle_nodes/CCParticleBatchNode.cpp +++ b/cocos2dx/particle_nodes/CCParticleBatchNode.cpp @@ -379,7 +379,8 @@ void CCParticleBatchNode::removeChildAtIndex(unsigned int index, bool doCleanup) void CCParticleBatchNode::removeAllChildrenWithCleanup(bool doCleanup) { - //TODO: arrayMakeObjectsPerformSelector(m_pChildren, &CCParticleBatchNode::useSelfRender); + //TODO: useSelfRender is undefined. + //arrayMakeObjectsPerformSelectorWithType(m_pChildren, &CCParticleBatchNode::useSelfRender, CCParticleSystem); CCNode::removeAllChildrenWithCleanup(doCleanup); diff --git a/cocos2dx/particle_nodes/CCParticleSystem.cpp b/cocos2dx/particle_nodes/CCParticleSystem.cpp index 9bb9488976..4236da0d46 100644 --- a/cocos2dx/particle_nodes/CCParticleSystem.cpp +++ b/cocos2dx/particle_nodes/CCParticleSystem.cpp @@ -535,7 +535,7 @@ bool CCParticleSystem::isFull() // ParticleSystem - MainLoop void CCParticleSystem::update(ccTime dt) { - // TODO: CC_PROFILER_START_CATEGORY(kCCProfilerCategoryParticles , "CCParticleSystem - update"); + CC_PROFILER_START_CATEGORY(kCCProfilerCategoryParticles , "CCParticleSystem - update"); if( m_bIsActive && m_fEmissionRate ) { @@ -695,7 +695,7 @@ void CCParticleSystem::update(ccTime dt) if (!m_pBatchNode) postStep(); - //TODO: CC_PROFILER_STOP_CATEGORY(kCCProfilerCategoryParticles , "CCParticleSystem - update"); + CC_PROFILER_STOP_CATEGORY(kCCProfilerCategoryParticles , "CCParticleSystem - update"); } void CCParticleSystem::updateWithNoTime(void) diff --git a/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp b/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp index f1bed8e4ea..09bf298600 100644 --- a/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp +++ b/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp @@ -284,7 +284,7 @@ void CCParticleSystemQuad::postStep() glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(m_pQuads[0])*m_uParticleCount, m_pQuads); glBindBuffer(GL_ARRAY_BUFFER, 0); - // TODO: CHECK_GL_ERROR_DEBUG(); + CHECK_GL_ERROR_DEBUG(); } // overriding draw method @@ -400,7 +400,7 @@ void CCParticleSystemQuad::initVAO() glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glBindBuffer(GL_ARRAY_BUFFER, 0); - //TODO:CHECK_GL_ERROR_DEBUG(); + CHECK_GL_ERROR_DEBUG(); } bool CCParticleSystemQuad::allocMemory() diff --git a/cocos2dx/platform/platform.cpp b/cocos2dx/platform/platform.cpp index 725aef515c..b19ff24b37 100644 --- a/cocos2dx/platform/platform.cpp +++ b/cocos2dx/platform/platform.cpp @@ -38,14 +38,14 @@ int CCTime::gettimeofdayCocos2d(struct cc_timeval *tp, void *tzp) return 0; } -void CCTime::timersubCocos2d(struct cc_timeval *out, struct cc_timeval *start, struct cc_timeval *end) +double CCTime::timersubCocos2d(struct cc_timeval *start, struct cc_timeval *end) { - if (! out || ! start || ! end) + if (! start || ! end) { - return; + return 0; } - out->tv_sec = end->tv_sec - start->tv_sec; - out->tv_usec = end->tv_usec - start->tv_usec; + + return ((end->tv_sec*1000.0+end->tv_usec/1000.0) - (start->tv_sec*1000.0+start->tv_usec/1000.0)); } NS_CC_END; diff --git a/cocos2dx/platform/platform.h b/cocos2dx/platform/platform.h index 3e16e99f4f..bf235970d6 100644 --- a/cocos2dx/platform/platform.h +++ b/cocos2dx/platform/platform.h @@ -40,7 +40,7 @@ class CC_DLL CCTime { public: static int gettimeofdayCocos2d(struct cc_timeval *tp, void *tzp); - static void timersubCocos2d(struct cc_timeval *out, struct cc_timeval *start, struct cc_timeval *end); + static double timersubCocos2d(struct cc_timeval *start, struct cc_timeval *end); }; NS_CC_END; diff --git a/cocos2dx/proj.win32/cocos2d-win32.vcproj b/cocos2dx/proj.win32/cocos2d-win32.vcproj index e99ea5ea13..7bc0e29028 100644 --- a/cocos2dx/proj.win32/cocos2d-win32.vcproj +++ b/cocos2dx/proj.win32/cocos2d-win32.vcproj @@ -43,7 +43,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories="..\platform;..\platform\third_party\win32\iconv;..\platform\third_party\win32\zlib;..\platform\third_party\win32\libpng;..\platform\third_party\win32\libjpeg;..\platform\third_party\win32\libxml2;..\platform\third_party\win32\pthread;..\platform\third_party\win32\OGLES;..\shaders;..\include;..;..\kazmath\include" - PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES" + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;COCOS2D_DEBUG=1" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="3" diff --git a/cocos2dx/sprite_nodes/CCSprite.cpp b/cocos2dx/sprite_nodes/CCSprite.cpp index e9a9f831e4..42ae50be38 100644 --- a/cocos2dx/sprite_nodes/CCSprite.cpp +++ b/cocos2dx/sprite_nodes/CCSprite.cpp @@ -521,7 +521,7 @@ void CCSprite::updateTransform(void) void CCSprite::draw(void) { - // TODO: CC_PROFILER_START_CATEGORY(kCCProfilerCategorySprite, "CCSprite - draw"); + CC_PROFILER_START_CATEGORY(kCCProfilerCategorySprite, "CCSprite - draw"); CCAssert(!m_pobBatchNode, "If CCSprite is being rendered by CCSpriteBatchNode, CCSprite#draw SHOULD NOT be called"); @@ -562,7 +562,7 @@ void CCSprite::draw(void) glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - // TODO: CHECK_GL_ERROR_DEBUG(); + CHECK_GL_ERROR_DEBUG(); #if CC_SPRITE_DEBUG_DRAW == 1 @@ -587,7 +587,7 @@ void CCSprite::draw(void) CC_INCREMENT_GL_DRAWS(1); - // TODO: CC_PROFILER_STOP_CATEGORY(kCCProfilerCategorySprite, "CCSprite - draw"); + CC_PROFILER_STOP_CATEGORY(kCCProfilerCategorySprite, "CCSprite - draw"); } // CCNode overrides diff --git a/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp b/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp index 6165ce8146..e0fce84d0c 100644 --- a/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp +++ b/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp @@ -125,7 +125,7 @@ CCSpriteBatchNode::~CCSpriteBatchNode() // don't call visit on it's children void CCSpriteBatchNode::visit(void) { - // TODO: CC_PROFILER_START_CATEGORY(kCCProfilerCategoryBatchSprite, "CCSpriteBatchNode - visit"); + CC_PROFILER_START_CATEGORY(kCCProfilerCategoryBatchSprite, "CCSpriteBatchNode - visit"); CCAssert(m_pParent != NULL, "CCSpriteBatchNode should NOT be root node"); @@ -162,7 +162,7 @@ void CCSpriteBatchNode::visit(void) kmGLPopMatrix(); m_nOrderOfArrival = 0; - // TODO: CC_PROFILER_STOP_CATEGORY(kCCProfilerCategoryBatchSprite, @"CCSpriteBatchNode - visit"); + CC_PROFILER_STOP_CATEGORY(kCCProfilerCategoryBatchSprite, "CCSpriteBatchNode - visit"); } @@ -395,7 +395,7 @@ void CCSpriteBatchNode::reorderBatch(bool reorder) // draw void CCSpriteBatchNode::draw(void) { - // TODO: CC_PROFILER_START("CCSpriteBatchNode - draw"); + CC_PROFILER_START("CCSpriteBatchNode - draw"); // Optimization: Fast Dispatch if( m_pobTextureAtlas->getTotalQuads() == 0 ) @@ -409,7 +409,7 @@ void CCSpriteBatchNode::draw(void) m_pobTextureAtlas->drawQuads(); - // TODO: CC_PROFILER_STOP("CCSpriteBatchNode - draw"); + CC_PROFILER_STOP("CCSpriteBatchNode - draw"); } void CCSpriteBatchNode::increaseAtlasCapacity(void) diff --git a/cocos2dx/support/CCProfiling.cpp b/cocos2dx/support/CCProfiling.cpp index ed6f559f83..7e87947912 100644 --- a/cocos2dx/support/CCProfiling.cpp +++ b/cocos2dx/support/CCProfiling.cpp @@ -24,112 +24,152 @@ THE SOFTWARE. ****************************************************************************/ #include "CCProfiling.h" -#if CC_ENABLE_PROFILERS +using namespace std; -namespace cocos2d +NS_CC_BEGIN + +//#pragma mark - Profiling Categories +/* set to NO the categories that you don't want to profile */ +bool kCCProfilerCategorySprite = false; +bool kCCProfilerCategoryBatchSprite = false; +bool kCCProfilerCategoryParticles = false; + + +static CCProfiler* g_sSharedProfiler = NULL; + +CCProfiler* CCProfiler::sharedProfiler(void) { - using namespace std; - static CCProfiler *g_sSharedProfiler; - - CCProfiler* CCProfiler::sharedProfiler(void) + if (! g_sSharedProfiler) { - if (! g_sSharedProfiler) - { - g_sSharedProfiler = new CCProfiler(); - g_sSharedProfiler->init(); - } - - return g_sSharedProfiler; + g_sSharedProfiler = new CCProfiler(); + g_sSharedProfiler->init(); } - CCProfilingTimer* CCProfiler::timerWithName(const char *pszTimerName, CCObject *pInstance) - { - CCProfiler *p = CCProfiler::sharedProfiler(); - CCProfilingTimer *t = new CCProfilingTimer(); - t->initWithName(pszTimerName, pInstance); - p->m_pActiveTimers->addObject(t); - t->release(); + return g_sSharedProfiler; +} - return t; +CCProfilingTimer* CCProfiler::createAndAddTimerWithName(const char* timerName) +{ + CCProfiler *p = CCProfiler::sharedProfiler(); + CCProfilingTimer *t = new CCProfilingTimer(); + t->initWithName(timerName); + m_pActiveTimers->setObject(t, timerName); + t->release(); + + return t; +} + +void CCProfiler::releaseTimer(const char* timerName) +{ + m_pActiveTimers->removeObjectForKey(timerName); +} + +void CCProfiler::releaseAllTimers() +{ + m_pActiveTimers->removeAllObjects(); +} + +bool CCProfiler::init() +{ + m_pActiveTimers = new CCMutableDictionary(); + return true; +} + +CCProfiler::~CCProfiler(void) +{ + CC_SAFE_RELEASE(m_pActiveTimers); +} + +void CCProfiler::displayTimers() +{ + vector allKeys = m_pActiveTimers->allKeys(); + for (vector::iterator it = allKeys.begin(); it != allKeys.end(); ++it) + { + CCProfilingTimer* timer = m_pActiveTimers->objectForKey(*it); + CCLog(timer->description()); + } +} + +// implementation of CCProfilingTimer + +bool CCProfilingTimer::initWithName(const char* timerName) +{ + m_NameStr = timerName; + numberOfCalls = 0; + m_dAverageTime = 0.0; + totalTime = 0.0; + minTime = 10000.0; + maxTime = 0.0; + gettimeofday((struct timeval *)&m_sStartTime, NULL); + + return true; +} + +CCProfilingTimer::~CCProfilingTimer(void) +{ + +} + +const char* CCProfilingTimer::description() +{ + static char s_szDesciption[256] = {0}; + sprintf(s_szDesciption, "%s: avg time, %fms", m_NameStr.c_str(), m_dAverageTime); + return s_szDesciption; +} + +void CCProfilingTimer::reset() +{ + numberOfCalls = 0; + m_dAverageTime = 0; + totalTime = 0; + minTime = 10000; + maxTime = 0; + gettimeofday((struct timeval *)&m_sStartTime, NULL); +} + +void CCProfilingBeginTimingBlock(const char *timerName) +{ + CCProfiler* p = CCProfiler::sharedProfiler(); + CCProfilingTimer *timer = p->m_pActiveTimers->objectForKey(timerName); + if( ! timer ) + { + timer = p->createAndAddTimerWithName(timerName); } - void CCProfiler::releaseTimer(CCProfilingTimer *pTimer) - { - CCProfiler *p = CCProfiler::sharedProfiler(); - p->m_pActiveTimers->removeObject(pTimer); + gettimeofday((struct timeval *)&timer->m_sStartTime, NULL); - if (0 == (p->m_pActiveTimers->count())) - { - CC_SAFE_DELETE(g_sSharedProfiler); - } - } + timer->numberOfCalls++; +} - bool CCProfiler::init() - { - m_pActiveTimers = CCArray::array(); - m_pActiveTimers->retain(); +void CCProfilingEndTimingBlock(const char *timerName) +{ + CCProfiler* p = CCProfiler::sharedProfiler(); + CCProfilingTimer *timer = p->m_pActiveTimers->objectForKey(timerName); - return true; - } + CCAssert(timer, "CCProfilingTimer not found"); - CCProfiler::~CCProfiler(void) - { - CC_SAFE_RELEASE(m_pActiveTimers); - } + struct timeval currentTime; + gettimeofday(¤tTime, NULL); - void CCProfiler::displayTimers() - { - CCObject* pObject = NULL; - CCProfilingTimer* pTimer = NULL; - CCARRAY_FOREACH(m_pActiveTimers, pObject) - { - pTimer = (CCProfilingTimer*) pObject; - char *pszDescription = pTimer->description(); - CCLog(pszDescription); - delete pszDescription; - } - } + double duration = CCTime::timersubCocos2d((struct cc_timeval *)&timer->m_sStartTime, (struct cc_timeval *)¤tTime); - // implementation of CCProfilingTimer + // milliseconds + timer->m_dAverageTime = (timer->m_dAverageTime + duration) / 2.0f; + timer->totalTime += duration; + timer->maxTime = MAX( timer->maxTime, duration); + timer->minTime = MIN( timer->minTime, duration); - bool CCProfilingTimer::initWithName(const char* pszTimerName, CCObject *pInstance) - { - char tmp[160]; - sprintf(tmp, "%s (0x%.8x)", pszTimerName, (unsigned int)pInstance); - m_NameStr = string(tmp); - m_dAverageTime = 0.0; +} - return true; - } +void CCProfilingResetTimingBlock(const char *timerName) +{ + CCProfiler* p = CCProfiler::sharedProfiler(); + CCProfilingTimer *timer = p->m_pActiveTimers->objectForKey(timerName); - CCProfilingTimer::~CCProfilingTimer(void) - { - - } + CCAssert(timer, "CCProfilingTimer not found"); - char* CCProfilingTimer::description() - { - char *pszDes = new char[m_NameStr.length() + sizeof(double) + 32]; - sprintf(pszDes, "%s: avg time, %fms", m_NameStr.c_str(), m_dAverageTime); - return pszDes; - } + timer->reset(); +} - void CCProfilingBeginTimingBlock(CCProfilingTimer *pTimer) - { - CCTime::gettimeofdayCocos2d(pTimer->getStartTime(), NULL); - } +NS_CC_END - void CCProfilingEndTimingBlock(CCProfilingTimer *pTimer) - { - struct cc_timeval currentTime; - CCTime::gettimeofdayCocos2d(¤tTime, NULL); - CCTime::timersubCocos2d(¤tTime, pTimer->getStartTime(), ¤tTime); - double duration = currentTime.tv_sec * 1000.0 + currentTime.tv_usec / 1000.0; - - // return in milliseconds - pTimer->setAverageTime((pTimer->getAverageTime() + duration) / 2.0f); - } - -} // end of namespace cocos2d - -#endif // CC_ENABLE_PROFILERS diff --git a/cocos2dx/support/CCProfiling.h b/cocos2dx/support/CCProfiling.h index 8c1203fb9a..8ca587ce35 100644 --- a/cocos2dx/support/CCProfiling.h +++ b/cocos2dx/support/CCProfiling.h @@ -26,55 +26,75 @@ THE SOFTWARE. #define __SUPPORT_CCPROFILING_H__ #include "ccConfig.h" - -#if CC_ENABLE_PROFILERS - #include - #include "CCObject.h" #include "platform/platform.h" -#include "CCArray.h" +#include "CCMutableDictionary.h" -namespace cocos2d +NS_CC_BEGIN + +class CCProfilingTimer; + +/** CCProfiler + cocos2d builtin profiler. + + To use it, enable set the CC_ENABLE_PROFILERS=1 in the ccConfig.h file + */ + +class CC_DLL CCProfiler : public CCObject { - class CCProfilingTimer; +public: + ~CCProfiler(void); + /** display the timers */ + void displayTimers(void); + bool init(void); - class CC_DLL CCProfiler : public CCObject - { - public: - ~CCProfiler(void); - void displayTimers(void); - bool init(void); +public: + static CCProfiler* sharedProfiler(void); + /** Creates and adds a new timer */ + CCProfilingTimer* createAndAddTimerWithName(const char* timerName); + /** releases a timer */ + void releaseTimer(const char* timerName); + /** releases all timers */ + void releaseAllTimers(); - public: - static CCProfiler* sharedProfiler(void); - static CCProfilingTimer* timerWithName(const char *pszTimerName, CCObject *pInstance); - static void releaseTimer(CCProfilingTimer *pTimer); + CCMutableDictionary* m_pActiveTimers; +}; - protected: - CCArray *m_pActiveTimers; - }; +class CCProfilingTimer : public CCObject +{ +public: + bool initWithName(const char* timerName); + ~CCProfilingTimer(void); + const char* description(void); + inline struct cc_timeval * getStartTime(void) { return &m_sStartTime; }; + inline void setAverageTime(double value) { m_dAverageTime = value; } + inline double getAverageTime(void) { return m_dAverageTime; } + /** resets the timer properties */ + void reset(); - class CCProfilingTimer : public CCObject - { - public: - bool initWithName(const char* pszTimerName, CCObject *pInstance); - ~CCProfilingTimer(void); - char* description(void); - inline struct cc_timeval * getStartTime(void) { return &m_sStartTime; }; - inline void setAverageTime(double value) { m_dAverageTime = value; } - inline double getAverageTime(void) { return m_dAverageTime; } + std::string m_NameStr; + struct cc_timeval m_sStartTime; + double m_dAverageTime; + double minTime; + double maxTime; + double totalTime; + unsigned int numberOfCalls; +}; - protected: - std::string m_NameStr; - struct cc_timeval m_sStartTime; - double m_dAverageTime; - }; +extern void CCProfilingBeginTimingBlock(const char *timerName); +extern void CCProfilingEndTimingBlock(const char *timerName); +extern void CCProfilingResetTimingBlock(const char *timerName); - void CC_DLL CCProfilingBeginTimingBlock(CCProfilingTimer *pTimer); - void CC_DLL CCProfilingEndTimingBlock(CCProfilingTimer *pTimer); +/* + * cocos2d profiling categories + * used to enable / disable profilers with granularity + */ -} // end of namespace cocos2d +extern bool kCCProfilerCategorySprite; +extern bool kCCProfilerCategoryBatchSprite; +extern bool kCCProfilerCategoryParticles; + +NS_CC_END -#endif // CC_ENABLE_PROFILERS #endif // __SUPPORT_CCPROFILING_H__ diff --git a/cocos2dx/textures/CCTextureAtlas.cpp b/cocos2dx/textures/CCTextureAtlas.cpp index f7e14a115b..a196e0630e 100644 --- a/cocos2dx/textures/CCTextureAtlas.cpp +++ b/cocos2dx/textures/CCTextureAtlas.cpp @@ -243,7 +243,7 @@ void CCTextureAtlas::initVAO() glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glBindBuffer(GL_ARRAY_BUFFER, 0); - //TODO: CHECK_GL_ERROR_DEBUG(); + CHECK_GL_ERROR_DEBUG(); } void CCTextureAtlas::mapBuffers() @@ -259,7 +259,7 @@ void CCTextureAtlas::mapBuffers() glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(m_pIndices[0]) * m_uCapacity * 6, m_pIndices, GL_STATIC_DRAW); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - // TODO: CHECK_GL_ERROR_DEBUG(); + CHECK_GL_ERROR_DEBUG(); } // TextureAtlas - Update, Insert, Move & Remove @@ -547,7 +547,7 @@ void CCTextureAtlas::drawNumberOfQuads(unsigned int n, unsigned int start) glBindVertexArray(0); - // TODO: CHECK_GL_ERROR_DEBUG(); + CHECK_GL_ERROR_DEBUG(); } diff --git a/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.cpp b/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.cpp index 1083707e35..1e745326e2 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.cpp +++ b/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.cpp @@ -210,8 +210,11 @@ void CCTMXLayer::parseInternalProperties() { m_bUseAutomaticVertexZ = true; CCString *alphaFuncVal = propertyNamed("cc_alpha_func"); - float alphaFuncValue = alphaFuncVal->toFloat(); - + float alphaFuncValue = 0.0f; + if (alphaFuncVal != NULL) + { + alphaFuncValue = alphaFuncVal->toFloat(); + } setShaderProgram(CCShaderCache::sharedShaderCache()->programForKey(kCCShader_PositionTextureColorAlphaTest)); GLint alphaValueLocation = glGetUniformLocation(getShaderProgram()->getProgram(), kCCUniformAlphaTestValue); diff --git a/cocos2dx/tileMap_parallax_nodes/CCTMXTiledMap.cpp b/cocos2dx/tileMap_parallax_nodes/CCTMXTiledMap.cpp index f1c8dcb57b..17b3bdac2e 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTMXTiledMap.cpp +++ b/cocos2dx/tileMap_parallax_nodes/CCTMXTiledMap.cpp @@ -29,213 +29,259 @@ THE SOFTWARE. #include "CCSprite.h" #include "CCPointExtension.h" -namespace cocos2d{ +NS_CC_BEGIN - // implementation CCTMXTiledMap - CCTMXTiledMap * CCTMXTiledMap::tiledMapWithTMXFile(const char *tmxFile) +// implementation CCTMXTiledMap +CCTMXTiledMap * CCTMXTiledMap::tiledMapWithTMXFile(const char *tmxFile) +{ + CCTMXTiledMap *pRet = new CCTMXTiledMap(); + if (pRet->initWithTMXFile(tmxFile)) { - CCTMXTiledMap *pRet = new CCTMXTiledMap(); - if (pRet->initWithTMXFile(tmxFile)) - { - pRet->autorelease(); - return pRet; - } - CC_SAFE_DELETE(pRet); - return NULL; - } - bool CCTMXTiledMap::initWithTMXFile(const char *tmxFile) - { - CCAssert(tmxFile != NULL && strlen(tmxFile)>0, "TMXTiledMap: tmx file should not bi nil"); - - setContentSize(CCSizeZero); - - CCTMXMapInfo *mapInfo = CCTMXMapInfo::formatWithTMXFile(tmxFile); - - if (! mapInfo) - { - return false; - } - CCAssert( mapInfo->getTilesets()->count() != 0, "TMXTiledMap: Map not found. Please check the filename."); - - m_tMapSize = mapInfo->getMapSize(); - m_tTileSize = mapInfo->getTileSize(); - m_nMapOrientation = mapInfo->getOrientation(); - setObjectGroups(mapInfo->getObjectGroups()); - setProperties(mapInfo->getProperties()); - CC_SAFE_RELEASE(m_pTileProperties); - m_pTileProperties = mapInfo->getTileProperties(); - CC_SAFE_RETAIN(m_pTileProperties); - - int idx = 0; - - CCMutableArray* layers = mapInfo->getLayers(); - if (layers && layers->count()>0) - { - if (NULL == m_pTMXLayers) - { - m_pTMXLayers = new CCDictionary(); - CCAssert(m_pTMXLayers, "Allocate memory failed!"); - } - - CCTMXLayerInfo *layerInfo = NULL; - CCMutableArray::CCMutableArrayIterator it; - for (it = layers->begin(); it != layers->end(); ++it) - { - layerInfo = *it; - if (layerInfo && layerInfo->m_bVisible) - { - CCTMXLayer *child = parseLayer(layerInfo, mapInfo); - addChild((CCNode*)child, idx, idx); - - // record the CCTMXLayer object by it's name - std::string layerName = child->getLayerName(); - m_pTMXLayers->setObject(child, layerName); - - // update content size with the max size - const CCSize& childSize = child->getContentSize(); - CCSize currentSize = this->getContentSize(); - currentSize.width = MAX( currentSize.width, childSize.width ); - currentSize.height = MAX( currentSize.height, childSize.height ); - this->setContentSize(currentSize); - - idx++; - } - } - } - return true; - } - CCTMXTiledMap::CCTMXTiledMap() - :m_tMapSize(CCSizeZero) - ,m_tTileSize(CCSizeZero) - ,m_pObjectGroups(NULL) - ,m_pProperties(NULL) - ,m_pTileProperties(NULL) - ,m_pTMXLayers(NULL) - { - } - CCTMXTiledMap::~CCTMXTiledMap() - { - CC_SAFE_RELEASE(m_pProperties); - CC_SAFE_RELEASE(m_pObjectGroups); - CC_SAFE_RELEASE(m_pTileProperties); - CC_SAFE_RELEASE(m_pTMXLayers); - } - CCMutableArray * CCTMXTiledMap::getObjectGroups() - { - return m_pObjectGroups; - } - void CCTMXTiledMap::setObjectGroups(CCMutableArray* var) - { - CC_SAFE_RETAIN(var); - CC_SAFE_RELEASE(m_pObjectGroups); - m_pObjectGroups = var; - } - CCStringToStringDictionary * CCTMXTiledMap::getProperties() - { - return m_pProperties; - } - void CCTMXTiledMap::setProperties(CCStringToStringDictionary* var) - { - CC_SAFE_RETAIN(var); - CC_SAFE_RELEASE(m_pProperties); - m_pProperties = var; - } - // private - CCTMXLayer * CCTMXTiledMap::parseLayer(CCTMXLayerInfo *layerInfo, CCTMXMapInfo *mapInfo) - { - CCTMXTilesetInfo *tileset = tilesetForLayer(layerInfo, mapInfo); - CCTMXLayer *layer = CCTMXLayer::layerWithTilesetInfo(tileset, layerInfo, mapInfo); - - // tell the layerinfo to release the ownership of the tiles map. - layerInfo->m_bOwnTiles = false; - layer->setupTiles(); - - return layer; - } - - CCTMXTilesetInfo * CCTMXTiledMap::tilesetForLayer(CCTMXLayerInfo *layerInfo, CCTMXMapInfo *mapInfo) - { - CCSize size = layerInfo->m_tLayerSize; - CCMutableArray* tilesets = mapInfo->getTilesets(); - if (tilesets && tilesets->count()>0) - { - CCTMXTilesetInfo *tileset = NULL; - CCMutableArray::CCMutableArrayRevIterator rit; - for (rit = tilesets->rbegin(); rit != tilesets->rend(); ++rit) - { - tileset = *rit; - if (tileset) - { - for( unsigned int y=0; y < size.height; y++ ) - { - for( unsigned int x=0; x < size.width; x++ ) - { - unsigned int pos = (unsigned int)(x + size.width * y); - unsigned int gid = layerInfo->m_pTiles[ pos ]; - - // gid are stored in little endian. - // if host is big endian, then swap - //if( o == CFByteOrderBigEndian ) - // gid = CFSwapInt32( gid ); - /* We support little endian.*/ - - // XXX: gid == 0 --> empty tile - if( gid != 0 ) - { - // Optimization: quick return - // if the layer is invalid (more than 1 tileset per layer) an CCAssert will be thrown later - if( gid >= tileset->m_uFirstGid ) - return tileset; - } - } - } - } - } - } - - // If all the tiles are 0, return empty tileset - CCLOG("cocos2d: Warning: TMX Layer '%@' has no tiles", layerInfo->m_sName.c_str()); - return NULL; - } - - - // public - CCTMXLayer * CCTMXTiledMap::layerNamed(const char *layerName) - { - std::string sLayerName = layerName; - CCTMXLayer * pRet = m_pTMXLayers->objectForKey(sLayerName); + pRet->autorelease(); return pRet; } - CCTMXObjectGroup * CCTMXTiledMap::objectGroupNamed(const char *groupName) + CC_SAFE_DELETE(pRet); + return NULL; +} + +CCTMXTiledMap* CCTMXTiledMap::tiledMapWithXML(const char* tmxString, const char* resourcePath) +{ + CCTMXTiledMap *pRet = new CCTMXTiledMap(); + if (pRet->initWithXML(tmxString, resourcePath)) { - std::string sGroupName = groupName; - if (m_pObjectGroups && m_pObjectGroups->count()>0) + pRet->autorelease(); + return pRet; + } + CC_SAFE_DELETE(pRet); + return NULL; +} + +bool CCTMXTiledMap::initWithTMXFile(const char *tmxFile) +{ + CCAssert(tmxFile != NULL && strlen(tmxFile)>0, "TMXTiledMap: tmx file should not bi NULL"); + + setContentSize(CCSizeZero); + + CCTMXMapInfo *mapInfo = CCTMXMapInfo::formatWithTMXFile(tmxFile); + + if (! mapInfo) + { + return false; + } + CCAssert( mapInfo->getTilesets()->count() != 0, "TMXTiledMap: Map not found. Please check the filename."); + buildWithMapInfo(mapInfo); + + return true; +} + +bool CCTMXTiledMap::initWithXML(const char* tmxString, const char* resourcePath) +{ + setContentSize(CCSizeZero); + + CCTMXMapInfo *mapInfo = CCTMXMapInfo::formatWithXML(tmxString, resourcePath); + + CCAssert( mapInfo->getTilesets()->count() != 0, "TMXTiledMap: Map not found. Please check the filename."); + buildWithMapInfo(mapInfo); + + return true; +} + +CCTMXTiledMap::CCTMXTiledMap() + :m_tMapSize(CCSizeZero) + ,m_tTileSize(CCSizeZero) + ,m_pObjectGroups(NULL) + ,m_pProperties(NULL) + ,m_pTileProperties(NULL) +{ +} +CCTMXTiledMap::~CCTMXTiledMap() +{ + CC_SAFE_RELEASE(m_pProperties); + CC_SAFE_RELEASE(m_pObjectGroups); + CC_SAFE_RELEASE(m_pTileProperties); +} + +CCMutableArray * CCTMXTiledMap::getObjectGroups() +{ + return m_pObjectGroups; +} + +void CCTMXTiledMap::setObjectGroups(CCMutableArray* var) +{ + CC_SAFE_RETAIN(var); + CC_SAFE_RELEASE(m_pObjectGroups); + m_pObjectGroups = var; +} + +CCStringToStringDictionary * CCTMXTiledMap::getProperties() +{ + return m_pProperties; +} + +void CCTMXTiledMap::setProperties(CCStringToStringDictionary* var) +{ + CC_SAFE_RETAIN(var); + CC_SAFE_RELEASE(m_pProperties); + m_pProperties = var; +} + +// private +CCTMXLayer * CCTMXTiledMap::parseLayer(CCTMXLayerInfo *layerInfo, CCTMXMapInfo *mapInfo) +{ + CCTMXTilesetInfo *tileset = tilesetForLayer(layerInfo, mapInfo); + CCTMXLayer *layer = CCTMXLayer::layerWithTilesetInfo(tileset, layerInfo, mapInfo); + + // tell the layerinfo to release the ownership of the tiles map. + layerInfo->m_bOwnTiles = false; + layer->setupTiles(); + + return layer; +} + +CCTMXTilesetInfo * CCTMXTiledMap::tilesetForLayer(CCTMXLayerInfo *layerInfo, CCTMXMapInfo *mapInfo) +{ + CCSize size = layerInfo->m_tLayerSize; + CCMutableArray* tilesets = mapInfo->getTilesets(); + if (tilesets && tilesets->count()>0) + { + CCTMXTilesetInfo *tileset = NULL; + CCMutableArray::CCMutableArrayRevIterator rit; + for (rit = tilesets->rbegin(); rit != tilesets->rend(); ++rit) { - CCTMXObjectGroup *objectGroup; - CCMutableArray::CCMutableArrayIterator it; - for (it = m_pObjectGroups->begin(); it != m_pObjectGroups->end(); ++it) + tileset = *rit; + if (tileset) { - objectGroup = (CCTMXObjectGroup*)(*it); - if (objectGroup && objectGroup->getGroupName() == sGroupName) + for( unsigned int y=0; y < size.height; y++ ) { - return objectGroup; - } + for( unsigned int x=0; x < size.width; x++ ) + { + unsigned int pos = (unsigned int)(x + size.width * y); + unsigned int gid = layerInfo->m_pTiles[ pos ]; + + // gid are stored in little endian. + // if host is big endian, then swap + //if( o == CFByteOrderBigEndian ) + // gid = CFSwapInt32( gid ); + /* We support little endian.*/ + + // XXX: gid == 0 --> empty tile + if( gid != 0 ) + { + // Optimization: quick return + // if the layer is invalid (more than 1 tileset per layer) an CCAssert will be thrown later + if( (gid & kCCFlippedMask) >= tileset->m_uFirstGid ) + return tileset; + } + } + } } } - - // objectGroup not found - return NULL; } - CCString * CCTMXTiledMap::propertyNamed(const char *propertyName) + // If all the tiles are 0, return empty tileset + CCLOG("cocos2d: Warning: TMX Layer '%@' has no tiles", layerInfo->m_sName.c_str()); + return NULL; +} + +void CCTMXTiledMap::buildWithMapInfo(CCTMXMapInfo* mapInfo) +{ + m_tMapSize = mapInfo->getMapSize(); + m_tTileSize = mapInfo->getTileSize(); + m_nMapOrientation = mapInfo->getOrientation(); + + CC_SAFE_RELEASE(m_pObjectGroups); + m_pObjectGroups = mapInfo->getObjectGroups(); + CC_SAFE_RETAIN(m_pObjectGroups); + + CC_SAFE_RELEASE(m_pProperties); + m_pProperties = mapInfo->getProperties(); + CC_SAFE_RETAIN(m_pProperties); + + CC_SAFE_RELEASE(m_pTileProperties); + m_pTileProperties = mapInfo->getTileProperties(); + CC_SAFE_RETAIN(m_pTileProperties); + + int idx=0; + + CCMutableArray* layers = mapInfo->getLayers(); + if (layers && layers->count()>0) { - return m_pProperties->objectForKey(std::string(propertyName)); + CCTMXLayerInfo *layerInfo = NULL; + CCMutableArray::CCMutableArrayIterator it; + for (it = layers->begin(); it != layers->end(); ++it) + { + layerInfo = *it; + if (layerInfo && layerInfo->m_bVisible) + { + CCTMXLayer *child = parseLayer(layerInfo, mapInfo); + addChild((CCNode*)child, idx, idx); + + // update content size with the max size + const CCSize& childSize = child->getContentSize(); + CCSize currentSize = this->getContentSize(); + currentSize.width = MAX( currentSize.width, childSize.width ); + currentSize.height = MAX( currentSize.height, childSize.height ); + this->setContentSize(currentSize); + + idx++; + } + } } - CCDictionary * CCTMXTiledMap::propertiesForGID(int GID) +} + +// public +CCTMXLayer * CCTMXTiledMap::layerNamed(const char *layerName) +{ + CCAssert(layerName != NULL && strlen(layerName) > 0, "Invalid layer name!"); + CCObject* pObj = NULL; + CCARRAY_FOREACH(m_pChildren, pObj) { - return m_pTileProperties->objectForKey(GID); + CCTMXLayer* layer = dynamic_cast(pObj); + if(layer) + { + if(0 == strcmp(layer->getLayerName(), layerName)) + { + return layer; + } + } } + + // layer not found + return NULL; +} + +CCTMXObjectGroup * CCTMXTiledMap::objectGroupNamed(const char *groupName) +{ + CCAssert(groupName != NULL && strlen(groupName) > 0, "Invalid group name!"); + + std::string sGroupName = groupName; + if (m_pObjectGroups && m_pObjectGroups->count()>0) + { + CCTMXObjectGroup *objectGroup; + CCMutableArray::CCMutableArrayIterator it; + for (it = m_pObjectGroups->begin(); it != m_pObjectGroups->end(); ++it) + { + objectGroup = (CCTMXObjectGroup*)(*it); + if (objectGroup && objectGroup->getGroupName() == sGroupName) + { + return objectGroup; + } + } + } + + // objectGroup not found + return NULL; +} + +CCString * CCTMXTiledMap::propertyNamed(const char *propertyName) +{ + return m_pProperties->objectForKey(std::string(propertyName)); +} +CCDictionary * CCTMXTiledMap::propertiesForGID(int GID) +{ + return m_pTileProperties->objectForKey(GID); +} -}// namespace cocos2d +NS_CC_END diff --git a/tests/Resources/TileMaps/hexa-tiles.png.REMOVED.git-id b/tests/Resources/TileMaps/hexa-tiles.png.REMOVED.git-id index 12596d37ed..ee6c0bcf5a 100644 --- a/tests/Resources/TileMaps/hexa-tiles.png.REMOVED.git-id +++ b/tests/Resources/TileMaps/hexa-tiles.png.REMOVED.git-id @@ -1 +1 @@ -6869c5352bc6510dba54803f5f4459b0a6a3fcf2 \ No newline at end of file +67b1f4a471f50a0df9c0bcd97d27b474d91f28e2 \ No newline at end of file diff --git a/tests/Resources/TileMaps/ortho-test1.png.REMOVED.git-id b/tests/Resources/TileMaps/ortho-test1.png.REMOVED.git-id index 303efad475..71f51ac865 100644 --- a/tests/Resources/TileMaps/ortho-test1.png.REMOVED.git-id +++ b/tests/Resources/TileMaps/ortho-test1.png.REMOVED.git-id @@ -1 +1 @@ -d13ddb0931c1772127b38010990140adce837bc8 \ No newline at end of file +cc8dd1d0d875569db4112955e0305486374285ae \ No newline at end of file diff --git a/tests/Resources/TileMaps/ortho-test1_bw.png.REMOVED.git-id b/tests/Resources/TileMaps/ortho-test1_bw.png.REMOVED.git-id new file mode 100644 index 0000000000..4294a3274d --- /dev/null +++ b/tests/Resources/TileMaps/ortho-test1_bw.png.REMOVED.git-id @@ -0,0 +1 @@ +a648cdbe1a0668d60bcee196aea024055767496c \ No newline at end of file diff --git a/tests/tests/DrawPrimitivesTest/DrawPrimitivesTest.cpp b/tests/tests/DrawPrimitivesTest/DrawPrimitivesTest.cpp index 3f653aeca7..9da2d004bf 100644 --- a/tests/tests/DrawPrimitivesTest/DrawPrimitivesTest.cpp +++ b/tests/tests/DrawPrimitivesTest/DrawPrimitivesTest.cpp @@ -8,7 +8,7 @@ void DrawPrimitivesTest::draw() { CCSize s = CCDirector::sharedDirector()->getWinSize(); - //TODO: CHECK_GL_ERROR_DEBUG(); + CHECK_GL_ERROR_DEBUG(); // draw a simple line // The default state is: @@ -18,7 +18,7 @@ void DrawPrimitivesTest::draw() // glEnable(GL_LINE_SMOOTH); ccDrawLine( ccp(0, 0), ccp(s.width, s.height) ); - //TODO: CHECK_GL_ERROR_DEBUG(); + CHECK_GL_ERROR_DEBUG(); // line: color, width, aliased // glLineWidth > 1 and GL_LINE_SMOOTH are not compatible @@ -28,7 +28,7 @@ void DrawPrimitivesTest::draw() ccDrawColor4B(255,0,0,255); ccDrawLine( ccp(0, s.height), ccp(s.width, 0) ); - //TODO: CHECK_GL_ERROR_DEBUG(); + CHECK_GL_ERROR_DEBUG(); // TIP: // If you are going to use always the same color or width, you don't @@ -41,7 +41,7 @@ void DrawPrimitivesTest::draw() ccDrawColor4B(0,0,255,128); ccDrawPoint( ccp(s.width / 2, s.height / 2) ); - //TODO: CHECK_GL_ERROR_DEBUG(); + CHECK_GL_ERROR_DEBUG(); // draw 4 small points CCPoint points[] = { ccp(60,60), ccp(70,70), ccp(60,70), ccp(70,60) }; @@ -49,21 +49,21 @@ void DrawPrimitivesTest::draw() ccDrawColor4B(0,255,255,255); ccDrawPoints( points, 4); - //TODO: CHECK_GL_ERROR_DEBUG(); + CHECK_GL_ERROR_DEBUG(); // draw a green circle with 10 segments glLineWidth(16); ccDrawColor4B(0, 255, 0, 255); ccDrawCircle( ccp(s.width/2, s.height/2), 100, 0, 10, false); - //TODO: CHECK_GL_ERROR_DEBUG(); + CHECK_GL_ERROR_DEBUG(); // draw a green circle with 50 segments with line to center glLineWidth(2); ccDrawColor4B(0, 255, 255, 255); ccDrawCircle( ccp(s.width/2, s.height/2), 50, CC_DEGREES_TO_RADIANS(90), 50, true); - //TODO: CHECK_GL_ERROR_DEBUG(); + CHECK_GL_ERROR_DEBUG(); // open yellow poly ccDrawColor4B(255, 255, 0, 255); @@ -71,7 +71,7 @@ void DrawPrimitivesTest::draw() CCPoint vertices[] = { ccp(0,0), ccp(50,50), ccp(100,50), ccp(100,100), ccp(50,100) }; ccDrawPoly( vertices, 5, false); - //TODO: CHECK_GL_ERROR_DEBUG(); + CHECK_GL_ERROR_DEBUG(); // closed purble poly ccDrawColor4B(255, 0, 255, 255); @@ -79,24 +79,24 @@ void DrawPrimitivesTest::draw() CCPoint vertices2[] = { ccp(30,130), ccp(30,230), ccp(50,200) }; ccDrawPoly( vertices2, 3, true); - //TODO: CHECK_GL_ERROR_DEBUG(); + CHECK_GL_ERROR_DEBUG(); // draw quad bezier path ccDrawQuadBezier(ccp(0,s.height), ccp(s.width/2,s.height/2), ccp(s.width,s.height), 50); - //TODO: CHECK_GL_ERROR_DEBUG(); + CHECK_GL_ERROR_DEBUG(); // draw cubic bezier path ccDrawCubicBezier(ccp(s.width/2, s.height/2), ccp(s.width/2+30,s.height/2+50), ccp(s.width/2+60,s.height/2-50),ccp(s.width, s.height/2),100); - //TODO: CHECK_GL_ERROR_DEBUG(); + CHECK_GL_ERROR_DEBUG(); // restore original values glLineWidth(1); ccDrawColor4B(255,255,255,255); ccPointSize(1); - //TODO: CHECK_GL_ERROR_DEBUG(); + CHECK_GL_ERROR_DEBUG(); } void DrawPrimitivesTestScene::runThisTest() diff --git a/tests/tests/TileMapTest/TileMapTest.cpp b/tests/tests/TileMapTest/TileMapTest.cpp index a0e4a810f5..6f215afa52 100644 --- a/tests/tests/TileMapTest/TileMapTest.cpp +++ b/tests/tests/TileMapTest/TileMapTest.cpp @@ -940,7 +940,7 @@ TMXIsoVertexZ::TMXIsoVertexZ() CCSize s = map->getContentSize(); map->setPosition( ccp(-s.width/2,0) ); - ////----UXLOG("ContentSize: %f, %f", s.width,s.height); + CCLOG("ContentSize: %f, %f", s.width,s.height); // because I'm lazy, I'm reusing a tile as an sprite, but since this method uses vertexZ, you // can use any CCSprite and it will work OK.