简体   繁体   中英

Do I need attach renderbuffer to a framebuffer that has a texture attached already?

I created a framebuffer for offscreen rendering. I made an empty texture with no data set up. I did not attached a color renderbuffer since there is the texture backing.

In code:

    //Generate framebuffer, hook up renderbuffer.
    glGenFramebuffers(1, &_frameBufferName);
    glBindFramebuffer(GL_FRAMEBUFFER, _frameBufferName);

    //DON'T Attach texture to framebuffer (RGBA).
    //glGenRenderbuffers(1, &_colorRenderBufferName);        
    //glBindRenderbuffer(GL_RENDERBUFFER, _colorRenderBufferName);    

    //glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA4, _layerWidth, _layerHeight);        
    //glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, _colorRenderBufferName);            

    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, _textureName, 0);
    glClear(GL_COLOR_BUFFER_BIT);

It works actually, but xCode profiler always claims that the framebuffer has no attachments. Do I need color renderbuffer here?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM