0
votes

Say I have a number of cube map textures and I wish to pass all of them to the GPU as a cube map array texture.

First I would need to create the array texture, which should look something like:

glTextureStorage3D(textureId, 0, internalFormat, width, height, howManyCubeMaps);

Assuming there is only one mipmap level.

How can I then attach each indidivual texture to this texture array?

Say if each cube map id is in an array, I wonder if you can do somehting like this:

for(uint level=0; level<num_levels; level++)
    glAttach(textureID, cubeID[level], level);

And then I am not sure how I should receive the data on the shader side and the OpenGL wiki has no explicit docuemtnation on it

https://www.khronos.org/opengl/wiki/Cubemap_Texture#Cubemap_array_textures

1
"the OpenGL wiki has no explicit docuemtnation on it" It has explicit documentation. It tells you what the sampler type is. It tells you how cube map arrays change the texture accessing functions' interfaces. What it doesn't have is copy-and-pasteable code. Cubemap arrays work just like 2D and 1D array textures: their texture coordinates take an additional component, which is the array layer. If you have a specific question about how to use a cubemap array, you can ask that. - Nicol Bolas

1 Answers

2
votes

How can I then attach each indidivual texture to this texture array?

That's not how array textures work in OpenGL. That's not even how arrays work in C++. Think about it: if you have 5 int variables, there's no way to "attach" those int variables to an int array[5] array. The only solution is to copy the value of those variables into the appropriate locations in the array. After this process, you still have 5 int variables, with no connection between them and the array.

So too with OpenGL: you can only copy the data within those cube map textures into the appropriate location in the cube map array texture. glCopyImageSubData is your best bet for this process.