LCOV - code coverage report
Current view: top level - source/renderer - SkyManager.h (source / functions) Hit Total Coverage
Test: 0 A.D. test coverage report Lines: 1 8 12.5 %
Date: 2023-01-19 00:18:29 Functions: 1 4 25.0 %

          Line data    Source code
       1             : /* Copyright (C) 2023 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             :  * Sky settings and texture management
      20             :  */
      21             : 
      22             : #ifndef INCLUDED_SKYMANAGER
      23             : #define INCLUDED_SKYMANAGER
      24             : 
      25             : #include "graphics/Texture.h"
      26             : #include "renderer/backend/IDeviceCommandContext.h"
      27             : #include "renderer/backend/IShaderProgram.h"
      28             : #include "renderer/backend/ITexture.h"
      29             : #include "renderer/VertexArray.h"
      30             : 
      31             : #include <memory>
      32             : #include <vector>
      33             : 
      34             : /**
      35             :  * Class SkyManager: Maintain sky settings and textures, and render the sky.
      36             :  */
      37           6 : class SkyManager
      38             : {
      39             : public:
      40             :     SkyManager();
      41             : 
      42             :     /**
      43             :      * Render the sky.
      44             :      */
      45             :     void RenderSky(
      46             :         Renderer::Backend::IDeviceCommandContext* deviceCommandContext);
      47             : 
      48             :     /**
      49             :      * Return the currently selected sky set name.
      50             :      */
      51           0 :     inline const CStrW& GetSkySet() const
      52             :     {
      53           0 :         return m_SkySet;
      54             :     }
      55             : 
      56             :     Renderer::Backend::ITexture* GetSkyCube();
      57             : 
      58             :     /**
      59             :      * Set the sky set name.
      60             :      */
      61             :     void SetSkySet(const CStrW& name);
      62             : 
      63             :     /**
      64             :      * Return a sorted list of available sky sets, in a form suitable
      65             :      * for passing to SetSkySet.
      66             :      */
      67             :     std::vector<CStrW> GetSkySets() const;
      68             : 
      69           0 :     bool IsSkyVisible() const
      70             :     {
      71           0 :         return m_SkyVisible;
      72             :     }
      73             : 
      74           0 :     void SetSkyVisible(bool value)
      75             :     {
      76           0 :         m_SkyVisible = value;
      77           0 :     }
      78             : 
      79             :     /**
      80             :      * Load all sky textures from files and upload to GPU.
      81             :      */
      82             :     void LoadAndUploadSkyTexturesIfNeeded(
      83             :         Renderer::Backend::IDeviceCommandContext* deviceCommandContext);
      84             : 
      85             : private:
      86             :     void CreateSkyCube();
      87             : 
      88             :     bool m_SkyVisible = true;
      89             : 
      90             :     /// Name of current skyset (a directory within art/textures/skies)
      91             :     CStrW m_SkySet;
      92             : 
      93             :     // Indices into m_SkyTexture
      94             :     enum
      95             :     {
      96             :         FRONT,
      97             :         BACK,
      98             :         RIGHT,
      99             :         LEFT,
     100             :         TOP,
     101             :         NUMBER_OF_TEXTURES
     102             :     };
     103             : 
     104             :     // Sky textures
     105             :     CTexturePtr m_SkyTexture[NUMBER_OF_TEXTURES];
     106             :     CTexturePtr m_SkyTextureCube;
     107             : 
     108             :     VertexArray m_VertexArray;
     109             :     VertexArray::Attribute m_AttributePosition;
     110             :     VertexArray::Attribute m_AttributeUV;
     111             : 
     112             :     Renderer::Backend::IVertexInputLayout* m_VertexInputLayout = nullptr;
     113             : };
     114             : 
     115             : 
     116             : #endif // INCLUDED_SKYMANAGER

Generated by: LCOV version 1.13