在RenderTexture Cocos2dx 3.0上应用Shader

时间:2014-01-19 12:35:37

标签: cocos2d-x cocos2d-x-3.0

有人可以指导我如何将着色器应用于Beta 3.0中的RenderTexture,  我使用以下代码将着色器应用于renderTexture对象,但代码似乎不再适用于Cocox2dX Beta 3.0

void TestLayer::initRenderTexture()
 {
    m_renderTexture = CCRenderTexture::create(utility::WindowSize.Size.width,utility::WindowSize.Size.width);


    cocos2d::CCGLProgram *pShaderProgram = new CCGLProgram();
    pShaderProgram->initWithVertexShaderByteArray(ccPositionTextureA8Color_vert, myFragSource);

    m_renderTexture->getSprite()->setShaderProgram(pShaderProgram);
    m_renderTexture->getSprite()->getShaderProgram()->addAttribute(kCCAttributeNamePosition, kCCVertexAttrib_Position);
    m_renderTexture->getSprite()->getShaderProgram()->addAttribute(kCCAttributeNameColor, kCCVertexAttrib_Color);
    m_renderTexture->getSprite()->getShaderProgram()->addAttribute(kCCAttributeNameTexCoord, kCCVertexAttrib_TexCoords);
    m_renderTexture->getSprite()->getShaderProgram()->link();
    m_renderTexture->getSprite()->getShaderProgram()->updateUniforms();

    m_renderTexture->getSprite()->getShaderProgram()->use();

    //add renderTexture Object to layer
     addChild(m_renderTexture);
}

由于 罗马托马斯

0 个答案:

没有答案