Merge branch 'gles20' of github.com:dualface/cocos2d-x into gles20

This commit is contained in:
dualface 2012-09-14 18:00:30 +08:00
commit 2866fa8f56
1 changed files with 15 additions and 10 deletions

View File

@ -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<numberOfPoints;i++) {
newPoli[i].x = poli[i].x;
newPoli[i].y = poli[i].y;
}
glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, newPoli);
if( closePolygon )
glDrawArrays(GL_LINE_LOOP, 0, (GLsizei) numberOfPoints);
else
glDrawArrays(GL_LINE_STRIP, 0, (GLsizei) numberOfPoints);
CC_SAFE_DELETE_ARRAY(newPoli);
}
if( closePolygon )
glDrawArrays(GL_LINE_LOOP, 0, (GLsizei) numberOfPoints);
else
glDrawArrays(GL_LINE_STRIP, 0, (GLsizei) numberOfPoints);
CC_SAFE_DELETE_ARRAY(newPoli);
CC_INCREMENT_GL_DRAWS(1);
}