Line data Source code
1 : /* Copyright (C) 2022 Wildfire Games.
2 : * This file is part of 0 A.D.
3 : *
4 : * 0 A.D. is free software: you can redistribute it and/or modify
5 : * it under the terms of the GNU General Public License as published by
6 : * the Free Software Foundation, either version 2 of the License, or
7 : * (at your option) any later version.
8 : *
9 : * 0 A.D. is distributed in the hope that it will be useful,
10 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 : * GNU General Public License for more details.
13 : *
14 : * You should have received a copy of the GNU General Public License
15 : * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16 : */
17 :
18 : #ifndef INCLUDED_SILHOUETTERENDERER
19 : #define INCLUDED_SILHOUETTERENDERER
20 :
21 : #include "graphics/Overlay.h"
22 : #include "maths/BoundingBoxAligned.h"
23 : #include "renderer/backend/gl/DeviceCommandContext.h"
24 :
25 : class CCamera;
26 : class CModel;
27 : class CPatch;
28 : class SceneCollector;
29 :
30 : class SilhouetteRenderer
31 : {
32 : public:
33 : SilhouetteRenderer();
34 :
35 : void AddOccluder(CPatch* patch);
36 : void AddOccluder(CModel* model);
37 : void AddCaster(CModel* model);
38 :
39 : void ComputeSubmissions(const CCamera& camera);
40 : void RenderSubmitOverlays(SceneCollector& collector);
41 : void RenderSubmitOccluders(SceneCollector& collector);
42 : void RenderSubmitCasters(SceneCollector& collector);
43 :
44 : void RenderDebugBounds(
45 : Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext);
46 : void RenderDebugOverlays(
47 : Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext);
48 :
49 : void EndFrame();
50 :
51 : private:
52 : bool m_DebugEnabled;
53 :
54 : std::vector<CPatch*> m_SubmittedPatchOccluders;
55 : std::vector<CModel*> m_SubmittedModelOccluders;
56 : std::vector<CModel*> m_SubmittedModelCasters;
57 :
58 : std::vector<CPatch*> m_VisiblePatchOccluders;
59 : std::vector<CModel*> m_VisibleModelOccluders;
60 : std::vector<CModel*> m_VisibleModelCasters;
61 :
62 : struct DebugBounds
63 : {
64 : CColor color;
65 : CBoundingBoxAligned bounds;
66 : };
67 :
68 0 : struct DebugRect
69 : {
70 : CColor color;
71 : u16 x0, y0, x1, y1;
72 : };
73 :
74 : std::vector<DebugBounds> m_DebugBounds;
75 : std::vector<DebugRect> m_DebugRects;
76 :
77 : std::vector<SOverlaySphere> m_DebugSpheres;
78 : };
79 :
80 : #endif // INCLUDED_SILHOUETTERENDERER
|