Loads multiple images into one texture array or cube-map array
| 242 | |
| 243 | // Loads multiple images into one texture array or cube-map array |
| 244 | LLGL::Texture* LoadTextureArray(const LLGL::TextureType texType, const std::initializer_list<std::string>& texFilenames) |
| 245 | { |
| 246 | const std::string texPath = "../../Media/Textures/PBR/"; |
| 247 | |
| 248 | // Load image data |
| 249 | int texWidth = 0, texHeight = 0; |
| 250 | std::vector<std::uint8_t> imageData; |
| 251 | |
| 252 | for (auto filename : texFilenames) |
| 253 | { |
| 254 | if (filename.empty()) |
| 255 | FillImage(texWidth, texHeight, imageData); |
| 256 | else |
| 257 | LoadImage(texPath + filename, texWidth, texHeight, imageData); |
| 258 | } |
| 259 | |
| 260 | // Define initial texture data |
| 261 | LLGL::SrcImageDescriptor srcImageDesc; |
| 262 | { |
| 263 | srcImageDesc.format = LLGL::ImageFormat::RGBA; |
| 264 | srcImageDesc.dataType = LLGL::DataType::UInt8; |
| 265 | srcImageDesc.data = imageData.data(); |
| 266 | srcImageDesc.dataSize = imageData.size(); |
| 267 | } |
| 268 | |
| 269 | // Create texture |
| 270 | LLGL::TextureDescriptor texDesc; |
| 271 | { |
| 272 | texDesc.type = texType; |
| 273 | texDesc.format = LLGL::Format::RGBA8UNorm; |
| 274 | texDesc.extent.width = static_cast<std::uint32_t>(texWidth); |
| 275 | texDesc.extent.height = static_cast<std::uint32_t>(texHeight); |
| 276 | texDesc.extent.depth = 1; |
| 277 | texDesc.arrayLayers = static_cast<std::uint32_t>(texFilenames.size()); |
| 278 | } |
| 279 | auto tex = renderer->CreateTexture(texDesc, &srcImageDesc); |
| 280 | |
| 281 | return tex; |
| 282 | } |
| 283 | |
| 284 | void CreateTextures() |
| 285 | { |
nothing calls this directly
no test coverage detected