Draw primitives(polygons) on update

Draw primitives(polygons) on update
0.0 0


In my game I’m trying to draw polygons on on each step i.e. update method. I call draw() method to draw new polygon with dynamic vertices. Following is my code:

void HelloWorld::draw(){glLineWidth(1);
CCPoint filledVertices[] ={ccp(drawX1,drawY1),ccp(drawX2,drawY2), ccp(drawX3,drawY3), ccp(drawX4,drawY4)};
ccDrawSolidPoly( filledVertices, 4, ccc4f(0.5f, 0.5f, 1, 1 ));}
I call the draw() method from the update(float dt) method. The engine is behaving inconsistently i.e. sometimes it displays the polygons and on other occasions it does not.

Is it the right approach to do such a task? If not what is the best way to display large number of primitives?


Consider using CCDrawNode.