View Full Version : Gl_texture_cube_map_array

04-30-2015, 12:52 PM
I have troubles understanding the process of creation and image' uploading of this new fancy texture type - the specs and wiki did not gave me a clear picture on that process. No examples I have seen so far as well. Did anyone used the GL_TEXTURE_CUBE_MAP_ARRAY textures? Can anyone, please, post an example code of the texture initialization using glTexImage3D or glTexStorage3D+glTexSubImage*D?

Alfonse Reinheart
04-30-2015, 01:38 PM
What part of the process were you unclear on? Basically, you treat a cubemap array texture (https://www.opengl.org/wiki/Cubemap_Texture#Cubemap_array_textures) exactly like a 2D array texture (https://www.opengl.org/wiki/Array_Texture). The only difference is that, when you access from it within the shader, 6 array layers is considered a single cubemap (and thus, the number of layers that the shader sees is the number you specify divided by 6).

That's what the whole "layer vs. layer-face" thing the Wiki is talking about means. Hence the statement "When allocating storage for a cubemap array, the number of layer-faces is provided as the depth​ parameter, not the number of layers."

05-01-2015, 05:01 AM
Well, for regular cubemap textures I create a GL_TEXTURE_CUBE_MAP type texture, then I upload images using glTexImage2D to 6 different targets: GL_TEXTURE_CUBE_MAP_*_*. Now, if I understand correctly, for GL_TEXTURE_CUBE_MAP_ARRAY there is no way to upload layered faces individually (like with glTexImage3D and 6 targets), right? So for array cubemaps I upload once the whole single pack consisting of 6*n slices where n is a number of layers each face has? Is this correct?

05-01-2015, 05:43 AM
There's an example in the Wiki: "Similarly, when uploading texel data to the cubemap array, the parameters that represent the Z component are layer-faces. So if you want to upload to the positive Z axis of the second layer in the array, you would use index 10 (layer 1 * 6 faces per layer + face index 4)."

So instead of using TexSubImage2D, use TexSubImage3D with the proper Z offset.

05-01-2015, 10:33 AM
Oh, I see. Now I understand. :)
Thank you very much, guys!