在Layer的init中使用opengl的问题

    Size visibleSize = Director::getInstance()->getVisibleSize();
    Vec2 origin = Director::getInstance()->getVisibleOrigin();

    RenderTexture *rt = RenderTexture::create(visibleSize.width,visibleSize.height);
    rt->beginWithClear(1, 1, 0,1);
///1
    this->setShaderProgram(ShaderCache::getInstance()->getGLProgram(GLProgram::SHADER_NAME_POSITION_COLOR));
    CC_NODE_DRAW_SETUP();
    CCPoint vertices;
    ccColor4F colors;
    int nVertices = 0;
    vertices = CCPointMake(0, 0);
    colors = ccc4f(1, 0, 0, 1);
    vertices = CCPointMake(100, 0);
    colors = ccc4f(0, 1, 0, 1);
    vertices = CCPointMake(0, 100);
    colors = ccc4f(0, 0, 1, 1);
    vertices = CCPointMake(100, 100);
    colors = ccc4f(1, 0, 0, 1);
    ccGLEnableVertexAttribs(kCCVertexAttribFlag_Position | kCCVertexAttribFlag_Color);
    glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices);
    glVertexAttribPointer(kCCVertexAttrib_Color, 4, GL_FLOAT, GL_FALSE, 0, colors);
    glBlendFunc(CC_BLEND_SRC, CC_BLEND_DST);
    glDrawArrays(GL_TRIANGLE_STRIP, 0, (GLsizei)nVertices);
////1
    rt->end();
    rt->retain();
    auto sprt = Sprite::createWithTexture(rt->getSprite()->getTexture());
    sprt->setPosition(visibleSize.width / 2, visibleSize.height / 2);
    addChild(sprt);

代码如上,问题:1.在注释1中间的代码为什么没有显示? 2.rt->retain()为什么要加,不加也就没显示

是2.x么?

我在3.x不管retain还是不retain都是一片黄色

是3.3,我得加retain ,另外中间那段画渐变三角形的没用吗?