void ShaderSprite::draw()
{
    _renderCommand.init(0, _vertexZ);
    _renderCommand.func = CC_CALLBACK_0(ShaderSprite::onDraw, this);
    Director::getInstance()->getRenderer()->addCommand(&_renderCommand);
    
}
void EffectSprite3D::draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, uint32_t flags)
{
    for(auto &effect : _effects)
    {
        if(std::get<0>(effect) >=0)
            break;
        CustomCommand &cc = std::get<2>(effect);
        cc.func = CC_CALLBACK_0(Effect3D::draw,std::get<1>(effect),transform);
        renderer->addCommand(&cc);
        
    }
    
    if(!_defaultEffect)
    {
        Sprite3D::draw(renderer, transform, flags);
    }
    else
    {
        _command.init(_globalZOrder, transform, flags);
        _command.func = CC_CALLBACK_0(Effect3D::draw, _defaultEffect, transform);
        renderer->addCommand(&_command);
    }
    
    for(auto &effect : _effects)
    {
        if(std::get<0>(effect) <=0)
            continue;
        CustomCommand &cc = std::get<2>(effect);
        cc.func = CC_CALLBACK_0(Effect3D::draw,std::get<1>(effect),transform);
        renderer->addCommand(&cc);
        
    }
}
示例#3
0
void ShaderSprite::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
    _renderCommand.init(_globalZOrder);
    _renderCommand.func = CC_CALLBACK_0(ShaderSprite::onDraw, this, transform, transformUpdated);
    renderer->addCommand(&_renderCommand);

}
示例#4
0
void CocosTools::captureScreen(const CapturedCallback &callback)
{
    static CustomCommand captureScreenCommand;
    captureScreenCommand.init(std::numeric_limits<float>::max());
    captureScreenCommand.func = std::bind(onCaptureScreen, callback);
    Director::getInstance()->getRenderer()->addCommand(&captureScreenCommand);
}
Point PixelCollision::renderSprite(Sprite *sprite, CustomCommand &command, bool red) {
    command.init(sprite->getGlobalZOrder());
    command.func = [=]() {
        sprite->getGLProgramState()->setUniformInt(kShaderRedUniform, red ? 255 : 0);
        sprite->getGLProgramState()->setUniformInt(kShaderBlueUniform, red ? 0 : 255);
    };
    Director::getInstance()->getRenderer()->addCommand(&command);
    
    sprite->setGLProgram(_glProgram);
    sprite->setBlendFunc(BlendFunc::ADDITIVE);
    Point oldPosition = sprite->getPosition();
    sprite->setPosition(sprite->getParent()->convertToWorldSpace(oldPosition));
    sprite->visit();
    
    return oldPosition;
}
void DrawNode3D::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
    _customCommand.init(_globalZOrder, transform, flags);
    _customCommand.func = CC_CALLBACK_0(DrawNode3D::onDraw, this, transform, flags);
    renderer->addCommand(&_customCommand);
}
示例#7
0
void MySprite::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
{
    _customCommand.init(_globalZOrder);
    _customCommand.func = CC_CALLBACK_0(MySprite::onDraw, this, transform, transformUpdated);
    renderer->addCommand(&_customCommand);
}