CCDrawNode color problem

CCDrawNode seems to not get colors correctly.
Any value of ccColor4F higher than 0.0f seems to be interpreted as a full 1.0f; you can only get pure red, green, blue or any combination of these, but not a gray, for example.
The following code produces the image attached.

bool MyLayer::init()
{
   CCPoint vertex[] = { ccp(0,0), ccp(100,0), ccp(100,100), ccp(0,100) };
   if( CCLayer::init() )
   {
      CCDrawNode *dnode = CCDrawNode::create();
      // the fill color should not be pure yellow!!
      // the border should NOT be white!!
      dnode->drawPolygon( vertex, 4, ccc4f(0.1f, 0.1f, 0, 1), 4, ccc4f(0.1f, 1, 0.1f, 1) );

      // this way does not work either. Pure white is displayed
      ccColor4F gray = {0.5f, 0.5f, 0.5f, 1.0f };
      dnode->drawSegment( ccp(0,0), ccp(200,200), 4, gray );

      dnode->setPosition( VisibleRect::center() );
      this->addChild( dnode );
      return true;
   }
   else
   {
      return false;
   }
}

Does anyone know what is happening?


ccdrawnode.jpg (9.5 KB)

This happends also in c++ cocos2d-x test demo (testccp).
Primitive drawing works fine, but CCDrawNode does not.
I ended up using regular CCSprites and batch node.
But it will great if CCDrawNode worked, as I find it really useful.

I had the same issue.

This should fix it:

Here’s CCDrawNode.cpp line 204:

glVertexAttribPointer(kCCVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_FALSE, sizeof(ccV2F_C4B_T2F), (GLvoid *)offsetof(ccV2F_C4B_T2F, colors));

Change GL_FALSE to GL_TRUE.

Worked for me, thanks Daniel