From 2869aba7b49f3851247df169acbda0fc76de112f Mon Sep 17 00:00:00 2001 From: dualface Date: Fri, 14 Sep 2012 17:54:53 +0800 Subject: [PATCH] avoid unused memory alloc --- cocos2dx/CCDrawingPrimitives.cpp | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/cocos2dx/CCDrawingPrimitives.cpp b/cocos2dx/CCDrawingPrimitives.cpp index 085ba16c1b..0b07e47334 100644 --- a/cocos2dx/CCDrawingPrimitives.cpp +++ b/cocos2dx/CCDrawingPrimitives.cpp @@ -186,30 +186,35 @@ void ccDrawPoly( const CCPoint *poli, unsigned int numberOfPoints, bool closePol ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position ); - // XXX: Mac OpenGL error. arrays can't go out of scope before draw is executed - ccVertex2F* newPoli = new ccVertex2F[numberOfPoints]; - // iPhone and 32-bit machines optimization if( sizeof(CCPoint) == sizeof(ccVertex2F) ) + { glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, poli); + if( closePolygon ) + glDrawArrays(GL_LINE_LOOP, 0, (GLsizei) numberOfPoints); + else + glDrawArrays(GL_LINE_STRIP, 0, (GLsizei) numberOfPoints); + } else { // Mac on 64-bit + // XXX: Mac OpenGL error. arrays can't go out of scope before draw is executed + ccVertex2F* newPoli = new ccVertex2F[numberOfPoints]; for( unsigned int i=0; i