Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 5 of 5

Thread: FrameBuffer mixing with BackBuffer

  1. #1
    Intern Newbie
    Join Date
    Jul 2009
    Posts
    39

    FrameBuffer mixing with BackBuffer

    I read here (http://stackoverflow.com/questions/5...in-opengl-fbos) that it is impossible to mix backbuffer with a custom GL framebuffer. I ran into this problem today, but it appears that some sort of mixing does work.

    I have a few passes in my engine. The first one is early-z, followed by a pass that writes down normals and depths. Early-z renders to the backbuffer, but normal-depth pass switches the render target (*), and disables writes to z-buffer. What is interesting is that normal-depth pass utilizies early-z to only shade pixels that are visible, but in theory that should not work as the *backbuffer's* z-buffer is filled it, whereas I already have bound a new framebuffer object, which has not z-buffer render-buffer or texture bound at all.

    On the other hand, if I skip the early-z pass, leaving only normal-depth that sets the render target, the further rendering screws up (note that right now, as there is no early-z, normal-depth pass has to write z values). So basically it appears that reading from the backbuffer's Z is possible, but it is not possible to simultanously write to a framebuffer's color, and backbuffer's z. Is that correct?

    I am aware that my description might be a bit enigmatic so if necessary, I can describe it in more detail and post more code.

    (*) the function looks this:
    Code :
     
    void CRenderer::setRenderTarget(const CRenderTarget *renderTarget)
    {
      if (renderTarget == NULL)
      {
       glViewport(0, 0, CApplication::getScreenWidth(), CApplication::getScreenHeight());
       glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
      }
      else
      {
       glViewport(0, 0, renderTarget->width, renderTarget->height);
       glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, offScreenFramebuffer);
       glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, renderTarget->texture, 0);
      }
    }

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    723
    I don't know of a way to tell OpenGL that you want to use the backbuffer and another buffer simultaneously. I am not sure what happens if you enable depth testing without a z-buffer attached.

  3. #3
    Member Regular Contributor
    Join Date
    Dec 2007
    Posts
    250
    Quote Originally Posted by tonyo_au View Post
    I am not sure what happens if you enable depth testing without a z-buffer attached.
    you just get no depth testing

  4. #4
    Intern Newbie
    Join Date
    Jul 2009
    Posts
    39
    Then why do I get depth testing working correctly when I switch to an offscreen buffer with only color buffer attached? Moreover, z-values are correctly read for the *backbuffer's* z-buffer.

  5. #5
    Advanced Member Frequent Contributor
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    723
    It sounds like the driver may be attaching the back-buffer's depth buffer but since this is not standard behaviour you can't assume it will continue to work.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •