Pyrogenesis  trunk
SkyManager.h
Go to the documentation of this file.
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"
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  */
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  inline const CStrW& GetSkySet() const
52  {
53  return m_SkySet;
54  }
55 
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  bool IsSkyVisible() const
70  {
71  return m_SkyVisible;
72  }
73 
74  void SetSkyVisible(bool value)
75  {
76  m_SkyVisible = value;
77  }
78 
79  /**
80  * Load all sky textures from files and upload to GPU.
81  */
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  {
102  };
103 
104  // Sky textures
107 
111 
113 };
114 
115 
116 #endif // INCLUDED_SKYMANAGER
CTexturePtr m_SkyTextureCube
Definition: SkyManager.h:106
std::vector< CStrW > GetSkySets() const
Return a sorted list of available sky sets, in a form suitable for passing to SetSkySet.
Definition: SkyManager.cpp:189
Definition: ITexture.h:33
Definition: SkyManager.h:97
Definition: SkyManager.h:99
IVertexInputLayout stores precompiled list of vertex attributes.
Definition: IShaderProgram.h:73
Renderer::Backend::ITexture * GetSkyCube()
Definition: SkyManager.cpp:174
void SetSkyVisible(bool value)
Definition: SkyManager.h:74
const CStrW & GetSkySet() const
Return the currently selected sky set name.
Definition: SkyManager.h:51
Definition: VertexArray.h:140
CTexturePtr m_SkyTexture[NUMBER_OF_TEXTURES]
Definition: SkyManager.h:105
Renderer::Backend::IVertexInputLayout * m_VertexInputLayout
Definition: SkyManager.h:112
Definition: SkyManager.h:96
CStrW m_SkySet
Name of current skyset (a directory within art/textures/skies)
Definition: SkyManager.h:91
Definition: VertexArray.h:137
Definition: SkyManager.h:101
void RenderSky(Renderer::Backend::IDeviceCommandContext *deviceCommandContext)
Render the sky.
Definition: SkyManager.cpp:210
SkyManager()
Definition: SkyManager.cpp:43
void CreateSkyCube()
Definition: SkyManager.cpp:262
VertexArray::Attribute m_AttributeUV
Definition: SkyManager.h:110
VertexArray::Attribute m_AttributePosition
Definition: SkyManager.h:109
VertexArray m_VertexArray
Definition: SkyManager.h:108
void LoadAndUploadSkyTexturesIfNeeded(Renderer::Backend::IDeviceCommandContext *deviceCommandContext)
Load all sky textures from files and upload to GPU.
Definition: SkyManager.cpp:49
Definition: SkyManager.h:98
void SetSkySet(const CStrW &name)
Set the sky set name.
Definition: SkyManager.cpp:179
Definition: IDeviceCommandContext.h:40
bool m_SkyVisible
Definition: SkyManager.h:88
std::shared_ptr< CTexture > CTexturePtr
Definition: Texture.h:22
Definition: SkyManager.h:100
bool IsSkyVisible() const
Definition: SkyManager.h:69
Class SkyManager: Maintain sky settings and textures, and render the sky.
Definition: SkyManager.h:37