   Blit from window frameBuffer to FBO (depth map)
  Hi everybody,I'm currently trying to make accessible into a texture the content of the main windows depth buffer OR current bound FBO depth buffer content. Here is the way i was expecting to do this :   glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, currentFbo);   glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, depthfb_);   glBlitFramebufferEXT( 0, 0, width, height,0, 0, width, height,GL_DEPTH_BUFFER_BIT, GL_NEAREST);   glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, 0);   glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, currentFbo); In my context, currentFbo can be 0  meaning no FBO is boundHere is the way my depth FBO is initialized :glGenFramebuffersEXT(1, &fb_);    glGenTextures( 1, &depthTex_);    glBindTexture( GL_TEXTURE_2D, depthTex_);    glTexImage2D( GL_TEXTURE_2D, 0, config.depthFormat, width, height, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, NULL);    glGenerateMipmapEXT( GL_TEXTURE_2D);    glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);    glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);    glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);    glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);    glTexParameterf( GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_LUMINANCE);    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb_);glGenRenderbuffersEXT(1, &depthRB_);    glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depthRB_);    glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, width, height);    glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);    glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depthRB_);    glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, depthTex_, 0);    glDrawBuffer (GL_NONE); glReadBuffer(GL_NONE); The FBO appears to be completed and i have no openGL error at runtime.However, the result is that my framebuffer appears corrupted and my depth texture looks like uninitialized ( noisy )Here are all my unanswered questions :1) Is it possible to blit from main framebuffer to FBO ? (the spec tends to make me think this is ok but...) 2) Will this technic be faster than a more classical glCopyTexSubImage ?3) Is it correct to have a FBO with only depth attachment ? (same remark)4) What's wrong in my code ?5) Is is possible to blit from multisampled framebuffer ? 6) In that case do i need to initialize my depth FBO with the vp size or vp size * ms ?7) Is it necessary to glClear the Depth only FBO ?8) Has the currently bound GL_FRAMEBUFFER_EXT FBO any impact on the glBlitCall ?9) In the case i don't want a shadowmap but only a depth map do i need to use : glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE);Many thanks for any answer to one of those questions !last info :Quadro 5600FX (G80) with driver 186.18[Edited by - pixelKiller95 on June 29, 2009 8:13:06 AM]
  I always clear my newly created buffers before unbinding or [later] right after binding them... make sure you are doing that to the depth buffer, does that work?   ;Quote:Original post by AverageJoeSSUI always clear my newly created buffers before unbinding or [later] right after binding them... make sure you are doing that to the depth buffer, does that work?Nope, no change (strangly enough). I really have a doubt on the fact it is possible to blit directly the main depth buffer to another FBO...The problem doesn't seems to be linked to multisampling since this doesn't work for non-multisampled framebuffer.   ;  I found out that this works perfectly if i attach a color buffer to the depthFbo_ (don't ask me why !!! Driver bug ?)Here some of my (auto)answers :1) Is it possible to blit from main framebuffer to FBO ? (the spec tends to make me think this is ok but...)  ==> Yes but color buffer is required 3) Is it correct to have a FBO with only depth attachment ? (same remark) ==> Correct but this doesn't work maybe due to a driver bug4) What's wrong in my code ? ==> Nothing (just don't forget to reset :glDrawBuffer (GL_BACK); glReadBuffer(GL_BACK); 5) Is is possible to blit from multisampled framebuffer ?  ==> YES !!! 6) In that case do i need to initialize my depth FBO with the vp size or vp size * ms ? ==> NO, vp size runs fine7) Is it necessary to glClear the Depth only FBO ? ==> This is better at first sight 9) Use R_COMPARE ? ==> NO