MCPcopy Create free account
hub / github.com/GDRETools/gdsdecomp / load_images_from_layered_tex

Method load_images_from_layered_tex

compat/texture_loader_compat.cpp:727–768  ·  view source on GitHub ↗

TODO: What to do with this?

Source from the content-addressed store, hash-verified

725
726// TODO: What to do with this?
727Vector<Ref<Image>> TextureLoaderCompat::load_images_from_layered_tex(const String p_path, Error *r_err) {
728 Error err;
729 Vector<Ref<Image>> data;
730 const String res_path = p_path;
731
732 TextureLoaderCompat::TextureVersionType t = recognize(res_path, &err);
733 if (t == FORMAT_NOT_TEXTURE) {
734 if (r_err) {
735 *r_err = err;
736 }
737 ERR_FAIL_COND_V_MSG(err == ERR_FILE_UNRECOGNIZED, data, "File " + res_path + " is not a texture.");
738 ERR_FAIL_COND_V(err != OK, data);
739 }
740 auto textype = get_type_enum_from_version_type(t);
741 switch (textype) {
742 case TEXTURE_TYPE_3D: {
743 ResourceFormatLoaderCompatTexture3D rlcb;
744 Ref<Texture3D> res = rlcb.custom_load(res_path, {}, ResourceInfo::LoadType::NON_GLOBAL_LOAD, &err);
745 data = res->get_data();
746 } break;
747 case TEXTURE_TYPE_LAYERED: {
748 ResourceFormatLoaderCompatTextureLayered rlcb;
749 Ref<TextureLayered> res = rlcb.custom_load(res_path, {}, ResourceInfo::LoadType::NON_GLOBAL_LOAD, &err);
750
751 for (int i = 0; i < res->get_layers(); i++) {
752 data.push_back(res->get_layer_data(i));
753 }
754 } break;
755 default:
756 if (r_err) {
757 *r_err = ERR_INVALID_PARAMETER;
758 }
759 ERR_FAIL_V_MSG(data, "Not a 3d image texture: " + res_path);
760 break;
761 }
762
763 if (r_err) {
764 *r_err = err;
765 }
766 ERR_FAIL_COND_V_MSG(err != OK, data, "Texture " + res_path + " could not be loaded");
767 return data;
768}
769
770bool ResourceConverterTexture2D::handles_type(const String &p_type, int ver_major) const {
771 return (p_type == "Texture" && ver_major <= 3) || (p_type == "Texture2D") || (p_type == "StreamTexture") || (p_type == "CompressedTexture2D");

Callers

nothing calls this directly

Calls 4

push_backMethod · 0.80
get_layer_dataMethod · 0.80
custom_loadMethod · 0.45
get_dataMethod · 0.45

Tested by

no test coverage detected