11 #ifndef hifi_render_utils_BackgroundStage_h
12 #define hifi_render_utils_BackgroundStage_h
14 #include <graphics/Stage.h>
16 #include <unordered_map>
17 #include <render/IndexedContainer.h>
18 #include <render/Stage.h>
19 #include "HazeStage.h"
21 #include "LightingModel.h"
25 class BackgroundStage :
public render::Stage {
27 static std::string _stageName;
28 static const std::string& getName() {
return _stageName; }
30 using Index = render::indexed_container::Index;
31 static const Index INVALID_INDEX;
32 static bool isIndexInvalid(Index index) {
return index == INVALID_INDEX; }
34 using BackgroundPointer = graphics::SunSkyStagePointer;
35 using Backgrounds = render::indexed_container::IndexedPointerVector<graphics::SunSkyStage>;
36 using BackgroundMap = std::unordered_map<BackgroundPointer, Index>;
38 using BackgroundIndices = std::vector<Index>;
41 Index findBackground(
const BackgroundPointer& background)
const;
42 Index addBackground(
const BackgroundPointer& background);
44 BackgroundPointer removeBackground(Index index);
46 bool checkBackgroundId(Index index)
const {
return _backgrounds.checkIndex(index); }
48 Index getNumBackgrounds()
const {
return _backgrounds.getNumElements(); }
49 Index getNumFreeBackgrounds()
const {
return _backgrounds.getNumFreeIndices(); }
50 Index getNumAllocatedBackgrounds()
const {
return _backgrounds.getNumAllocatedIndices(); }
52 BackgroundPointer getBackground(Index backgroundId)
const {
53 return _backgrounds.get(backgroundId);
56 Backgrounds _backgrounds;
57 BackgroundMap _backgroundMap;
63 void clear() { _backgrounds.clear(); }
65 void pushBackground(BackgroundStage::Index index) { _backgrounds.emplace_back(index); }
67 BackgroundStage::BackgroundIndices _backgrounds;
69 using FramePointer = std::shared_ptr<Frame>;
73 using BackgroundStagePointer = std::shared_ptr<BackgroundStage>;
75 class BackgroundStageSetup {
77 using JobModel = render::Job::Model<BackgroundStageSetup>;
79 BackgroundStageSetup();
80 void run(
const render::RenderContextPointer& renderContext);
83 class DrawBackgroundStage {
85 using Inputs = render::VaryingSet3<LightingModelPointer, BackgroundStage::FramePointer, HazeStage::FramePointer>;
86 using JobModel = render::Job::ModelI<DrawBackgroundStage, Inputs>;
88 DrawBackgroundStage() {}
90 void run(
const render::RenderContextPointer& renderContext,
const Inputs& inputs);