2023-01-06 01:39:25 +01:00
|
|
|
/* Copyright (C) 2023 Wildfire Games.
|
2023-12-03 01:30:12 +01:00
|
|
|
* This file is part of 0 A.D.
|
2009-04-18 19:00:33 +02:00
|
|
|
*
|
2023-12-03 01:30:12 +01:00
|
|
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
2009-04-18 19:00:33 +02:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
2023-12-03 01:30:12 +01:00
|
|
|
* 0 A.D. is distributed in the hope that it will be useful,
|
2009-04-18 19:00:33 +02:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2023-12-03 01:30:12 +01:00
|
|
|
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
2009-04-18 19:00:33 +02:00
|
|
|
*/
|
|
|
|
|
2009-04-18 19:51:05 +02:00
|
|
|
/*
|
|
|
|
* Sky settings and texture management
|
2006-05-16 06:41:37 +02:00
|
|
|
*/
|
|
|
|
|
2007-05-07 18:33:24 +02:00
|
|
|
#ifndef INCLUDED_SKYMANAGER
|
|
|
|
#define INCLUDED_SKYMANAGER
|
2006-05-16 06:41:37 +02:00
|
|
|
|
2010-09-10 23:02:10 +02:00
|
|
|
#include "graphics/Texture.h"
|
2022-05-09 00:02:46 +02:00
|
|
|
#include "renderer/backend/IDeviceCommandContext.h"
|
2023-01-06 01:39:25 +01:00
|
|
|
#include "renderer/backend/IShaderProgram.h"
|
2022-05-09 00:02:46 +02:00
|
|
|
#include "renderer/backend/ITexture.h"
|
2022-02-19 21:07:55 +01:00
|
|
|
#include "renderer/VertexArray.h"
|
2006-05-16 06:41:37 +02:00
|
|
|
|
2022-01-07 21:00:41 +01:00
|
|
|
#include <memory>
|
2021-01-17 16:40:10 +01:00
|
|
|
#include <vector>
|
|
|
|
|
2006-05-16 06:41:37 +02:00
|
|
|
/**
|
|
|
|
* Class SkyManager: Maintain sky settings and textures, and render the sky.
|
|
|
|
*/
|
|
|
|
class SkyManager
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SkyManager();
|
|
|
|
|
|
|
|
/**
|
2018-12-26 14:13:52 +01:00
|
|
|
* Render the sky.
|
2006-05-16 06:41:37 +02:00
|
|
|
*/
|
2022-01-19 18:28:47 +01:00
|
|
|
void RenderSky(
|
2022-05-09 00:02:46 +02:00
|
|
|
Renderer::Backend::IDeviceCommandContext* deviceCommandContext);
|
2006-05-16 06:41:37 +02:00
|
|
|
|
2006-05-17 04:24:17 +02:00
|
|
|
/**
|
2018-12-26 14:13:52 +01:00
|
|
|
* Return the currently selected sky set name.
|
2006-05-17 04:24:17 +02:00
|
|
|
*/
|
2018-12-26 14:13:52 +01:00
|
|
|
inline const CStrW& GetSkySet() const
|
|
|
|
{
|
2006-05-17 04:24:17 +02:00
|
|
|
return m_SkySet;
|
|
|
|
}
|
2016-11-23 12:18:37 +01:00
|
|
|
|
2022-05-09 00:02:46 +02:00
|
|
|
Renderer::Backend::ITexture* GetSkyCube();
|
2006-05-17 04:24:17 +02:00
|
|
|
|
|
|
|
/**
|
2022-01-07 21:00:41 +01:00
|
|
|
* Set the sky set name.
|
2006-05-17 04:24:17 +02:00
|
|
|
*/
|
2006-07-20 16:37:58 +02:00
|
|
|
void SetSkySet(const CStrW& name);
|
2006-05-17 04:24:17 +02:00
|
|
|
|
2006-06-22 00:37:31 +02:00
|
|
|
/**
|
|
|
|
* Return a sorted list of available sky sets, in a form suitable
|
|
|
|
* for passing to SetSkySet.
|
|
|
|
*/
|
|
|
|
std::vector<CStrW> GetSkySets() const;
|
|
|
|
|
2022-03-11 23:26:49 +01:00
|
|
|
bool IsSkyVisible() const
|
2018-12-26 14:13:52 +01:00
|
|
|
{
|
2022-03-11 23:26:49 +01:00
|
|
|
return m_SkyVisible;
|
2018-12-26 14:13:52 +01:00
|
|
|
}
|
|
|
|
|
2022-03-11 23:26:49 +01:00
|
|
|
void SetSkyVisible(bool value)
|
2018-12-26 14:13:52 +01:00
|
|
|
{
|
2022-03-11 23:26:49 +01:00
|
|
|
m_SkyVisible = value;
|
2018-12-26 14:13:52 +01:00
|
|
|
}
|
|
|
|
|
2022-01-07 21:00:41 +01:00
|
|
|
/**
|
|
|
|
* Load all sky textures from files and upload to GPU.
|
|
|
|
*/
|
|
|
|
void LoadAndUploadSkyTexturesIfNeeded(
|
2022-05-09 00:02:46 +02:00
|
|
|
Renderer::Backend::IDeviceCommandContext* deviceCommandContext);
|
2009-11-03 22:46:35 +01:00
|
|
|
|
2022-01-07 21:00:41 +01:00
|
|
|
private:
|
2022-02-19 21:07:55 +01:00
|
|
|
void CreateSkyCube();
|
|
|
|
|
2022-03-11 23:26:49 +01:00
|
|
|
bool m_SkyVisible = true;
|
2018-12-26 14:13:52 +01:00
|
|
|
|
2006-05-17 04:24:17 +02:00
|
|
|
/// Name of current skyset (a directory within art/textures/skies)
|
|
|
|
CStrW m_SkySet;
|
|
|
|
|
|
|
|
// Indices into m_SkyTexture
|
2009-11-03 22:46:35 +01:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
FRONT,
|
|
|
|
BACK,
|
|
|
|
RIGHT,
|
|
|
|
LEFT,
|
|
|
|
TOP,
|
2018-12-26 14:13:52 +01:00
|
|
|
NUMBER_OF_TEXTURES
|
2009-11-03 22:46:35 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
// Sky textures
|
2018-12-26 14:13:52 +01:00
|
|
|
CTexturePtr m_SkyTexture[NUMBER_OF_TEXTURES];
|
2022-04-17 12:10:52 +02:00
|
|
|
CTexturePtr m_SkyTextureCube;
|
2022-02-19 21:07:55 +01:00
|
|
|
|
|
|
|
VertexArray m_VertexArray;
|
|
|
|
VertexArray::Attribute m_AttributePosition;
|
|
|
|
VertexArray::Attribute m_AttributeUV;
|
2023-01-06 01:39:25 +01:00
|
|
|
|
|
|
|
Renderer::Backend::IVertexInputLayout* m_VertexInputLayout = nullptr;
|
2006-05-16 06:41:37 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2007-05-07 18:33:24 +02:00
|
|
|
#endif // INCLUDED_SKYMANAGER
|