White depth texture using FBO

Hello :slight_smile:
I am trying to use my FBO implementation to use a depth texture with shaders, but when I simply try to display it I get a white screen. Here is my code :


  // Initializing part
  
  // Creation of the FBO
  glGenFramebuffers(1, @FBOId);
  glBindFramebuffer(GL_FRAMEBUFFER, FBOId);
  
  // Color buffer texture attachment
  glGenTextures(1, @ColorBufferTextureId);
  glBindTexture(GL_TEXTURE_2D, ColorBufferTextureId);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
  glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, FBOWidth, FBOHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, nil);
  glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, ColorBufferTextureId, 0);

  // Depth render buffer
  glGenRenderbuffers(1, @DepthBufferId);
  glBindRenderbuffer(GL_RENDERBUFFER, DepthBufferId);
  glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT32, FBOWidth, FBOHeight);
  glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, DepthBufferId);

  // Depth buffer texture attachment
  glGenTextures(1, @DepthBufferTextureId);
  glBindTexture(GL_TEXTURE_2D, DepthBufferTextureId);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
  glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32, FBOWidth, FBOHeight, 0, GL_DEPTH_COMPONENT, GL_FLOAT, nil);
  glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, DepthBufferTextureId, 0);

  glBindFramebuffer(GL_FRAMEBUFFER, 0);
  

  
  // Drawing Part
  
  glBindFramebuffer(GL_FRAMEBUFFER, FBOId);
  glPushAttrib(GL_VIEWPORT_BIT);
  glViewport(0, 0, FBOWidth, FBOHeight);
  
  ...
  ...// Render the scene
  ...
  
  glPopAttrib;
  glBindFramebuffer(GL_FRAMEBUFFER, 0);

  ...
  ...// Try to display the depth texture : white screen
  ...
  

I have tried to display the color texture of the FBO and everything goes well so I may be doing something wrong in the initializing part of my depth texture

Thank you for the help, and sorry for my poor English

I’m sorry, I just realized the problem came from my drawing part, it’s now resolved