Some opengl functions not working [Solved]

Some opengl functions not working [Solved]
0.0 0


Hello friends,
I am trying to draw with open gl with some vertices array…
but some functions are not working like this

glColor4f(1.f, 0.f, 0.f, 1.f); //not declared in the scope error
glVertexPointer(2, GL_FLOAT, 0, triangleFanPos); //not declared in the scope error

Configuration is ok because many other functions are working right…
Using cocos2dx 2.0.1

Please help


glColor4f and glVertexPointer , supported only OpenGLES.framework ES 1.0
you can use glVertexAttribPointer


thank you for the response…
I have tried that one but getting polygon at unexpected position…

Here is the code for that :

In the custom node class draw method ::

triangleFanPos[0] = Vertex2DMake(innerCircleBody~~>GetPosition.x * PTM_RATIO~~ this~~>getPosition.x,
innerCircleBody~~>GetPosition().y * PTM_RATIO - this~~>getPosition.y);

// Use each box2d body as a vertex and calculate coordinate for the triangle fan
for {
b2Body* currentBody =;
Vertex2D pos = Vertex2DMake.x * PTM_RATIO~~ this~~>getPosition.x,
currentBody~~>GetPosition().y * PTM_RATIO - this->getPosition().y);
triangleFanPos[i+1] = Vertex2DMake(pos.x, pos.y);

// Loop back to close off the triangle fan
triangleFanPos[NUM_SEGMENTS+1] = triangleFanPos[1];

ccDrawColor4B(255, 0, 0, 255);
// Load the vertex data
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, triangleFanPos);

And added that node to layer…
I am getting position of node through debug draw but not getting filled circle inside that as drawed in above method…

Do you have any idea about it.
If you want to take a good look i am trying this code:


I do not know how to do it
but you can see how it is created in b2DebugDraw
some code:
`void b2DebugDraw::DrawCircle(const b2Vec2& center, float32 radius, const b2Color& color)

const float32 k_segments = 16.0f;
const int vertexCount=16;
const float32 k_increment = 2.0f * b2_pi / k_segments;
float32 theta = 0.0f;

GLfloat                glVertices[vertexCount*2];
for (int32 i = 0; i < k_segments; ++i)
    b2Vec2 v = center + radius * b2Vec2(cosf(theta), sinf(theta));
    glVertices[i*2]=v.x * mRatio;
    glVertices[i*2+1]=v.y * mRatio;
    theta += k_increment;

mShaderProgram->setUniformLocationWith4f(mColorLocation, color.r, color.g, color.b, 1);
glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, glVertices);

glDrawArrays(GL_LINE_LOOP, 0, vertexCount);





Thank you @Misha
I have got the solution…

I have changed the trainglePositions like this…

triangleFanPos[0] = Vertex2DMake(innerCircleBody~~>GetPosition.x * PTM_RATIO ,
innerCircleBody~~>GetPosition().y * PTM_RATIO) ; //Big Big Watch Out……………For positions…

// Use each box2d body as a vertex and calculate coordinate for the triangle fan
for (int i = 0; i < NUM_SEGMENTS; i++) {
b2Body* currentBody =;
Vertex2D pos = Vertex2DMake(currentBody~~>GetPosition.x * PTM_RATIO,
currentBody~~>GetPosition().y * PTM_RATIO );
triangleFanPos[i+1] = Vertex2DMake(pos.x, pos.y);