Merge 'remotes/trunk'
[0ad.git] / source / renderer / SkyManager.h
blobdb09031fdf7dee4af9093e8e3d9189aba1674ca8
1 /* Copyright (C) 2023 Wildfire Games.
2 * This file is part of 0 A.D.
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.
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.
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/>.
19 * Sky settings and texture management
22 #ifndef INCLUDED_SKYMANAGER
23 #define INCLUDED_SKYMANAGER
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"
31 #include <memory>
32 #include <vector>
34 /**
35 * Class SkyManager: Maintain sky settings and textures, and render the sky.
37 class SkyManager
39 public:
40 SkyManager();
42 /**
43 * Render the sky.
45 void RenderSky(
46 Renderer::Backend::IDeviceCommandContext* deviceCommandContext);
48 /**
49 * Return the currently selected sky set name.
51 inline const CStrW& GetSkySet() const
53 return m_SkySet;
56 Renderer::Backend::ITexture* GetSkyCube();
58 /**
59 * Set the sky set name.
61 void SetSkySet(const CStrW& name);
63 /**
64 * Return a sorted list of available sky sets, in a form suitable
65 * for passing to SetSkySet.
67 std::vector<CStrW> GetSkySets() const;
69 bool IsSkyVisible() const
71 return m_SkyVisible;
74 void SetSkyVisible(bool value)
76 m_SkyVisible = value;
79 /**
80 * Load all sky textures from files and upload to GPU.
82 void LoadAndUploadSkyTexturesIfNeeded(
83 Renderer::Backend::IDeviceCommandContext* deviceCommandContext);
85 private:
86 void CreateSkyCube();
88 bool m_SkyVisible = true;
90 /// Name of current skyset (a directory within art/textures/skies)
91 CStrW m_SkySet;
93 // Indices into m_SkyTexture
94 enum
96 FRONT,
97 BACK,
98 RIGHT,
99 LEFT,
100 TOP,
101 NUMBER_OF_TEXTURES
104 // Sky textures
105 CTexturePtr m_SkyTexture[NUMBER_OF_TEXTURES];
106 CTexturePtr m_SkyTextureCube;
108 VertexArray m_VertexArray;
109 VertexArray::Attribute m_AttributePosition;
110 VertexArray::Attribute m_AttributeUV;
112 Renderer::Backend::IVertexInputLayout* m_VertexInputLayout = nullptr;
116 #endif // INCLUDED_SKYMANAGER