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

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