74cb74d3c9
- namespace refactor (example: wiGraphics:: -> wi::graphics) - provided namespace compatibility macro for old user code: WICKEDENGINE_BACKWARDS_COMPATIBILITY_0_59 - resource manager will return `Resource` instead of `shared_ptr<Resource>` objects - MAD shader optimizations - implemented alpha to coverage with alpha tested materials when MSAA is enabled - alpha testing fix with transparent shadow maps - TLAS and scene buffers will be recreated less frequently when things get added/removed from the scene
61 lines
1.1 KiB
C++
61 lines
1.1 KiB
C++
#include "wiLoadingScreen.h"
|
|
#include "wiApplication.h"
|
|
|
|
#include <thread>
|
|
|
|
namespace wi
|
|
{
|
|
|
|
bool LoadingScreen::isActive()
|
|
{
|
|
return wi::jobsystem::IsBusy(ctx);
|
|
}
|
|
|
|
void LoadingScreen::addLoadingFunction(std::function<void(wi::jobsystem::JobArgs)> loadingFunction)
|
|
{
|
|
if (loadingFunction != nullptr)
|
|
{
|
|
tasks.push_back(loadingFunction);
|
|
}
|
|
}
|
|
|
|
void LoadingScreen::addLoadingComponent(RenderPath* component, Application* main, float fadeSeconds, wi::Color fadeColor)
|
|
{
|
|
addLoadingFunction([=](wi::jobsystem::JobArgs args) {
|
|
component->Load();
|
|
});
|
|
onFinished([=] {
|
|
main->ActivatePath(component, fadeSeconds, fadeColor);
|
|
});
|
|
}
|
|
|
|
void LoadingScreen::onFinished(std::function<void()> finishFunction)
|
|
{
|
|
if (finishFunction != nullptr)
|
|
finish = finishFunction;
|
|
}
|
|
|
|
void LoadingScreen::Start()
|
|
{
|
|
for (auto& x : tasks)
|
|
{
|
|
wi::jobsystem::Execute(ctx, x);
|
|
}
|
|
std::thread([this]() {
|
|
wi::jobsystem::Wait(ctx);
|
|
finish();
|
|
}).detach();
|
|
|
|
RenderPath2D::Start();
|
|
}
|
|
|
|
void LoadingScreen::Stop()
|
|
{
|
|
tasks.clear();
|
|
finish = nullptr;
|
|
|
|
RenderPath2D::Stop();
|
|
}
|
|
|
|
}
|