framebuffer - OpenGL FBO not blitting depth buffer -


i'm trying create 1 fbo draw 3d scene on , fbo draw hud on. try combine these 2 fbos blitting 3d scene default fbo , blitting hud default fbo.

each fbo created has same dimensions window, , has rbo both color attachment , depth attachment.

what expect happen blit of 3d fbo fill depth buffer of default fbo data 3d depth rbo while drawing contents of 3d color rbo. second blit, hud, draw hud color rbo data default fbo hud depth rbo gl_lequal default fbo's depth data.

side note

i understand want clear hud color has no alpha (currently clear <1.0f, 0.0f, 1.0f, 0.0f>) , disable depth test , blit hud default fbo. make sure hud on top. intend this, need make depth check version work first.

what happening 3d fbo drawing scene , hud fbo draws on it. spots there should transparent clear color background aren't clear either. draw on 3d scene covering completely.

am missing or not understanding fbo blitting? possible depth check working correctly, clear color alpha channel not being blended?

an opengl call log single frame can found here:
http://fpaste.org/84040/

program details

  • opengl context version: 4.0
  • glx window color space: rgba8
  • glx window depth size: 24
  • glx window stencil size: 8

development system details

  • operating system: ubuntu 12.04 lts
  • graphics card: ati radeon hd 5750
  • driver version: 13.25.5

blit code

public void blit(int dstx = 0, int dsty = 0,                  int dstwidth = 0, int dstheight = 0,                  uint targetframebuffer = 0) {    int mask;     // start out nothing set.    mask = 0;     // see if should blit color buffer.    if (color_buffer != null)    {       mask |= gl_color_buffer_bit;    }     // see if should blit depth buffer.    if (depth_buffer != null)    {       mask |= gl_depth_buffer_bit;    }     // see if should blit stencil buffer.    if (stencil_buffer != null)    {       mask |= gl_stencil_buffer_bit;    }     // make sure mask set before done.    if (mask != 0)    {       // enable depth writing if depth buffer available.       if (depth_buffer != null)       {          // enable depth writing.          gldepthmask(gl_true);       }        // bind reading , drawing buffers.       glbindframebuffer(gl_read_framebuffer, reference);       glreadbuffer(gl_color_attachment0);       glbindframebuffer(gl_draw_framebuffer, targetframebuffer);        // if target buffer default fbo,       // render one.       if (targetframebuffer == 0)       {          gldrawbuffer(gl_back);       }        glblitframebuffer(0, 0, width, height,                         dstx, dsty, dstwidth, dstheight,                         mask, gl_nearest);        // unbind buffers.       glbindframebuffer(gl_read_framebuffer, 0);       glbindframebuffer(gl_draw_framebuffer, 0);        // disable depth writing if enabled earlier.       if (depth_buffer != null)       {          // disable depth writing.          gldepthmask(gl_false);       }    } } 

glblitframebuffer copies block of pixels 1 buffer another. doesn't use depth buffer accept or reject pixels source buffer.

you can want drawing quad using hud texture , depth buffer (assuming binding depth texture hud fbo). need write value of depth texture gl_fragdepth in fragment shader.

the same thing true if use alpha instead (as intend do), except blending using alpha value of hud fbo. better solution away hud depth buffer.


Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -