| 197 | } |
| 198 | |
| 199 | void ccDrawPoly( const DPoint *poli, unsigned int numberOfPoints, bool closePolygon ) |
| 200 | { |
| 201 | lazy_init(); |
| 202 | |
| 203 | s_pShader->use(); |
| 204 | s_pShader->setUniformsForBuiltins(); |
| 205 | s_pShader->setUniformLocationWith4fv(s_nColorLocation, (GLfloat*) &s_tColor.r, 1); |
| 206 | |
| 207 | ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position ); |
| 208 | |
| 209 | // iPhone and 32-bit machines optimization |
| 210 | if( sizeof(DPoint) == sizeof(ccVertex2F) ) |
| 211 | { |
| 212 | #ifdef EMSCRIPTEN |
| 213 | setGLBufferData((void*) poli, numberOfPoints * sizeof(DPoint)); |
| 214 | glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0); |
| 215 | #else |
| 216 | glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, poli); |
| 217 | #endif // EMSCRIPTEN |
| 218 | |
| 219 | if( closePolygon ) |
| 220 | glDrawArrays(GL_LINE_LOOP, 0, (GLsizei) numberOfPoints); |
| 221 | else |
| 222 | glDrawArrays(GL_LINE_STRIP, 0, (GLsizei) numberOfPoints); |
| 223 | } |
| 224 | else |
| 225 | { |
| 226 | // Mac on 64-bit |
| 227 | // XXX: Mac OpenGL error. arrays can't go out of scope before draw is executed |
| 228 | ccVertex2F* newPoli = new ccVertex2F[numberOfPoints]; |
| 229 | for( unsigned int i=0; i<numberOfPoints;i++) { |
| 230 | newPoli[i].x = poli[i].x; |
| 231 | newPoli[i].y = poli[i].y; |
| 232 | } |
| 233 | #ifdef EMSCRIPTEN |
| 234 | setGLBufferData(newPoli, numberOfPoints * sizeof(ccVertex2F)); |
| 235 | glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0); |
| 236 | #else |
| 237 | glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, newPoli); |
| 238 | #endif // EMSCRIPTEN |
| 239 | |
| 240 | if( closePolygon ) |
| 241 | glDrawArrays(GL_LINE_LOOP, 0, (GLsizei) numberOfPoints); |
| 242 | else |
| 243 | glDrawArrays(GL_LINE_STRIP, 0, (GLsizei) numberOfPoints); |
| 244 | |
| 245 | CC_SAFE_DELETE_ARRAY(newPoli); |
| 246 | } |
| 247 | } |
| 248 | |
| 249 | void ccDrawSolidPoly( const DPoint *poli, unsigned int numberOfPoints, CAColor4F color ) |
| 250 | { |
no test coverage detected