1 /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */
2 
3 #ifndef _GL_LIGHTHANDLER_H
4 #define _GL_LIGHTHANDLER_H
5 
6 #include <list>
7 #include <map>
8 #include "Light.h"
9 
10 namespace Shader {
11 	struct IProgramObject;
12 }
13 
14 namespace GL {
15 	struct LightHandler {
16 	public:
LightHandlerLightHandler17 		LightHandler(): baseLight(0), maxLights(0), numLights(0), lightHandle(0) {}
~LightHandlerLightHandler18 		~LightHandler() { Kill(); }
19 
20 		void Init(unsigned int, unsigned int);
KillLightHandler21 		void Kill() { lights.clear(); }
22 		void Update(Shader::IProgramObject*);
23 
24 		unsigned int AddLight(const GL::Light&);
25 		GL::Light* GetLight(unsigned int);
26 
GetBaseLightLightHandler27 		unsigned int GetBaseLight() const { return baseLight; }
GetMaxLightsLightHandler28 		unsigned int GetMaxLights() const { return maxLights; }
29 
30 	private:
31 		std::map<unsigned int, GL::Light> lights;
32 		std::list<unsigned int> lightIDs;
33 
34 		// sum of intensity weights for all active lights
35 		float3 lightIntensityWeight;
36 
37 		unsigned int baseLight;
38 		unsigned int maxLights;
39 		unsigned int numLights;
40 		unsigned int lightHandle;
41 	};
42 }
43 
44 #endif // _GL_LIGHTHANDLER_H
45