MCPcopy Create free account
hub / github.com/KhronosGroup/Vulkan-Samples / load

Method load

framework/scene_graph/components/image.cpp:377–405  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

375}
376
377std::unique_ptr<Image> Image::load(const std::string &name, const std::string &uri,
378 ContentType content_type)
379{
380 std::unique_ptr<Image> image{nullptr};
381
382 auto data = fs::read_asset(uri);
383
384 // Get extension
385 auto extension = get_extension(uri);
386
387 if (extension == "png" || extension == "jpg")
388 {
389 image = std::make_unique<Stb>(name, data, content_type);
390 }
391 else if (extension == "astc")
392 {
393 image = std::make_unique<Astc>(name, data);
394 }
395 else if (extension == "ktx")
396 {
397 image = std::make_unique<Ktx>(name, data, content_type);
398 }
399 else if (extension == "ktx2")
400 {
401 image = std::make_unique<Ktx>(name, data, content_type);
402 }
403
404 return image;
405}
406
407} // namespace sg
408} // namespace vkb

Callers

nothing calls this directly

Calls 2

read_assetFunction · 0.85
get_extensionFunction · 0.85

Tested by

no test coverage detected