Added function to compile built in shaders

This commit is contained in:
Xiao Qi 2022-10-26 17:16:09 +08:00
parent 54796773b2
commit 4eaa15d999
3 changed files with 16 additions and 0 deletions

View File

@ -139,4 +139,17 @@ namespace SHADE
return {};
}
std::optional<std::string> SHShaderSourceCompiler::CompileShaderFromString
(std::string const& string, AssetPath path, SH_SHADER_TYPE type) noexcept
{
auto const data = CompileShaderSourceToMemory(string, path.filename().string(), type);
if (data == nullptr)
{
return{};
}
return CompileShaderSourceToBinary(path, *data);
}
}

View File

@ -24,5 +24,7 @@ namespace SHADE
public:
static std::optional<std::string> LoadAndCompileShader(AssetPath path) noexcept;
static std::optional<std::string> CompileShaderFromString
(std::string const& string, AssetPath path, SH_SHADER_TYPE type) noexcept;
};
}

View File

@ -82,6 +82,7 @@ namespace SHADE
static std::vector<SHAssetData const*> GetAllDataOfType(AssetType type) noexcept;
static std::vector<SHAsset> GetAllRecordOfType(AssetType type) noexcept;
private:
/****************************************************************************
* \brief Load resource data into memory