Hi! I really need your help! Tell me, how do I draw a triangle on CCRenderTexture with colored tops? I tried to override the ccDrawSolidPoly to be output with the ground and the triangle with colored tops.
`void ccDrawSolidPoly( const CCPoint *poli, unsigned int numberOfPoints, ccColor4F color, int w )
{
lazy_init();
s_pShader->use();
s_pShader->setUniformForModelViewProjectionMatrix();
s_pShader->setUniformLocationWith4fv(s_nColorLocation, (GLfloat*) &color.r, 1);
ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position );
// XXX: Mac OpenGL error. arrays can't go out of scope before draw is executed
ccVertex2F* newPoli = new ccVertex2F[numberOfPoints];
// iPhone and 32-bit machines optimization
if( sizeof(CCPoint) == sizeof(ccVertex2F) )
{
glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, poli);
}
else
{
// Mac on 64-bit
for( unsigned int i=0; i<numberOfPoints;i++)
{
newPoli[i] = vertex2( poli[i].x, poli[i].y );
}
glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, newPoli);
}
glDrawArrays(GL_TRIANGLE_FAN, 0, (GLsizei) numberOfPoints);
///////////////////////////////////////////////////////////////////////////////////
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glBegin(GL_TRIANGLES);
glColor3d(1,0,0); // рисуем треугольник
glVertex3d(0,0,0);
glVertex3d(700,700.9,0);
glVertex3d(200,200,0);
glEnd();
///////////////////////////////////////////////////////////////////////////////////
CC_SAFE_DELETE_ARRAY(newPoli);
CC_INCREMENT_GL_DRAWS(1);
}` But in the end I got one color triangle, the color that matches the color of the polygon. How can I be? (sorry for my english :))