Line data Source code
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"
22 : #include "graphics/ShaderProgramPtr.h"
23 : #include "lib/file/vfs/vfs_path.h"
24 : #include "ps/CStr.h"
25 : #include "renderer/backend/IShaderProgram.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 : */
33 0 : class CShaderProgram
34 : {
35 : NONCOPYABLE(CShaderProgram);
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 :
44 0 : Renderer::Backend::IShaderProgram* GetBackendShaderProgram() { return m_BackendShaderProgram.get(); }
45 :
46 : // TODO: add reloadable handles.
47 :
48 : protected:
49 : CShaderProgram(const CStr& name, const CShaderDefines& defines);
50 :
51 : CStr m_Name;
52 : CShaderDefines m_Defines;
53 : std::unique_ptr<Renderer::Backend::IShaderProgram> m_BackendShaderProgram;
54 : };
55 :
56 : #endif // INCLUDED_SHADERPROGRAM
|