LCOV - code coverage report
Current view: top level - source/renderer - RenderingOptions.h (source / functions) Hit Total Coverage
Test: 0 A.D. test coverage report Lines: 2 19 10.5 %
Date: 2023-01-19 00:18:29 Functions: 2 27 7.4 %

          Line data    Source code
       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             : 
      35             : enum RenderPath
      36             : {
      37             :     // If no rendering path is configured explicitly, the renderer
      38             :     // will choose the path when Open() is called.
      39             :     DEFAULT,
      40             : 
      41             :     // Classic fixed function.
      42             :     FIXED,
      43             : 
      44             :     // Use new ARB/GLSL system
      45             :     SHADER
      46             : };
      47             : 
      48             : struct RenderPathEnum
      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             : 
      62             : struct RenderDebugModeEnum
      63             : {
      64             :     static RenderDebugMode FromString(const CStr8& name);
      65             :     static CStrIntern ToString(RenderDebugMode mode);
      66             : };
      67             : 
      68             : class CRenderingOptions
      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:
      75             :     CRenderingOptions();
      76             :     ~CRenderingOptions();
      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           0 :     OPTION_WITH_SIDE_EFFECT(Shadows, bool);
     100           0 :     OPTION_WITH_SIDE_EFFECT(ShadowPCF, bool);
     101           0 :     OPTION_WITH_SIDE_EFFECT(Fog, bool);
     102             : 
     103           6 :     OPTION_WITH_SIDE_EFFECT(RenderPath, RenderPath);
     104             : 
     105           0 :     OPTION_WITH_SIDE_EFFECT(RenderDebugMode, RenderDebugMode);
     106             : 
     107           0 :     OPTION(WaterEffects, bool);
     108           0 :     OPTION(WaterFancyEffects, bool);
     109           0 :     OPTION(WaterRealDepth, bool);
     110           0 :     OPTION(WaterRefraction, bool);
     111           0 :     OPTION(WaterReflection, bool);
     112             : 
     113           0 :     OPTION(ShadowAlphaFix, bool);
     114           0 :     OPTION(Particles, bool);
     115           0 :     OPTION(GPUSkinning, bool);
     116           0 :     OPTION(Silhouettes, bool);
     117           0 :     OPTION(SmoothLOS, bool);
     118           6 :     OPTION(PostProc, bool);
     119           0 :     OPTION(DisplayFrustum, bool);
     120           0 :     OPTION(DisplayShadowsFrustum, bool);
     121             : 
     122           0 :     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             : 
     136             : extern CRenderingOptions g_RenderingOptions;
     137             : 
     138             : #endif // INCLUDED_RENDERINGOPTIONS

Generated by: LCOV version 1.13