mirror of
https://github.com/hyprwm/hyprlock.git
synced 2024-11-17 23:15:59 +01:00
21 lines
669 B
C++
21 lines
669 B
C++
|
#include "Background.hpp"
|
||
|
#include "../Renderer.hpp"
|
||
|
|
||
|
CBackground::CBackground(const Vector2D& viewport_, const std::string& resourceID_) : viewport(viewport_), resourceID(resourceID_) {
|
||
|
;
|
||
|
}
|
||
|
|
||
|
bool CBackground::draw() {
|
||
|
if (!asset)
|
||
|
asset = g_pRenderer->asyncResourceGatherer->getAssetByID(resourceID);
|
||
|
|
||
|
if (!asset)
|
||
|
return false;
|
||
|
|
||
|
float bga = std::clamp(std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::system_clock::now() - g_pRenderer->gatheredAt).count() / 500000.0, 0.0, 1.0);
|
||
|
CBox monbox = {0, 0, viewport.x, viewport.y};
|
||
|
|
||
|
g_pRenderer->renderTexture(monbox, asset->texture, bga);
|
||
|
|
||
|
return bga < 1.0;
|
||
|
}
|