2 * Copyright © 2015 Canonical Ltd.
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com>
19 #ifndef ANBOX_GRAPHICS_PROGRAM_FAMILY_H_
20 #define ANBOX_GRAPHICS_PROGRAM_FAMILY_H_
23 #include <unordered_map>
26 #include <GLES2/gl2.h>
31 * ProgramFamily represents a set of GLSL programs that are closely
32 * related. Programs which point to the same shader source strings will be
33 * made to share the same compiled shader objects.
34 * A secondary intention is that this class may be extended to allow the
35 * different programs within the family to share common patterns of uniform
40 ProgramFamily() = default;
41 ProgramFamily(ProgramFamily const&) = delete;
42 ProgramFamily& operator=(ProgramFamily const&) = delete;
43 ~ProgramFamily() noexcept;
45 GLuint add_program(const GLchar* const static_vshader_src,
46 const GLchar* const static_fshader_src);
51 void init(GLenum type, const GLchar* src);
53 typedef std::unordered_map<const GLchar*, Shader> ShaderMap;
54 ShaderMap vshader, fshader;
56 typedef std::pair<GLuint, GLuint> ShaderPair;
60 std::map<ShaderPair, Program> program;
62 } // namespace graphics
65 #endif // MIR_RENDERER_GL_PROGRAM_FAMILY_H_