1 /* 2 Copyright (c) 2013 yvt 3 4 This file is part of OpenSpades. 5 6 OpenSpades is free software: you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation, either version 3 of the License, or 9 (at your option) any later version. 10 11 OpenSpades is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with OpenSpades. If not, see <http://www.gnu.org/licenses/>. 18 19 */ 20 21 #pragma once 22 23 #include <vector> 24 25 #include <Client/IRenderer.h> 26 #include <Core/Math.h> 27 #include "GLDynamicLight.h" 28 #include "GLProgramUniform.h" 29 30 namespace spades { 31 namespace draw { 32 class GLRenderer; 33 class GLImage; 34 class GLProgramManager; 35 class GLDynamicLightShader { 36 GLRenderer *lastRenderer; 37 GLImage *whiteImage; 38 39 GLProgramUniform dynamicLightOrigin; 40 GLProgramUniform dynamicLightColor; 41 GLProgramUniform dynamicLightRadius; 42 GLProgramUniform dynamicLightRadiusInversed; 43 GLProgramUniform dynamicLightSpotMatrix; 44 GLProgramUniform dynamicLightProjectionTexture; 45 46 public: 47 GLDynamicLightShader(); ~GLDynamicLightShader()48 ~GLDynamicLightShader() {} 49 50 static std::vector<GLShader *> RegisterShader(GLProgramManager *); 51 52 static bool Cull(const GLDynamicLight &light, const AABB3 &); 53 54 static bool SphereCull(const GLDynamicLight &light, const Vector3 ¢er, 55 float radius); 56 57 /** setups shadow shader. 58 * note that this function sets the current active texture 59 * stage to the returned texture stage. 60 * @param firstTexStage first available texture stage. 61 * @return next available texture stage */ 62 int operator()(GLRenderer *renderer, GLProgram *, const GLDynamicLight &light, 63 int firstTexStage); 64 }; 65 } 66 } 67