Results 1 to 4 of 4

Thread: problem with depth buffer while using the FBO

  1. #1
    Senior Member Frequent Contributor ehsan2004's Avatar
    Join Date
    Jun 2004
    Location
    Iran
    Posts
    645

    problem with depth buffer while using the FBO

    I don't know why depth test doesn't work correctly when I use a FBO to render to texture? Note that I have just attached a texture to the color buffer of FBO. I haven't attached anything to the depth buffer of FBO.

  2. #2
    Newbie Frequent Contributor
    Join Date
    Mar 2016
    Posts
    896

    Re: problem with depth buffer while using the FBO

    I haven't attached anything to the depth buffer of FBO.
    and that is why the depth test does not work, it needs a depth buffer, i.e. you need to attach one to your FBO.

  3. #3
    Senior Member Frequent Contributor ehsan2004's Avatar
    Join Date
    Jun 2004
    Location
    Iran
    Posts
    645

    Re: problem with depth buffer while using the FBO

    Thank you. I tried it, but I no longer see anything in my texture!
    here's my code to initialize a texture, FBO and render buffer:
    Code :
    		glGenerateMipmapEXT( GL_TEXTURE_2D );
    		glTexImage2D(GL_TEXTURE_2D, 0, channels, size, size, 0, type, GL_UNSIGNED_BYTE, NULL );
    		m_fboID[textureID] = g_render.GenerateFBO();
    		g_render.BindFBO( m_fboID[textureID] );
    		g_render.Attach2DTextureToFBOColor( m_waterTexture[textureID] );
    		CUInt renderBuffer = g_render.GenerateRenderBuffer();
    		g_render.BindRenderBuffer( renderBuffer );
    		g_render.RenderbufferStorage( 256, 256 );
    		g_render.AttachDepthToFBO( renderBuffer );
    		g_render.BindFBO(0);
    		g_render.BindRenderBuffer(0);

    Without creating a render buffer and attaching it to the FBO, at least I get some images in my texture. but now the texture is black.
    Note that the result of creating my FBO is GL_FRAMEBUFFER_COMPLETE_EXT.

  4. #4
    Senior Member Frequent Contributor ehsan2004's Avatar
    Join Date
    Jun 2004
    Location
    Iran
    Posts
    645

    Re: problem with depth buffer while using the FBO

    [solved]
    I understood that the width and height of my render buffer are not equal with the with and height of my color texture. replacing this part of code:

    Code :
    g_render.RenderbufferStorage( 256, 256 );

    with this one:
    Code :
    g_render.RenderbufferStorage( size, size );

    solved my problem

    Now the water texture looks nice:

    [img:right]http://upwqcw.blu.livefilestore.com/y1pN...er-1.jpg?psid=1[/img]

    Thank you carsten neumann

Similar Threads

  1. Depth buffer problem
    By egydev in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 05-19-2010, 06:26 AM
  2. depth buffer problem?
    By in forum OpenGL: Basic Coding
    Replies: 11
    Last Post: 02-23-2004, 10:00 PM
  3. depth buffer problem
    By deans in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 11-15-2002, 03:58 AM
  4. Replies: 1
    Last Post: 11-03-2001, 12:04 AM
  5. Problem of depth buffer
    By pongkm in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 07-30-2001, 08:44 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean