Skip to content

Instantly share code, notes, and snippets.

@grahamsellers
Created December 13, 2013 14:39
Show Gist options
  • Save grahamsellers/7945239 to your computer and use it in GitHub Desktop.
Save grahamsellers/7945239 to your computer and use it in GitHub Desktop.
Set up a 10 layer FBO with depth + RGBA8_UNORM color.
GLuint tex[2];
GLuint fbo;
glGenTextures(2, tex);
glBindTexture(GL_TEXTURE_2D_ARRAY, tex[0]);
glTexStorage3D(GL_TEXTURE_2D_ARRAY, 1, GL_DEPTH_COMPONENT32F, 1024, 1024, 10);
glBindTexture(GL_TEXTURE_2D_ARRAY, tex[1]);
glTexStorage3D(GL_TEXTURE_2D_ARRAY, 1, GL_RGBA8, 1024, 1024, 10);
glGenFramebuffers(1, &fbo);
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, tex[0], 0);
glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex[1], 0);
static const GLenum buffers[] = { GL_COLOR_ATTACHMENT0 };
glDrawBuffers(1, buffers);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment