Jump to content
  • Advertisement
Sign in to follow this  

FBO & depth texture, doesn t seem to render to FBO

This topic is 4140 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I am having some trouble setting up the FBO for shadow mapping. Thats how I setup the depth texture
318         glGenTextures   (1,&m_uiID);
319         glBindTexture   (GL_TEXTURE_2D,m_uiID);
320         glTexImage2D    (GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, m_iMapSize, m_iMapSize, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL);
321         glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
322         glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
323         glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
324         glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
331         glBindTexture   (GL_TEXTURE_2D,0);

I can change the color of the depth attachment with glClearDepth(...); However when rendering to the FBO it doesn t render to the targets, they keep the clear color/depth. The projection and view matrix of the lightcamera also seem to be correct. I did assign the generated texture coordinates to gl_FragColor and they look correct. x & y axis are in between (0,1) range and the depth coordinate is also correct, test this by moving the near and far planes a little to see the difference. Can you render to a depth texture at all? Or should I use a depth buffer as target and copy the content back to the depth texture?

Share this post

Link to post
Share on other sites
Does your FBO return any errors when you setup the FBO?

Are you on ATI or Nvidia? ATI pre 1000 series I think doesn't like 24bit depth types. And I am not sure either but GL_LINEAR on ATI doesn't have PCF like Nvidia on older cards.

And are you just trying to render a shadowmap to a depth texture? If so it works I have it working now... But if you are trying to do someother work to the shadowmap you may want to use a renderbuffer to do the work and copy it back to the depth texture.

Do you call these functions?

//if you aren't using color

and where is

glGenFramebuffersEXT(1, &fb);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb);

glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, texture_target, depthtexture, 0);

I don't see those in your code either?


Share this post

Link to post
Share on other sites
thanks for taking the time.

Unfortunately the error was somewhere different.

We are working with a framework and after hours of bug tracking I just replaced the orthographic camera with a perspective one and it worked, so I examined the framework a little and finally found the problem


however the interface for the camera used
left,right,bottom,top thus the viewport was corrupted and opengl did not throw a error message.
This took me the whole afternoon to figure out :)

thx for ya help

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!