About the 6 layers / 1 texture bit, I think a lot of the confusion comes from OpenGL concept of “images” vs “textures”. Basically a texture is made up of one to several images, the texture is the ID you use to reference that group of images, and the actual images are the actual data stored in memory. Each images being allocated memory accessible through the same texture ID. The most common use case is mipmapping, you have in practice a single Texture, but effectively N images of lower and lower resolutions are stored in the memory to help solve different issues related to resolution/scale/performance… Layered textures (3d textures, cubemaps, etc…) add to the confusion by being one texture representing several sets of images, … for example a cubemap texture has 6 layers/faces which can each have several images…
Re: gl_Layer. Those extensions while using gl_Layer are sort of unrelated and expose other functionalities you’re probably not going to need. Also gl_Layer should be more widely available.
https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/gl_Layer.xhtml
I would start with a passthrough geometry shader and try to write to gl_Layer. Maybe start with an hardcoded gl_Layer = 2; and see if that get rendered to the right face. From there it should be fairly easy to wrap the whole thing into a for( int i = 0; i < 6... and read the relevant transforms from an uniform array.
You might also need to setup your gl::Fbo in a specific way to make it work properly with gl_Layer. If I remember correctly one requirement for “fbo completeness” is to have all the attachments being layered. Something like this:
auto textureCubeMap = gl::TextureCubeMap::create( faceWidth, faceHeight, gl::TextureCubeMap::Format().immutableStorage() );
auto layeredFbo = gl::Fbo::create( width, height, gl::Fbo::Format().disableDepth().attachment( GL_COLOR_ATTACHMENT0, textureCubeMap ) );
Again, not done that for a while so not sure I remember correctly, but I believe that if you do want depth testing and writing to gl_Layer you might need a depth cubemap attach to the depth attachment,… something like this :
auto textureCubeMap = gl::TextureCubeMap::create( width, height, gl::TextureCubeMap::Format().immutableStorage() );
auto textureDepthCubeMap = gl::TextureCubeMap::create( width, height, gl::TextureCubeMap::Format().immutableStorage().internalFormat( GL_DEPTH_COMPONENT24 ) );
auto layeredFbo = gl::Fbo::create( width, height, gl::Fbo::Format().attachment( GL_COLOR_ATTACHMENT0, textureCubeMap ).attachment( GL_DEPTH_ATTACHMENT, textureDepthCubeMap ) );
Hope that helps.