auto s = Director::getInstance()->getWinSize();
auto draw = DrawNode::create();
this->addChild(draw);
for (int i = 0; i < 10; i++) {
draw->drawDot(Vec2(s.width*0.5,s.height*0.5),10*(10-i),Color4F(CCRANDOM_0_1(),CCRANDOM_0_1(),1));
}
void HelloWorld::draw(Renderer *renderer,const Mat4 &transform,uint32_t flags)
{
_customCommand.init(1);
_customCommand.func = CC_CALLBACK_0(HelloWorld::onDraw,this,transform,flags);
renderer->addCommand(&_customCommand);
}
void HelloWorld::onDraw(const Mat4 &transform,uint32_t flags)
{
Director::getInstance()->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
Director::getInstance()->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW,transform);
//直线
CHECK_GL_ERROR_DEBUG();
glLineWidth(5.0f);
DrawPrimitives::setDrawColor4B(255,0,255);
DrawPrimitives::drawLine(VisibleRect::leftBottom(),VisibleRect::rightTop());
Director::getInstance()->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
}