Nameless Engine
Loading...
Searching...
No Matches
RenderSettings.h
1#pragma once
2
3// Custom.
4#include "io/Serializable.h"
5
6#include "RenderSettings.generated.h"
7
8namespace ne RNAMESPACE() {
9 class Renderer;
10
12 enum class RendererType : unsigned int { DIRECTX = 0, VULKAN = 1 };
13
15 enum class AntialiasingQuality : unsigned int {
16 DISABLED = 1,
17 MEDIUM = 2,
18 HIGH = 4,
19 // no x8 MSAA because it has an absurd performance penalty with very little visual changes
20 };
21
23 enum class ShadowQuality : unsigned int {
24 LOW = 256,
25 MEDIUM = 512,
26 HIGH = 1024,
27 };
28
30 enum class TextureFilteringQuality : unsigned int {
31 LOW = 0, //< Point filtering.
32 MEDIUM = 1, //< Linear filtering.
33 HIGH = 2 //< Anisotropic filtering.
34 };
35
37 enum class TextureQuality : unsigned int {
38 VERY_HIGH = 0,
39 HIGH = 1,
40 MEDIUM = 2,
41 LOW = 3,
42 };
43
45 class RCLASS(Guid("eb477c6d-cdc4-4b7a-9349-296fb38e6bfc")) RenderSettings : public Serializable {
46 // Renderer will initialize this object.
47 friend class Renderer;
48
49 public:
50 RenderSettings() = default;
51 virtual ~RenderSettings() override = default;
52
58 static std::filesystem::path getPathToConfigurationFile();
59
65 void setFpsLimit(unsigned int iNewFpsLimit);
66
72 void setShadowQuality(ShadowQuality quality);
73
82 void setAntialiasingQuality(AntialiasingQuality quality);
83
89 void setTextureFilteringQuality(TextureFilteringQuality quality);
90
98 void setTextureQuality(TextureQuality quality);
99
108 void setRenderResolution(std::pair<unsigned int, unsigned int> resolution);
109
115 void setVsyncEnabled(bool bEnableVsync);
116
124 void setRefreshRate(std::pair<unsigned int, unsigned int> refreshRate);
125
135 void setGpuToUse(const std::string& sGpuName);
136
146 void setPreferredRenderer(RendererType preferredRenderer);
147
153 unsigned int getFpsLimit() const;
154
161 AntialiasingQuality getAntialiasingQuality() const;
162
168 ShadowQuality getShadowQuality() const;
169
179 std::variant<AntialiasingQuality, Error> getMaxSupportedAntialiasingQuality() const;
180
186 TextureFilteringQuality getTextureFilteringQuality() const;
187
193 TextureQuality getTextureQuality() const;
194
200 std::pair<unsigned int, unsigned int> getRenderResolution() const;
201
207 bool isVsyncEnabled() const;
208
214 std::pair<unsigned int, unsigned int> getRefreshRate() const;
215
225 std::string getGpuToUse() const;
226
227 protected:
235 virtual void onAfterDeserialized() override;
236
237 private:
245 static std::string getConfigurationFileName(bool bIncludeFileExtension);
246
254 void setRenderer(Renderer* pRenderer);
255
262 [[nodiscard]] std::optional<Error> clampSettingsToMaxSupported();
263
271 [[nodiscard]] std::optional<Error> saveConfigurationToDisk();
272
281 void notifyRendererAboutChangedSettings(bool bShadowMapSizeChanged = false);
282
284 RPROPERTY(Serialize)
285 unsigned int iRenderResolutionWidth = 0;
286
288 RPROPERTY(Serialize)
289 unsigned int iRenderResolutionHeight = 0;
290
292 RPROPERTY(Serialize)
293 unsigned int iRefreshRateNumerator = 0;
294
296 RPROPERTY(Serialize)
297 unsigned int iRefreshRateDenominator = 0;
298
304 RPROPERTY(Serialize)
305 unsigned int iFpsLimit = 0;
306
308 RPROPERTY(Serialize)
309 std::string sGpuToUse;
310
316 RPROPERTY(Serialize)
317 unsigned int iRendererType = 0;
318
320 RPROPERTY(Serialize)
321 unsigned int iShadowMapSize = static_cast<unsigned int>(ShadowQuality::HIGH);
322
324 RPROPERTY(Serialize)
325 unsigned int iAntialiasingSampleCount = static_cast<unsigned int>(AntialiasingQuality::HIGH);
326
328 RPROPERTY(Serialize)
329 unsigned int iTextureFilteringQuality = static_cast<unsigned int>(TextureFilteringQuality::HIGH);
330
332 RPROPERTY(Serialize)
333 unsigned int iTextureQuality = static_cast<unsigned int>(TextureQuality::VERY_HIGH);
334
336 RPROPERTY(Serialize)
337 bool bIsVsyncEnabled = false;
338
340 Renderer* pRenderer = nullptr;
341
352 bool bAllowSavingConfigurationToDisk = false;
353
355 static inline const char* sRenderSettingsConfigurationFileName = "render";
356
357 ne_RenderSettings_GENERATED
358 };
359} // namespace ne RNAMESPACE()
360
361File_RenderSettings_GENERATED
Definition: GuidProperty.h:30
Definition: RenderSettings.h:45
Definition: Renderer.h:43
Definition: Serializable.h:113
Definition: SerializeProperty.h:42