How to setup texture cube map array?

How to setup texture cube map array? I need some example.


HiGL_TexStorage3D(
	GL_TEXTURE_CUBE_MAP_ARRAY,
	Data->GetMipMap(),
	DestFormat,
	Data->GetWidth(),
	Data->GetHeight(),
	6 * Data->GetDepth()
	);
//how to fill data in cube map array???????
//i need some code example.

Thanks in advance :slight_smile:

Either:

  1. call glTexImage2D() for each face and mipmap level, using [var]target[/var] parameters of GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL_TEXTURE_CUBE_MAP_NEGATIVE_X, etc, or

  2. call glTexStorage2D() with a [var]target[/var] parameter of GL_TEXTURE_CUBE_MAP, then call glTexSubImage2D() for each face and mipmap level to provide the texture data.

Structurally, cubemap array textures are really just [2D array textures](https://www.opengl.org/wiki/Array Texture). So you should upload data to them like you would 2D array textures.

The main difficulty is understanding the difference between cubemap array layers and cubemap array layer-faces. Layers are the number of individual cubemaps in the array. Layer-faces are the number of 2D images in the array, so it’s the number of layers * 6. From the OpenGL side, you’re dealing primarily with layer-faces.

[QUOTE=GClements;1264940]Either:

  1. call glTexImage2D() for each face and mipmap level, using [var]target[/var] parameters of GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL_TEXTURE_CUBE_MAP_NEGATIVE_X, etc, or

  2. call glTexStorage2D() with a [var]target[/var] parameter of GL_TEXTURE_CUBE_MAP, then call glTexSubImage2D() for each face and mipmap level to provide the texture data.[/QUOTE]

You answered the wrong question. He’s asking how to send data to the cubemap array after creating storage for it, not how to create storage for it (which is code he already has).

Also, that’s the wrong answer for how to create storage for a cubemap [i]array[/i] texture. His code is correct for that.

[QUOTE=GClements;1264940]Either:

  1. call glTexImage2D() for each face and mipmap level, using [var]target[/var] parameters of GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL_TEXTURE_CUBE_MAP_NEGATIVE_X, etc, or

  2. call glTexStorage2D() with a [var]target[/var] parameter of GL_TEXTURE_CUBE_MAP, then call glTexSubImage2D() for each face and mipmap level to provide the texture data.[/QUOTE]

I want to create cubemap array, not cubemap. This is my assume


GLenum CubeFace[] = {
	GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
	GL_TEXTURE_CUBE_MAP_POSITIVE_Y, GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
	GL_TEXTURE_CUBE_MAP_POSITIVE_Z, GL_TEXTURE_CUBE_MAP_NEGATIVE_Z
};
glTexStorage3D(
	GL_TEXTURE_CUBE_MAP_ARRAY,
	Data->GetMipMap(),
	DestFormat,
	Data->GetWidth(),
	Data->GetHeight(),
	6 * Data->GetDepth()
	);
for (size_t ai = 0; ai < Data->GetDepth(); ai++)
{
	for (size_t fi = 0; fi < 6; fi++)
	{						
		glTexSubImage3D(
			CubeFace[fi], 0, 0, 0, ai, Data->GetWidth(), Data->GetHeight(), 1,
			...
			);
	}
}

But from this:
https://www.opengl.org/sdk/docs/man/html/glTexSubImage3D.xhtml
glTexSubImage3D target must be GL_TEXTURE_3D or GL_TEXTURE_2D_ARRAY, Very Confused to me. i don’t know to create cubemap array.
Thanks for reply. :slight_smile:

[QUOTE=Xiongmao;1264942]But from this:
https://www.opengl.org/sdk/docs/man/html/glTexSubImage3D.xhtml
glTexSubImage3D target must be GL_TEXTURE_3D or GL_TEXTURE_2D_ARRAY, Very Confused to me. [/quote]

That’s because the documentation is wrong. It also take GL_TEXTURE_CUBE_MAP_ARRAY.

Thanks. :slight_smile: