Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
RenderingOptions.h
Go to the documentation of this file.
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/**
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#include "ps/CStrIntern.h"
32
33class CRenderer;
34
36{
37 // If no rendering path is configured explicitly, the renderer
38 // will choose the path when Open() is called.
40
41 // Classic fixed function.
43
44 // Use new ARB/GLSL system
45 SHADER
46};
47
49{
50 static RenderPath FromString(const CStr8& name);
51 static CStr8 ToString(RenderPath);
52};
53
55{
56 NONE,
57 AO,
58 ALPHA,
59 CUSTOM
60};
61
63{
64 static RenderDebugMode FromString(const CStr8& name);
66};
67
69{
70 // The renderer needs access to our private variables directly because capabilities have not yet been extracted
71 // and thus sometimes it needs to change the rendering options without the side-effects.
72 friend class CRenderer;
73
74public:
77
79 void ClearHooks();
80
81#define OPTION_DEFAULT_SETTER(NAME, TYPE) \
82public: void Set##NAME(TYPE value) { m_##NAME = value; }\
83
84#define OPTION_CUSTOM_SETTER(NAME, TYPE) \
85public: void Set##NAME(TYPE value);\
86
87#define OPTION_GETTER(NAME, TYPE)\
88public: TYPE Get##NAME() const { return m_##NAME; }\
89
90#define OPTION_DEF(NAME, TYPE)\
91private: TYPE m_##NAME;
92
93#define OPTION(NAME, TYPE)\
94OPTION_DEFAULT_SETTER(NAME, TYPE); OPTION_GETTER(NAME, TYPE); OPTION_DEF(NAME, TYPE);
95
96#define OPTION_WITH_SIDE_EFFECT(NAME, TYPE)\
97OPTION_CUSTOM_SETTER(NAME, TYPE); OPTION_GETTER(NAME, TYPE); OPTION_DEF(NAME, TYPE);
98
100 OPTION_WITH_SIDE_EFFECT(ShadowPCF, bool);
102
104
106
107 OPTION(WaterEffects, bool);
108 OPTION(WaterFancyEffects, bool);
109 OPTION(WaterRealDepth, bool);
110 OPTION(WaterRefraction, bool);
111 OPTION(WaterReflection, bool);
112
113 OPTION(ShadowAlphaFix, bool);
114 OPTION(Particles, bool);
115 OPTION(GPUSkinning, bool);
116 OPTION(Silhouettes, bool);
117 OPTION(SmoothLOS, bool);
118 OPTION(PostProc, bool);
119 OPTION(DisplayFrustum, bool);
120 OPTION(DisplayShadowsFrustum, bool);
121
122 OPTION(RenderActors, bool);
123
124#undef OPTION_DEFAULT_SETTER
125#undef OPTION_CUSTOM_SETTER
126#undef OPTION_GETTER
127#undef OPTION_DEF
128#undef OPTION
129#undef OPTION_WITH_SIDE_EFFECT
130
131private:
132 class ConfigHooks;
133 std::unique_ptr<ConfigHooks> m_ConfigHooks; // Hide this via PImpl to avoid including ConfigDB.h here.
134};
135
137
138#endif // INCLUDED_RENDERINGOPTIONS
CRenderingOptions g_RenderingOptions
Definition: RenderingOptions.cpp:35
RenderPath
Definition: RenderingOptions.h:36
@ DEFAULT
Definition: RenderingOptions.h:39
@ FIXED
Definition: RenderingOptions.h:42
@ SHADER
Definition: RenderingOptions.h:45
RenderDebugMode
Definition: RenderingOptions.h:55
Higher level interface on top of the whole frame rendering.
Definition: Renderer.h:50
Definition: RenderingOptions.cpp:38
Definition: RenderingOptions.h:69
OPTION(ShadowAlphaFix, bool)
void ReadConfigAndSetupHooks()
Definition: RenderingOptions.cpp:141
OPTION(PostProc, bool)
OPTION_WITH_SIDE_EFFECT(ShadowPCF, bool)
OPTION_WITH_SIDE_EFFECT(RenderPath, RenderPath)
OPTION_WITH_SIDE_EFFECT(RenderDebugMode, RenderDebugMode)
void ClearHooks()
Definition: RenderingOptions.cpp:280
OPTION(WaterReflection, bool)
OPTION(GPUSkinning, bool)
OPTION(WaterRefraction, bool)
OPTION(WaterFancyEffects, bool)
std::unique_ptr< ConfigHooks > m_ConfigHooks
Definition: RenderingOptions.h:133
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:114
OPTION(RenderActors, bool)
~CRenderingOptions()
Definition: RenderingOptions.cpp:136
Interned 8-bit strings.
Definition: CStrIntern.h:38
Definition: RenderingOptions.h:63
static CStrIntern ToString(RenderDebugMode mode)
Definition: RenderingOptions.cpp:98
static RenderDebugMode FromString(const CStr8 &name)
Definition: RenderingOptions.cpp:83
Definition: RenderingOptions.h:49
static RenderPath FromString(const CStr8 &name)
Definition: RenderingOptions.cpp:56
static CStr8 ToString(RenderPath)
Definition: RenderingOptions.cpp:69