Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
RenderingOptions.h
Go to the documentation of this file.
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
34class CStrIntern;
35
37{
38 NONE,
39 AO,
40 ALPHA,
41 CUSTOM
42};
43
45{
46 static RenderDebugMode FromString(const CStr8& name);
48};
49
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
56public:
59
61 void ClearHooks();
62
63#define OPTION_DEFAULT_SETTER(NAME, TYPE) \
64public: void Set##NAME(TYPE value) { m_##NAME = value; }\
65
66#define OPTION_CUSTOM_SETTER(NAME, TYPE) \
67public: void Set##NAME(TYPE value);\
68
69#define OPTION_GETTER(NAME, TYPE)\
70public: TYPE Get##NAME() const { return m_##NAME; }\
71
72#define OPTION_DEF(NAME, TYPE)\
73private: TYPE m_##NAME;
74
75#define OPTION(NAME, TYPE)\
76OPTION_DEFAULT_SETTER(NAME, TYPE); OPTION_GETTER(NAME, TYPE); OPTION_DEF(NAME, TYPE);
77
78#define OPTION_WITH_SIDE_EFFECT(NAME, TYPE)\
79OPTION_CUSTOM_SETTER(NAME, TYPE); OPTION_GETTER(NAME, TYPE); OPTION_DEF(NAME, TYPE);
80
82 OPTION_WITH_SIDE_EFFECT(ShadowPCF, bool);
84
86
87 OPTION(WaterEffects, bool);
88 OPTION(WaterFancyEffects, bool);
89 OPTION(WaterRealDepth, bool);
90 OPTION(WaterRefraction, bool);
91 OPTION(WaterReflection, bool);
92
93 OPTION(ShadowAlphaFix, bool);
94 OPTION(Particles, bool);
95 OPTION(GPUSkinning, bool);
96 OPTION(Silhouettes, bool);
97 OPTION(SmoothLOS, bool);
98 OPTION(PostProc, bool);
99 OPTION(DisplayFrustum, bool);
100 OPTION(DisplayShadowsFrustum, bool);
101
102 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 OPTION(CutsceneMode, bool);
109
110 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
119private:
120 class ConfigHooks;
121 std::unique_ptr<ConfigHooks> m_ConfigHooks; // Hide this via PImpl to avoid including ConfigDB.h here.
122};
123
125
126#endif // INCLUDED_RENDERINGOPTIONS
CRenderingOptions g_RenderingOptions
Definition: RenderingOptions.cpp:40
RenderDebugMode
Definition: RenderingOptions.h:37
Higher level interface on top of the whole frame rendering.
Definition: Renderer.h:51
Definition: RenderingOptions.cpp:43
Definition: RenderingOptions.h:51
OPTION(ShadowAlphaFix, bool)
void ReadConfigAndSetupHooks()
Definition: RenderingOptions.cpp:121
OPTION(PostProc, bool)
OPTION_WITH_SIDE_EFFECT(ShadowPCF, bool)
OPTION_WITH_SIDE_EFFECT(RenderDebugMode, RenderDebugMode)
void ClearHooks()
Definition: RenderingOptions.cpp:246
OPTION(WaterReflection, bool)
OPTION(CutsceneMode, bool)
OPTION(GPUSkinning, bool)
OPTION(WaterRefraction, bool)
OPTION(WaterFancyEffects, bool)
std::unique_ptr< ConfigHooks > m_ConfigHooks
Definition: RenderingOptions.h:121
OPTION_WITH_SIDE_EFFECT(Shadows, bool)
OPTION(WaterEffects, bool)
OPTION(Silhouettes, bool)
OPTION_WITH_SIDE_EFFECT(Fog, bool)
OPTION(DisplayShadowsFrustum, bool)
OPTION(Particles, bool)
OPTION(SmoothLOS, bool)
OPTION(DisplayFrustum, bool)
OPTION(WaterRealDepth, bool)
CRenderingOptions()
Definition: RenderingOptions.cpp:94
OPTION(RenderActors, bool)
~CRenderingOptions()
Definition: RenderingOptions.cpp:116
OPTION(PBRBrightness, float)
Interned 8-bit strings.
Definition: CStrIntern.h:42
Definition: RenderingOptions.h:45
static CStrIntern ToString(RenderDebugMode mode)
Definition: RenderingOptions.cpp:78
static RenderDebugMode FromString(const CStr8 &name)
Definition: RenderingOptions.cpp:63