- (7) Render to depth texture with no color attachments
- // Given: depth_tex - TEXTURE_2D depth texture object
- // fb - framebuffer object
- // Enable render-to-texture
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb);
- // Set up depth_tex for render-to-texture
- glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,
- GL_DEPTH_ATTACHMENT_EXT,
- GL_TEXTURE_2D, depth_tex, 0);
- // No color buffer to draw to or read from
- glDrawBuffer(GL_NONE);
- glReadBuffer(GL_NONE);
- // Check framebuffer completeness at the end of initialization.
- CHECK_FRAMEBUFFER_STATUS();
- <draw something>
- // Re-enable rendering to the window
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
- glBindTexture(GL_TEXTURE_2D, depth_tex);
- <draw to the window, reading from the depth_tex>