O'Reilly logo

OpenGL Programming Guide: The Official Guide to Learning OpenGL, Version 4.3, Eighth Edition by Bill M. Licea-Kane, John M. Kessenich, Graham Sellers, Dave Shreiner

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Layered Rendering

When rendering into a framebuffer object, it is possible to use a 2D array texture as a color attachment and render into the slices of the array using a geometry shader. To create a 2D array texture and attach it to a framebuffer object, use code such as that shown in Example 10.24.

Example 10.24. Example Code to Create an FBO with an Array Texture Attachment

// Declare variablesGLuint tex;        // This will be the 2D array textureGLuint fbo;        // The framebuffer object// Create and allocate a 1024x1024x32 2D array textureglGenTextures(1, &tex);glBindTexture(GL_TEXTURE_2D_ARRAY, tex);glTexImage3D(GL_TEXTURE_2D_ARRAY,             0,             GL_RGBA,             1024,             1024, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required