| 15 | } |
| 16 | |
| 17 | GL46TextureCubeArray::GL46TextureCubeArray(TextureCubeArray const* texture) |
| 18 | : |
| 19 | GL46TextureArray(texture, GL_TEXTURE_CUBE_MAP_ARRAY, GL_TEXTURE_BINDING_CUBE_MAP_ARRAY) |
| 20 | { |
| 21 | // Create a texture structure. |
| 22 | glGenTextures(1, &mGLHandle); |
| 23 | glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, mGLHandle); |
| 24 | |
| 25 | // Allocate (immutable) texture storage for all levels. |
| 26 | auto const width = texture->GetDimension(0); |
| 27 | auto const height = texture->GetDimension(1); |
| 28 | auto const numItems = texture->GetNumItems(); |
| 29 | auto const numCubes = texture->GetNumCubes(); |
| 30 | glTexStorage3D(GL_TEXTURE_CUBE_MAP_ARRAY, mNumLevels, mInternalFormat, width, height, numItems); |
| 31 | |
| 32 | // The default is 4-byte alignment. This allows byte alignment when data |
| 33 | // from user buffers into textures and vice versa. |
| 34 | glPixelStorei(GL_UNPACK_ALIGNMENT, 1); |
| 35 | glPixelStorei(GL_PACK_ALIGNMENT, 1); |
| 36 | |
| 37 | // Set the range of levels. |
| 38 | glTexParameteri(GL_TEXTURE_CUBE_MAP_ARRAY, GL_TEXTURE_BASE_LEVEL, 0); |
| 39 | glTexParameteri(GL_TEXTURE_CUBE_MAP_ARRAY, GL_TEXTURE_MAX_LEVEL, mNumLevels-1); |
| 40 | |
| 41 | // Initialize with data? |
| 42 | if (texture->GetData()) |
| 43 | { |
| 44 | if (CanAutoGenerateMipmaps()) |
| 45 | { |
| 46 | // Initialize with the first mipmap level and then generate |
| 47 | // the remaining mipmaps. |
| 48 | for (uint32_t cube = 0; cube < numCubes; ++cube) |
| 49 | { |
| 50 | for (uint32_t face = 0; face < texture->cubeFaceCount; ++face) |
| 51 | { |
| 52 | auto data = texture->GetDataFor(cube, face, 0); |
| 53 | if (data) |
| 54 | { |
| 55 | auto item = texture->GetItemIndexFor(cube, face); |
| 56 | LoadTextureLevel(item, 0, data); |
| 57 | } |
| 58 | } |
| 59 | } |
| 60 | GenerateMipmaps(); |
| 61 | } |
| 62 | else |
| 63 | { |
| 64 | // Initialize with each mipmap level. |
| 65 | for (uint32_t cube = 0; cube < numCubes; ++cube) |
| 66 | { |
| 67 | for (uint32_t face = 0; face < texture->cubeFaceCount; ++face) |
| 68 | { |
| 69 | for (int32_t level = 0; level < mNumLevels; ++level) |
| 70 | { |
| 71 | auto data = texture->GetDataFor(cube, face, level); |
| 72 | if (data) |
| 73 | { |
| 74 | auto item = texture->GetItemIndexFor(cube, face); |
nothing calls this directly
no test coverage detected