Line data Source code
1 : /* Copyright (C) 2026 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 : /**
19 : * Keeps track of the settings used for rendering.
20 : * Ideally this header file should remain very quick to parse,
21 : * so avoid including other headers here unless absolutely necessary.
22 : *
23 : * Lifetime concerns: g_RenderingOptions always exists, but hooks are tied to the configDB's lifetime
24 : * an the renderer may or may not actually exist.
25 : */
26 :
27 : #ifndef INCLUDED_RENDERINGOPTIONS
28 : #define INCLUDED_RENDERINGOPTIONS
29 :
30 : #include "ps/CStr.h"
31 :
32 : #include <memory>
33 :
34 : class CStrIntern;
35 :
36 : enum class RenderDebugMode
37 : {
38 : NONE,
39 : AO,
40 : ALPHA,
41 : CUSTOM
42 : };
43 :
44 : struct RenderDebugModeEnum
45 : {
46 : static RenderDebugMode FromString(const CStr8& name);
47 : static CStrIntern ToString(RenderDebugMode mode);
48 : };
49 :
50 : class CRenderingOptions
51 : {
52 : // The renderer needs access to our private variables directly because capabilities have not yet been extracted
53 : // and thus sometimes it needs to change the rendering options without the side-effects.
54 : friend class CRenderer;
55 :
56 : public:
57 : CRenderingOptions();
58 : ~CRenderingOptions();
59 :
60 : void ReadConfigAndSetupHooks();
61 : void ClearHooks();
62 :
63 : #define OPTION_DEFAULT_SETTER(NAME, TYPE) \
64 : public: void Set##NAME(TYPE value) { m_##NAME = value; }\
65 :
66 : #define OPTION_CUSTOM_SETTER(NAME, TYPE) \
67 : public: void Set##NAME(TYPE value);\
68 :
69 : #define OPTION_GETTER(NAME, TYPE)\
70 : public: TYPE Get##NAME() const { return m_##NAME; }\
71 :
72 : #define OPTION_DEF(NAME, TYPE)\
73 : private: TYPE m_##NAME;
74 :
75 : #define OPTION(NAME, TYPE)\
76 : OPTION_DEFAULT_SETTER(NAME, TYPE); OPTION_GETTER(NAME, TYPE); OPTION_DEF(NAME, TYPE);
77 :
78 : #define OPTION_WITH_SIDE_EFFECT(NAME, TYPE)\
79 : OPTION_CUSTOM_SETTER(NAME, TYPE); OPTION_GETTER(NAME, TYPE); OPTION_DEF(NAME, TYPE);
80 :
81 0 : OPTION_WITH_SIDE_EFFECT(Shadows, bool);
82 0 : OPTION_WITH_SIDE_EFFECT(ShadowPCF, bool);
83 0 : OPTION_WITH_SIDE_EFFECT(Fog, bool);
84 :
85 0 : OPTION_WITH_SIDE_EFFECT(RenderDebugMode, RenderDebugMode);
86 :
87 20 : OPTION(WaterEffects, bool);
88 0 : OPTION(WaterFancyEffects, bool);
89 0 : OPTION(WaterRealDepth, bool);
90 0 : OPTION(WaterRefraction, bool);
91 0 : OPTION(WaterReflection, bool);
92 :
93 20 : OPTION(ShadowAlphaFix, bool);
94 0 : OPTION(Particles, bool);
95 0 : OPTION(GPUSkinning, bool);
96 0 : OPTION(Silhouettes, bool);
97 0 : OPTION(SmoothLOS, bool);
98 30 : OPTION(PostProc, bool);
99 0 : OPTION(DisplayFrustum, bool);
100 0 : OPTION(DisplayShadowsFrustum, bool);
101 :
102 0 : OPTION(PBRBrightness, float);
103 :
104 : // Cutscene Mode: while active, (most) visual overlays aren't rendered in order to give the scene a more "pure"
105 : // and real feel, like a movie.
106 : // The idea is for it to be inactive during normal gameplay, but enabled while playing cinema paths and
107 : // potentially during other scripted story events/cutscenes as well, like speech/dialogue.
108 0 : OPTION(CutsceneMode, bool);
109 :
110 0 : OPTION(RenderActors, bool);
111 :
112 : #undef OPTION_DEFAULT_SETTER
113 : #undef OPTION_CUSTOM_SETTER
114 : #undef OPTION_GETTER
115 : #undef OPTION_DEF
116 : #undef OPTION
117 : #undef OPTION_WITH_SIDE_EFFECT
118 :
119 : private:
120 : class ConfigHooks;
121 : std::unique_ptr<ConfigHooks> m_ConfigHooks; // Hide this via PImpl to avoid including ConfigDB.h here.
122 : };
123 :
124 : extern CRenderingOptions g_RenderingOptions;
125 :
126 : #endif // INCLUDED_RENDERINGOPTIONS
|