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: 0 21 0.0 %
Date: 2021-09-24 14:46:47 Functions: 0 21 0.0 %

          Line data    Source code
       1             : /* Copyright (C) 2021 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             : class CRenderer;
      33             : 
      34             : enum RenderPath
      35             : {
      36             :     // If no rendering path is configured explicitly, the renderer
      37             :     // will choose the path when Open() is called.
      38             :     DEFAULT,
      39             : 
      40             :     // Classic fixed function.
      41             :     FIXED,
      42             : 
      43             :     // Use new ARB/GLSL system
      44             :     SHADER
      45             : };
      46             : 
      47             : struct RenderPathEnum
      48             : {
      49             :     static RenderPath FromString(const CStr8& name);
      50             :     static CStr8 ToString(RenderPath);
      51             : };
      52             : 
      53             : class CRenderingOptions
      54             : {
      55             :     // The renderer needs access to our private variables directly because capabilities have not yet been extracted
      56             :     // and thus sometimes it needs to change the rendering options without the side-effects.
      57             :     friend class CRenderer;
      58             : 
      59             : public:
      60             :     CRenderingOptions();
      61             :     ~CRenderingOptions();
      62             : 
      63             :     void ReadConfigAndSetupHooks();
      64             :     void ClearHooks();
      65             : 
      66             : #define OPTION_DEFAULT_SETTER(NAME, TYPE) \
      67             : public: void Set##NAME(TYPE value) { m_##NAME = value; }\
      68             : 
      69             : #define OPTION_CUSTOM_SETTER(NAME, TYPE) \
      70             : public: void Set##NAME(TYPE value);\
      71             : 
      72             : #define OPTION_GETTER(NAME, TYPE)\
      73             : public: TYPE Get##NAME() const { return m_##NAME; }\
      74             : 
      75             : #define OPTION_DEF(NAME, TYPE)\
      76             : private: TYPE m_##NAME;
      77             : 
      78             : #define OPTION(NAME, TYPE)\
      79             : OPTION_DEFAULT_SETTER(NAME, TYPE); OPTION_GETTER(NAME, TYPE); OPTION_DEF(NAME, TYPE);
      80             : 
      81             : #define OPTION_WITH_SIDE_EFFECT(NAME, TYPE)\
      82             : OPTION_CUSTOM_SETTER(NAME, TYPE); OPTION_GETTER(NAME, TYPE); OPTION_DEF(NAME, TYPE);
      83             : 
      84           0 :     OPTION_WITH_SIDE_EFFECT(Shadows, bool);
      85           0 :     OPTION_WITH_SIDE_EFFECT(ShadowPCF, bool);
      86           0 :     OPTION_WITH_SIDE_EFFECT(PreferGLSL, bool);
      87           0 :     OPTION_WITH_SIDE_EFFECT(Fog, bool);
      88             : 
      89           0 :     OPTION_WITH_SIDE_EFFECT(RenderPath, RenderPath);
      90             : 
      91           0 :     OPTION(WaterEffects, bool);
      92           0 :     OPTION(WaterFancyEffects, bool);
      93           0 :     OPTION(WaterRealDepth, bool);
      94           0 :     OPTION(WaterRefraction, bool);
      95           0 :     OPTION(WaterReflection, bool);
      96             : 
      97           0 :     OPTION(ShadowAlphaFix, bool);
      98           0 :     OPTION(ARBProgramShadow, bool);
      99           0 :     OPTION(Particles, bool);
     100           0 :     OPTION(ForceAlphaTest, bool);
     101           0 :     OPTION(GPUSkinning, bool);
     102           0 :     OPTION(Silhouettes, bool);
     103           0 :     OPTION(SmoothLOS, bool);
     104           0 :     OPTION(PostProc, bool);
     105           0 :     OPTION(DisplayFrustum, bool);
     106           0 :     OPTION(DisplayShadowsFrustum, bool);
     107             : 
     108           0 :     OPTION(RenderActors, bool);
     109             : 
     110             : #undef OPTION_DEFAULT_SETTER
     111             : #undef OPTION_CUSTOM_SETTER
     112             : #undef OPTION_GETTER
     113             : #undef OPTION_DEF
     114             : #undef OPTION
     115             : #undef OPTION_WITH_SIDE_EFFECT
     116             : 
     117             : private:
     118             :     class ConfigHooks;
     119             :     std::unique_ptr<ConfigHooks> m_ConfigHooks; // Hide this via PImpl to avoid including ConfigDB.h here.
     120             : };
     121             : 
     122             : extern CRenderingOptions g_RenderingOptions;
     123             : 
     124             : #endif // INCLUDED_RENDERINGOPTIONS

Generated by: LCOV version 1.13