summaryrefslogtreecommitdiffstats
path: root/src/AssetManager.cpp
diff options
context:
space:
mode:
authorLaG1924 <12997935+LaG1924@users.noreply.github.com>2021-06-22 02:47:45 +0200
committerGitHub <noreply@github.com>2021-06-22 02:47:45 +0200
commite93df8332d86b67dff89d24788525a027b8d0c4c (patch)
tree3c2e085706f3824aa34d2dce5747c9c86a79723a /src/AssetManager.cpp
parentMerge pull request #56 from LaG1924/ftr/upgrade-build-system (diff)
parentMinor changes to Ui scripts (diff)
downloadAltCraft-e93df8332d86b67dff89d24788525a027b8d0c4c.tar
AltCraft-e93df8332d86b67dff89d24788525a027b8d0c4c.tar.gz
AltCraft-e93df8332d86b67dff89d24788525a027b8d0c4c.tar.bz2
AltCraft-e93df8332d86b67dff89d24788525a027b8d0c4c.tar.lz
AltCraft-e93df8332d86b67dff89d24788525a027b8d0c4c.tar.xz
AltCraft-e93df8332d86b67dff89d24788525a027b8d0c4c.tar.zst
AltCraft-e93df8332d86b67dff89d24788525a027b8d0c4c.zip
Diffstat (limited to '')
-rw-r--r--src/AssetManager.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/AssetManager.cpp b/src/AssetManager.cpp
index 514d008..7bcfaae 100644
--- a/src/AssetManager.cpp
+++ b/src/AssetManager.cpp
@@ -64,6 +64,9 @@ void AssetManager::InitAssetManager()
ParseBlockModels();
PluginSystem::Init();
+}
+
+void AssetManager::InitPostRml() {
LoadScripts();
}
@@ -402,22 +405,26 @@ void ParseAssetShader(AssetTreeNode &node) {
std::string vertPath = j["vert"].get<std::string>();
std::string fragPath = j["frag"].get<std::string>();
- AssetTreeNode *vertAsset = AssetManager::GetAssetByAssetName(vertPath);
- AssetTreeNode *fragAsset = AssetManager::GetAssetByAssetName(fragPath);
+ AssetTreeNode* vertAsset = AssetManager::GetAssetByAssetName(vertPath);
+ AssetTreeNode* fragAsset = AssetManager::GetAssetByAssetName(fragPath);
std::string vertSource((char*)vertAsset->data.data(), (char*)vertAsset->data.data() + vertAsset->data.size());
std::string fragSource((char*)fragAsset->data.data(), (char*)fragAsset->data.data() + fragAsset->data.size());
std::vector<std::string> uniforms;
- for (auto &it : j["uniforms"]) {
+ for (auto& it : j["uniforms"]) {
uniforms.push_back(it.get<std::string>());
}
node.asset = std::make_unique<AssetShader>();
- AssetShader *asset = dynamic_cast<AssetShader*>(node.asset.get());
+ AssetShader* asset = dynamic_cast<AssetShader*>(node.asset.get());
asset->shader = std::make_unique<Shader>(vertSource, fragSource, uniforms);
+ } catch (std::exception &e) {
+ glCheckError();
+ LOG(ERROR) << "Shader asset parsing failed: " << e.what();
} catch (...) {
glCheckError();
+ LOG(ERROR) << "Shader asset parsing failed with unknown reason";
return;
}
}
@@ -426,8 +433,6 @@ void ParseAssetScript(AssetTreeNode &node) {
node.asset = std::make_unique<AssetScript>();
AssetScript *asset = dynamic_cast<AssetScript*>(node.asset.get());
asset->code = std::string((char*)node.data.data(), (char*)node.data.data() + node.data.size());
- node.data.clear();
- node.data.shrink_to_fit();
}
void ParseBlockModels() {