Search code examples
opengl-escocos2d-iphonecocos2d-x

Cocos2d-x, drawPoly() changing thickness?


Cocos2d-x V3-Alpha0

I have a class that subclasses cocos2d::LayerColor and I am overriding draw()

void HUDForPlanting::draw()
{
    float selfHeight = this->getContentSize().height;
    float selfWidth = this->getContentSize().width;

    cocos2d::Point vertices[4] = {cocos2d::Point(0.f, 0.f), cocos2d::Point(0.f, selfHeight), cocos2d::Point(selfWidth, selfHeight), cocos2d::Point(selfWidth, 0.f)};

    cocos2d::DrawPrimitives::drawPoly(vertices, 4, true);
}

This produces a thin line around my layer.

What I cannot see how to do is change/increase the line thickness and color.


Solution

  • Simple. Just use glLineWidth(value) before drawPoly method to set line width of your polygon.