SuperTuxKart
Loading...
Searching...
No Matches
sp_per_object_uniform.hpp
1// SuperTuxKart - a fun racing game with go-kart
2// Copyright (C) 2018 SuperTuxKart-Team
3//
4// This program is free software; you can redistribute it and/or
5// modify it under the terms of the GNU General Public License
6// as published by the Free Software Foundation; either version 3
7// of the License, or (at your option) any later version.
8//
9// This program 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 this program; if not, write to the Free Software
16// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
18#ifndef HEADER_SP_PER_OBJECT_UNIFORM_HPP
19#define HEADER_SP_PER_OBJECT_UNIFORM_HPP
20
21#include <functional>
22#include <string>
23#include <unordered_map>
24#include <vector>
25
26namespace SP
27{
28
29class SPUniformAssigner;
31{
32private:
33 std::unordered_map<std::string,
34 std::function<void(SPUniformAssigner*)> > m_all_uniforms;
35public:
36 // ------------------------------------------------------------------------
37 void addAssignerFunction(const std::string& name,
38 std::function<void(SPUniformAssigner*)> func)
39 {
40 m_all_uniforms[name] = func;
41 }
42 // ------------------------------------------------------------------------
43 void removeAssignerFunction(const std::string& name)
44 {
45 auto it = m_all_uniforms.find(name);
46 if (it != m_all_uniforms.end())
47 {
48 m_all_uniforms.erase(it);
49 }
50 }
51 // ------------------------------------------------------------------------
52 bool hasUniform(const std::string& name) const
53 {
54 auto ret = m_all_uniforms.find(name);
55 if (ret == m_all_uniforms.end())
56 {
57 return false;
58 }
59 return true;
60 }
61 // ------------------------------------------------------------------------
62 bool assignUniform(const std::string& name, SPUniformAssigner* ua) const;
63 // ------------------------------------------------------------------------
64 bool isEmpty() const { return m_all_uniforms.empty(); }
65
66};
67
68}
69
70#endif
Definition: sp_per_object_uniform.hpp:31
Definition: sp_uniform_assigner.hpp:43