Added function to manually compile shaders by path

This commit is contained in:
Xiao Qi 2022-10-27 14:24:03 +08:00
parent b10da2d160
commit 2102835629
2 changed files with 25 additions and 1 deletions

View File

@ -246,6 +246,28 @@ namespace SHADE
return result;
}
AssetID SHAssetManager::CompileAsset(AssetPath path) noexcept
{
SHAsset newAsset
{
.name = path.stem().string(),
.location = 0
};
auto const ext{ path.extension().string() };
if (ext == GLSL_EXTENSION.data())
{
newAsset.path = SHShaderSourceCompiler::LoadAndCompileShader(path).value();
newAsset.id = GenerateAssetID(AssetType::SHADER_BUILT_IN);
newAsset.type = AssetType::SHADER_BUILT_IN;
}
assetCollection.push_back(newAsset);
SHAssetMetaHandler::WriteMetaData(newAsset);
return newAsset.id;
}
bool SHAssetManager::IsRecognised(char const* ext) noexcept
{
for (auto const& e : EXTENSIONS)

View File

@ -83,6 +83,8 @@ namespace SHADE
static std::vector<SHAssetData const*> GetAllDataOfType(AssetType type) noexcept;
static std::vector<SHAsset> GetAllRecordOfType(AssetType type) noexcept;
static AssetID CompileAsset(AssetPath path) noexcept;
private:
static void InitLoaders() noexcept;