| 47 | } |
| 48 | |
| 49 | std::unique_ptr<vkb::scene_graph::components::HPPImage> HPPImage::load(const std::string &name, const std::string &uri, |
| 50 | ContentType content_type) |
| 51 | { |
| 52 | std::unique_ptr<vkb::scene_graph::components::HPPImage> image{nullptr}; |
| 53 | |
| 54 | auto data = fs::read_asset(uri); |
| 55 | |
| 56 | // Get extension |
| 57 | auto extension = get_extension(uri); |
| 58 | |
| 59 | // the derived classes Stb, Astc, and Ktx are not transcoded (yet), so we need some more complex casting here... |
| 60 | if (extension == "png" || extension == "jpg") |
| 61 | { |
| 62 | image = std::unique_ptr<vkb::scene_graph::components::HPPImage>(reinterpret_cast<vkb::scene_graph::components::HPPImage *>( |
| 63 | std::make_unique<vkb::sg::Stb>(name, data, static_cast<vkb::sg::Image::ContentType>(content_type)).release())); |
| 64 | } |
| 65 | else if (extension == "astc") |
| 66 | { |
| 67 | image = std::unique_ptr<vkb::scene_graph::components::HPPImage>( |
| 68 | reinterpret_cast<vkb::scene_graph::components::HPPImage *>(std::make_unique<vkb::sg::Astc>(name, data).release())); |
| 69 | } |
| 70 | else if ((extension == "ktx") || (extension == "ktx2")) |
| 71 | { |
| 72 | image = std::unique_ptr<vkb::scene_graph::components::HPPImage>(reinterpret_cast<vkb::scene_graph::components::HPPImage *>( |
| 73 | std::make_unique<vkb::sg::Ktx>(name, data, static_cast<vkb::sg::Image::ContentType>(content_type)).release())); |
| 74 | } |
| 75 | |
| 76 | return image; |
| 77 | } |
| 78 | |
| 79 | std::type_index HPPImage::get_type() |
| 80 | { |
nothing calls this directly
no test coverage detected