summaryrefslogtreecommitdiffstats
path: root/scene/resources/shader_include.cpp
diff options
context:
space:
mode:
authorbitsawer <sawerduster@gmail.com>2023-08-17 11:17:54 +0300
committerbitsawer <sawerduster@gmail.com>2023-08-17 11:17:54 +0300
commit26e3443eef49a7189eba5e1648ae7be13d95afd2 (patch)
treeaa908c9c57595889cc28fd9af89608918f0f947b /scene/resources/shader_include.cpp
parenta278c1b98a81738a35b96a933a6e6cf771f9ab2d (diff)
downloadredot-engine-26e3443eef49a7189eba5e1648ae7be13d95afd2.tar.gz
Fix Shader and ShaderInclude resource loading
Diffstat (limited to 'scene/resources/shader_include.cpp')
-rw-r--r--scene/resources/shader_include.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/scene/resources/shader_include.cpp b/scene/resources/shader_include.cpp
index aead484cc1..323be6e491 100644
--- a/scene/resources/shader_include.cpp
+++ b/scene/resources/shader_include.cpp
@@ -88,13 +88,16 @@ Ref<Resource> ResourceFormatLoaderShaderInclude::load(const String &p_path, cons
*r_error = ERR_FILE_CANT_OPEN;
}
- Ref<ShaderInclude> shader_inc;
- shader_inc.instantiate();
-
- Vector<uint8_t> buffer = FileAccess::get_file_as_bytes(p_path);
+ Error error = OK;
+ Vector<uint8_t> buffer = FileAccess::get_file_as_bytes(p_path, &error);
+ ERR_FAIL_COND_V_MSG(error, nullptr, "Cannot load shader include: " + p_path);
String str;
- str.parse_utf8((const char *)buffer.ptr(), buffer.size());
+ error = str.parse_utf8((const char *)buffer.ptr(), buffer.size());
+ ERR_FAIL_COND_V_MSG(error, nullptr, "Cannot parse shader include: " + p_path);
+
+ Ref<ShaderInclude> shader_inc;
+ shader_inc.instantiate();
shader_inc->set_include_path(p_path);
shader_inc->set_code(str);