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

Method load_scene

framework/gltf_loader.cpp:497–1095  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

495 return std::move(load_model(index, storage_buffer, additional_buffer_usage_flags));
496}
497
498vkb::scene_graph::SceneC GLTFLoader::load_scene(int scene_index, VkBufferUsageFlags additional_buffer_usage_flags)
499{
500 PROFILE_SCOPE("Process Scene");
501
502 auto scene = vkb::scene_graph::SceneC();
503
504 scene.set_name("gltf_scene");
505
506 // Check extensions
507 for (auto &used_extension : model.extensionsUsed)
508 {
509 auto it = supported_extensions.find(used_extension);
510
511 // Check if extension isn't supported by the GLTFLoader
512 if (it == supported_extensions.end())
513 {
514 // If extension is required then we shouldn't allow the scene to be loaded
515 if (std::ranges::find(model.extensionsRequired, used_extension) != model.extensionsRequired.end())
516 {
517 throw std::runtime_error("Cannot load glTF file. Contains a required unsupported extension: " + used_extension);
518 }
519 else
520 {
521 // Otherwise, if extension isn't required (but is in the file) then print a warning to the user
522 LOGW("glTF file contains an unsupported extension, unexpected results may occur: {}", used_extension);
523 }
524 }
525 else
526 {
527 // Extension is supported, so enable it
528 LOGI("glTF file contains extension: {}", used_extension);
529 it->second = true;
530 }
531 }
532
533 // Load lights
534 std::vector<std::unique_ptr<sg::Light>> light_components = parse_khr_lights_punctual();
535
536 scene.set_components(std::move(light_components));
537
538 // Load samplers
539 std::vector<std::unique_ptr<vkb::scene_graph::components::SamplerC>>
540 sampler_components(model.samplers.size());
541
542 for (size_t sampler_index = 0; sampler_index < model.samplers.size(); sampler_index++)
543 {
544 auto sampler = parse_sampler(model.samplers[sampler_index]);
545 sampler_components[sampler_index] = std::move(sampler);
546 }
547
548 scene.set_components(std::move(sampler_components));
549
550 Timer timer;
551 timer.start();
552
553 // Load images
554 auto image_count = to_u32(model.images.size());

Callers

nothing calls this directly

Calls 15

to_u32Function · 0.85
upload_image_to_gpuFunction · 0.85
to_snake_caseFunction · 0.85
get_attribute_dataFunction · 0.85
get_attribute_formatFunction · 0.85
get_attribute_strideFunction · 0.85
get_attribute_sizeFunction · 0.85
get_extensionFunction · 0.85
endMethod · 0.80
set_componentsMethod · 0.80

Tested by

no test coverage detected