Pyrogenesis  trunk
ShaderProgram.h
Go to the documentation of this file.
1 /* Copyright (C) 2022 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 #ifndef INCLUDED_SHADERPROGRAM
19 #define INCLUDED_SHADERPROGRAM
20 
21 #include "graphics/ShaderDefines.h"
23 #include "lib/file/vfs/vfs_path.h"
24 #include "ps/CStr.h"
26 
27 #include <vector>
28 
29 /**
30  * A wrapper for backend shader program to handle high-level operations like
31  * file reloading and handling errors on reload.
32  */
34 {
36 
37 public:
38  static CShaderProgramPtr Create(const CStr& name, const CShaderDefines& defines);
39 
40  void Reload();
41 
42  std::vector<VfsPath> GetFileDependencies() const;
43 
45 
46  // TODO: add reloadable handles.
47 
48 protected:
49  CShaderProgram(const CStr& name, const CShaderDefines& defines);
50 
51  CStr m_Name;
53  std::unique_ptr<Renderer::Backend::IShaderProgram> m_BackendShaderProgram;
54 };
55 
56 #endif // INCLUDED_SHADERPROGRAM
CShaderProgram(const CStr &name, const CShaderDefines &defines)
Definition: ShaderProgram.cpp:25
std::vector< VfsPath > GetFileDependencies() const
Definition: ShaderProgram.cpp:46
Renderer::Backend::IShaderProgram * GetBackendShaderProgram()
Definition: ShaderProgram.h:44
IShaderProgram is a container for multiple shaders of different types.
Definition: IShaderProgram.h:80
std::unique_ptr< Renderer::Backend::IShaderProgram > m_BackendShaderProgram
Definition: ShaderProgram.h:53
Represents a mapping of name strings to value strings, for use with #if and #ifdef and similar condit...
Definition: ShaderDefines.h:146
void Reload()
Definition: ShaderProgram.cpp:38
CStr m_Name
Definition: ShaderProgram.h:51
CShaderDefines m_Defines
Definition: ShaderProgram.h:52
static CShaderProgramPtr Create(const CStr &name, const CShaderDefines &defines)
Definition: ShaderProgram.cpp:31
A wrapper for backend shader program to handle high-level operations like file reloading and handling...
Definition: ShaderProgram.h:33
NONCOPYABLE(CShaderProgram)
std::shared_ptr< CShaderProgram > CShaderProgramPtr
Definition: ShaderProgramPtr.h:25