~ubuntu-branches/debian/sid/ember/sid

1 by Michael Koch
Import upstream version 0.5.6
1
//
2
// C++ Interface: ShaderManager
3
//
4
// Description: 
5
//
6
//
7
// Author: Alexey Torkhov <atorkhov@gmail.com>, (C) 2009
8
//
9
// This program is free software; you can redistribute it and/or modify
10
// it under the terms of the GNU General Public License as published by
11
// the Free Software Foundation; either version 2 of the License, or
12
// (at your option) any later version.
13
// 
14
// This program is distributed in the hope that it will be useful,
15
// but WITHOUT ANY WARRANTY; without even the implied warranty of
16
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
// GNU General Public License for more details.
18
// 
19
// You should have received a copy of the GNU General Public License
20
// along with this program; if not, write to the Free Software
21
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.//
22
//
23
#ifndef EMBEROGRE_SHADERMANAGER_H
24
#define EMBEROGRE_SHADERMANAGER_H
25
26
#include "framework/ConsoleObject.h"
27
#include "services/config/ConfigListener.h"
28
29
#include <string>
30
#include <map>
31
#include <sigc++/signal.h>
32
33
namespace EmberOgre {
34
35
/**
36
 * @brief Utility class for setup shaders
37
 *
38
 * Utility class for setup shaders. It checks a set of materials and selects
39
 * best sheme they work at. Then it performs setup of auxilary things like
40
 * shadows.
41
 *
42
 * @author Alexey Torkhov <atorkhov@gmail.com>
43
 */
44
class ShaderManager : public Ember::ConsoleObject, public Ember::ConfigListenerContainer 
45
{
46
public:
47
	/**
48
	 * Enumeration of graphics levels
49
	 */
50
	enum GraphicsLevel {
51
		// Default scheme is when no scheme specified, very simple textured models
52
		LEVEL_DEFAULT,
53
54
		// Low level, shader model 2
55
		LEVEL_LOW,
56
57
		// Medium level, shader model 3
58
		LEVEL_MEDIUM,
59
60
		// High level, shader model 4
61
		LEVEL_HIGH,
62
63
		// Experimental level
64
		LEVEL_EXPERIMENTAL,
65
	};
66
67
	/**
68
	 * Constructor.
69
	 */
70
	ShaderManager();
71
72
	/**
73
	 * Destructor.
74
	 */
75
	~ShaderManager();
76
77
	/**
78
	 * Shaders initialization
79
	 */
80
	void init();
81
82
	/**
83
	 * Gets current graphics level
84
	 */
85
	GraphicsLevel getGraphicsLevel();
86
87
	/**
88
	 * Sets current graphics level
89
	 */
90
	GraphicsLevel setGraphicsLevel(GraphicsLevel newLevel);
91
92
	/**
93
	 * Reimplements the ConsoleObject::runCommand method
94
	 */
95
	virtual	void runCommand(const std::string &command, const std::string &args);
96
97
	/**
98
	 * Sets graphics level at runtime
99
	 */
100
	const Ember::ConsoleCommandWrapper SetLevel;
101
102
	/**
103
	 * Returns level id by its name
104
	 */
105
	GraphicsLevel getLevelByName(const std::string &level);
106
	
107
	/**
108
	 * @brief Emitted when the graphical level is changed.
109
	 */
110
	sigc::signal<void> EventLevelChanged;
111
112
private:
113
	/**
114
	 * Current graphics level
115
	 */
116
	GraphicsLevel mGraphicsLevel;
117
118
	/**
119
	 * Best graphics level supported, determined at initialization time
120
	 */
121
	GraphicsLevel mBestGraphicsLevel;
122
123
	/**
124
	 * Map of levels and schemes. Also used to convert levels to strings
125
	 */
126
	std::map<GraphicsLevel, std::string> mGraphicSchemes;
127
128
	/**
129
	 * Checks whether material is supported in current scheme
130
	 */
131
	bool checkMaterial(const std::string& materialName, const std::string& schemeName);
132
133
	/**
134
	 * Setups PSSM shadows
135
	 */
136
	void setPSSMShadows();
137
138
	/**
139
	 * Disables shadows
140
	 */
141
	void setNoShadows();
142
	
143
	/**
144
	 * @brief Called when the varconf setting for the graphics level changes. This will in turn call setGraphicsLevel.
145
	 * @param section 
146
	 * @param key 
147
	 * @param variable 
148
	 */
149
	void Config_Level(const std::string& section, const std::string& key, varconf::Variable& variable);
150
	
151
};
152
153
}
154
155
#endif