Pyrogenesis  trunk
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 
33 class 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
46 };
47 
49 {
50  static RenderPath FromString(const CStr8& name);
51  static CStr8 ToString(RenderPath);
52 };
53 
54 enum class RenderDebugMode
55 {
56  NONE,
57  AO,
58  ALPHA,
59  CUSTOM
60 };
61 
63 {
64  static RenderDebugMode FromString(const CStr8& name);
65  static CStrIntern ToString(RenderDebugMode mode);
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 
74 public:
77 
78  void ReadConfigAndSetupHooks();
79  void ClearHooks();
80 
81 #define OPTION_DEFAULT_SETTER(NAME, TYPE) \
82 public: void Set##NAME(TYPE value) { m_##NAME = value; }\
83 
84 #define OPTION_CUSTOM_SETTER(NAME, TYPE) \
85 public: void Set##NAME(TYPE value);\
86 
87 #define OPTION_GETTER(NAME, TYPE)\
88 public: TYPE Get##NAME() const { return m_##NAME; }\
89 
90 #define OPTION_DEF(NAME, TYPE)\
91 private: TYPE m_##NAME;
92 
93 #define OPTION(NAME, TYPE)\
94 OPTION_DEFAULT_SETTER(NAME, TYPE); OPTION_GETTER(NAME, TYPE); OPTION_DEF(NAME, TYPE);
95 
96 #define OPTION_WITH_SIDE_EFFECT(NAME, TYPE)\
97 OPTION_CUSTOM_SETTER(NAME, TYPE); OPTION_GETTER(NAME, TYPE); OPTION_DEF(NAME, TYPE);
98 
99  OPTION_WITH_SIDE_EFFECT(Shadows, bool);
100  OPTION_WITH_SIDE_EFFECT(ShadowPCF, bool);
101  OPTION_WITH_SIDE_EFFECT(Fog, 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 
131 private:
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
Definition: RenderingOptions.h:39
static CStr8 ToString(RenderPath)
Definition: RenderingOptions.cpp:69
#define OPTION_WITH_SIDE_EFFECT(NAME, TYPE)
Definition: RenderingOptions.h:96
CRenderingOptions g_RenderingOptions
Definition: RenderingOptions.cpp:35
static RenderPath FromString(const CStr8 &name)
Definition: RenderingOptions.cpp:56
Definition: RenderingOptions.h:68
Interned 8-bit strings.
Definition: CStrIntern.h:37
Definition: RenderingOptions.h:48
friend class CRenderingOptions
Definition: Renderer.h:153
RenderPath
Definition: RenderingOptions.h:35
RenderDebugMode
Definition: RenderingOptions.h:54
#define OPTION(NAME, TYPE)
Definition: RenderingOptions.h:93
Definition: RenderingOptions.h:42
Definition: RenderingOptions.h:62
Definition: RenderingOptions.h:45
Higher level interface on top of the whole frame rendering.
Definition: Renderer.h:48
std::unique_ptr< ConfigHooks > m_ConfigHooks
Definition: RenderingOptions.h:132
Definition: RenderingOptions.cpp:37