CG Kit提供资源(模型、纹理、shader、glTF等)的异步加载功能,将资源加载和渲染流程隔离。资源的动态异步加载可以消除耗时的资源加载对渲染流程的影响。
void OnSuccess(IResource* resource)
{
LOGINFO("Async Load %s is Succeed.", resource->GetFilePath().c_str());
……// 资源的继续使用,根据用户的逻辑来写
}
void MainApplication::OnFailed(const String &filePath)
{
LOGERROR("Async Load %s is failed.", filePath.c_str());
}std::shared_ptr<ResourceLoadInfo> info = std::make_shared<ResourceLoadInfo>();
info->filePath = path;
info->OnSuccess = [this](IResource* res) { OnSuccess(res); };
info->OnFailed = [this](const String& path) { OnFailed(path); };
gResourceManager.Load(info);