1 | /* |
---|
2 | * ORXONOX - the hottest 3D action shooter ever to exist |
---|
3 | * > www.orxonox.net < |
---|
4 | * |
---|
5 | * |
---|
6 | * License notice: |
---|
7 | * |
---|
8 | * This program is free software; you can redistribute it and/or |
---|
9 | * modify it under the terms of the GNU General Public License |
---|
10 | * as published by the Free Software Foundation; either version 2 |
---|
11 | * of the License, or (at your option) any later version. |
---|
12 | * |
---|
13 | * This program is distributed in the hope that it will be useful, |
---|
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
16 | * GNU General Public License for more details. |
---|
17 | * |
---|
18 | * You should have received a copy of the GNU General Public License |
---|
19 | * along with this program; if not, write to the Free Software |
---|
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
21 | * |
---|
22 | * Author: |
---|
23 | * Fabian 'x3n' Landau |
---|
24 | * Co-authors: |
---|
25 | * ... |
---|
26 | * |
---|
27 | */ |
---|
28 | |
---|
29 | #ifndef _Shader_H__ |
---|
30 | #define _Shader_H__ |
---|
31 | |
---|
32 | #include "tools/ToolsPrereqs.h" |
---|
33 | |
---|
34 | #include <map> |
---|
35 | #include <string> |
---|
36 | #include <vector> |
---|
37 | |
---|
38 | #include "util/OgreForwardRefs.h" |
---|
39 | #include "tools/interfaces/Tickable.h" |
---|
40 | |
---|
41 | namespace orxonox |
---|
42 | { |
---|
43 | class _ToolsExport Shader : public Tickable |
---|
44 | { |
---|
45 | typedef std::pair<bool, void*> ParameterPointer; |
---|
46 | typedef std::map<std::string, ParameterPointer> ParameterMap; |
---|
47 | typedef std::vector<ParameterMap> PassVector; |
---|
48 | typedef std::vector<PassVector> TechniqueVector; |
---|
49 | typedef std::map<std::string, TechniqueVector> MaterialMap; |
---|
50 | |
---|
51 | public: |
---|
52 | Shader(Ogre::SceneManager* scenemanager = 0); |
---|
53 | virtual ~Shader(); |
---|
54 | |
---|
55 | virtual void tick(float dt); |
---|
56 | |
---|
57 | inline void setVisible(bool bVisible) |
---|
58 | { |
---|
59 | if (this->bVisible_ != bVisible) |
---|
60 | { |
---|
61 | this->bVisible_ = bVisible; |
---|
62 | this->updateVisibility(); |
---|
63 | } |
---|
64 | } |
---|
65 | inline bool isVisible() const |
---|
66 | { return this->bVisible_; } |
---|
67 | void updateVisibility(); |
---|
68 | |
---|
69 | inline void setCompositor(const std::string& compositor) |
---|
70 | { |
---|
71 | if (this->compositor_ != compositor) |
---|
72 | { |
---|
73 | this->compositor_ = compositor; |
---|
74 | this->changedCompositor(); |
---|
75 | } |
---|
76 | } |
---|
77 | inline const std::string& getCompositor() const |
---|
78 | { return this->compositor_; } |
---|
79 | void changedCompositor(); |
---|
80 | |
---|
81 | void setSceneManager(Ogre::SceneManager* scenemanager); |
---|
82 | inline Ogre::SceneManager* getSceneManager() const |
---|
83 | { return this->scenemanager_; } |
---|
84 | |
---|
85 | void setParameter(const std::string& material, size_t technique, size_t pass, const std::string& parameter, float value); |
---|
86 | void setParameter(const std::string& material, size_t technique, size_t pass, const std::string& parameter, int value); |
---|
87 | |
---|
88 | static bool _setParameter(const std::string& material, size_t technique, size_t pass, const std::string& parameter, float value); |
---|
89 | static bool _setParameter(const std::string& material, size_t technique, size_t pass, const std::string& parameter, int value); |
---|
90 | static float getParameter(const std::string& material, size_t technique, size_t pass, const std::string& parameter); |
---|
91 | static bool getParameterIsFloat(const std::string& material, size_t technique, size_t pass, const std::string& parameter); |
---|
92 | static bool getParameterIsInt (const std::string& material, size_t technique, size_t pass, const std::string& parameter); |
---|
93 | static ParameterPointer* getParameterPointer(const std::string& material, size_t technique, size_t pass, const std::string& parameter); |
---|
94 | |
---|
95 | private: |
---|
96 | Ogre::SceneManager* scenemanager_; |
---|
97 | Ogre::CompositorInstance* compositorInstance_; |
---|
98 | bool bVisible_; |
---|
99 | bool bLoadCompositor_; |
---|
100 | bool bViewportInitialized_; |
---|
101 | std::string compositor_; |
---|
102 | std::string oldcompositor_; |
---|
103 | |
---|
104 | static MaterialMap parameters_s; |
---|
105 | static bool bLoadedCgPlugin_s; |
---|
106 | }; |
---|
107 | } |
---|
108 | |
---|
109 | #endif /* _Shader_H__ */ |
---|