<p>I found my mistake...
I was creating 6 cube maps, not 8... but when creating them I have to multiply the number of wanted cube maps by 6 which I didn't done. So the cube map array texture was only holding one cube map.</p>
<pre><code>glTexStorage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 1, ToGlInternalFormat(format), size, size, layer); // this layer variable needs to be multiplied by 6
</code></pre>
<p>So the source code I posted within the question is working fine.</p>

CC BY-SA 4.0
2022-05-18T10:16:25.560Z
2022-05-18T10:16:25.560Z
Thomas
<p>I have a GL_TEXTURE_CUBE_MAP_ARRAY texture of 8 cube maps (<code>countLayers</code>). Now I am trying to transfer the pixels to CPU.</p>
<p>Currently I am using this code:</p>
<pre><code>unsigned int countFloats = size * size * countChannels * 6 * countLayers;
pixels = new float[countFloats];

glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, colorTexture()-&gt;id());
glGetTexImage(GL_TEXTURE_CUBE_MAP_ARRAY, 0, GL_RGBA, GL_FLOAT, pixels);

glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, 0);
</code></pre>
<p>It seems like, that this code works only for the first cubemap within the array. Because when deleting the multiplication with <code>countLayers</code> in the first line, everything is still working. But when <code>pixels</code> does not have enough storage (for example deleting the factor <code>6</code> as well), the program is crashing.</p>
<p>How can I store all cube maps to CPU? It would also be okay to store each cube map separately.</p>

<opengl><texture>
store GL_TEXTURE_CUBE_MAP_ARRAY data to CPU
Thomas
# store GL_TEXTURE_CUBE_MAP_ARRAY data to CPU

(Asked by: username_0 on 2022-05-17)

I have a GL\_TEXTURE\_CUBE\_MAP\_ARRAY texture of 8 cube maps (`countLayers`). Now I am trying to transfer the pixels to CPU.

Currently I am using this code:

```
unsigned int countFloats = size * size * countChannels * 6 * countLayers;
pixels = new float[countFloats];

glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, colorTexture()->id());
glGetTexImage(GL_TEXTURE_CUBE_MAP_ARRAY, 0, GL_RGBA, GL_FLOAT, pixels);

glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, 0);

```

It seems like, that this code works only for the first cubemap within the array. Because when deleting the multiplication with `countLayers` in the first line, everything is still working. But when `pixels` does not have enough storage (for example deleting the factor `6` as well), the program is crashing.

How can I store all cube maps to CPU? It would also be okay to store each cube map separately.

**Tags:** opengl, texture


---

## 1 answers

### Answer by username_0 on 2022-05-18. Score: 1 | Accepted answer

I found my mistake...
I was creating 6 cube maps, not 8... but when creating them I have to multiply the number of wanted cube maps by 6 which I didn't done. So the cube map array texture was only holding one cube map.

```
glTexStorage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 1, ToGlInternalFormat(format), size, size, layer); // this layer variable needs to be multiplied by 6

```

So the source code I posted within the question is working fine.


---

