| 283 | | glDrawArrays(_primitiveMode, 0, _vertices->size()); |
| 284 | | } |
| | 283 | if (_primitiveMode==GL_QUADS) |
| | 284 | { |
| | 285 | unsigned int numQuads = _vertices->size()/4; |
| | 286 | unsigned int numIndices = numQuads * 6; |
| | 287 | if (numIndices > _indexArray.size()) |
| | 288 | { |
| | 289 | // we need to expand the _indexArray to be big enough to cope with all the quads required. |
| | 290 | unsigned int numExistingQuads = _indexArray.size()/6; |
| | 291 | _indexArray.reserve(numIndices); |
| | 292 | for(unsigned int i=numExistingQuads; i<numQuads; ++i) |
| | 293 | { |
| | 294 | unsigned int base = i*4; |
| | 295 | _indexArray.push_back(base); |
| | 296 | _indexArray.push_back(base+2); |
| | 297 | _indexArray.push_back(base+1); |
| | 298 | |
| | 299 | _indexArray.push_back(base); |
| | 300 | _indexArray.push_back(base+3); |
| | 301 | _indexArray.push_back(base+2); |
| | 302 | } |
| | 303 | } |
| | 304 | |
| | 305 | glDrawElements(GL_TRIANGLES, numQuads*6, GL_UNSIGNED_SHORT, &(_indexArray.front())); |
| | 306 | } |
| | 307 | else if (_primitiveMode==GL_QUAD_STRIP) |
| | 308 | { |
| | 309 | // will the winding be wrong? Do we need to swap it? |
| | 310 | glDrawArrays(GL_TRIANGLE_STRIP, 0, _vertices->size()); |
| | 311 | } |
| | 312 | else if (_primitiveMode==GL_POLYGON) glDrawArrays(GL_TRIANGLE_FAN, 0, _vertices->size()); |
| | 313 | else glDrawArrays(_primitiveMode, 0, _vertices->size()); |
| | 314 | } |