Beispiel #1
0
void PUBillboardChain::render( Renderer* renderer, const Mat4 &transform, ParticleSystem3D* particleSystem )
{
    auto camera = Camera::getVisitingCamera();
    auto cameraMat = camera->getNodeToWorldTransform();

    if (!_chainSegmentList.empty())
    {
        updateVertexBuffer(cameraMat);
        updateIndexBuffer();
        if (!_vertices.empty() && !_indices.empty())
        {
            GLuint texId = this->getTextureName();
            _stateBlock->setBlendFunc(particleSystem->getBlendFunc());
            _meshCommand->init(0,
                               texId,
                               _glProgramState,
                               _stateBlock,
                               _vertexBuffer->getVBO(),
                               _indexBuffer->getVBO(),
                               GL_TRIANGLES,
                               GL_UNSIGNED_SHORT,
                               _indices.size(),
                               transform,
                               Node::FLAGS_RENDER_AS_3D);
            _meshCommand->setSkipBatching(true);
            _meshCommand->setTransparent(true);            
            _glProgramState->setUniformVec4("u_color", Vec4(1,1,1,1));
            renderer->addCommand(_meshCommand);
        }
    }
}
	//-----------------------------------------------------------------------
	void BillboardChain::_updateRenderQueue(RenderQueue* queue)
	{
		updateIndexBuffer();

		if (mIndexData->indexCount > 0)
		{
            if (mRenderQueueIDSet)
                queue->addRenderable(this, mRenderQueueID);
            else
                queue->addRenderable(this);
		}

	}
void TMXLayer::draw(Renderer *renderer, const Mat4& transform, uint32_t flags)
{
    updateTotalQuads();
    
    if( flags != 0 || _dirty || _quadsDirty )
    {
        Size s = Director::getInstance()->getWinSize();
        auto rect = Rect(0, 0, s.width, s.height);
        
        Mat4 inv = transform;
        inv.inverse();
        rect = RectApplyTransform(rect, inv);
        
        updateTiles(rect);
        updateIndexBuffer();
        updatePrimitives();
        _dirty = false;
    }
    
    if(_renderCommands.size() < static_cast<size_t>(_primitives.size()))
    {
        _renderCommands.resize(_primitives.size());
    }
	_texture->prepareDraw();
    int index = 0;
    for(const auto& iter : _primitives)
    {
        if(iter.second->getCount() > 0)
        {
            auto& cmd = _renderCommands[index++];
			//修改混合模式,满足美术需求和PS一样 added by tokentong 20150327
            cmd.init(iter.first, _texture->getName(), getGLProgramState(), BlendFunc::ALPHA_PREMULTIPLIED, iter.second, _modelViewTransform, flags);
            renderer->addCommand(&cmd);
        }
    }
}