How to draw a solid circle with cocos2d for iPhone

Reinout Roels picture Reinout Roels · Jul 4, 2009 · Viewed 20.1k times · Source

Is it possible to draw a filled circle with cocos2d ? An outlined circle can be done using the drawCircle() function, but is there a way to fill it in a certain color? Perhaps by using pure OpenGL?

Answer

quano picture quano · Jul 26, 2009

In DrawingPrimitives.m, change this in drawCricle:

glDrawArrays(GL_LINE_STRIP, 0, segs+additionalSegment);

to:

glDrawArrays(GL_TRIANGLE_FAN, 0, segs+additionalSegment);

You can read more about opengl primitives here: http://www.informit.com/articles/article.aspx?p=461848

alt text