void PhongLightTechnique::addDirectionalLight(DirectionalLight& dirLight)
{
	// Add light source to dir light vector list
	m_vDirLights.push_back(dirLight);
	++m_uiDirLightCount;

	// Enable shader program
	enable();

	// Get the location for the current light uniform
	GLuint lightCount = (GLuint)(m_vDirLights.size() - 1);
	std::string sLightIndex = std::to_string(lightCount);
	std::string sTemp = "dirLight[" + sLightIndex + "].";
	std::string sShaderLocation;

	// Init dir light location structure
	DirectionalLightLocation directionalLightLocation;
	memset(&directionalLightLocation, 0, sizeof(DirectionalLightLocation));
	
	sShaderLocation = sTemp + "lightDirection";
	directionalLightLocation.DirectionLocation = getUniformLocation(sShaderLocation.c_str());
	sShaderLocation = sTemp + "ambientLight";
	directionalLightLocation.AmbientColorLocation = getUniformLocation(sShaderLocation.c_str());
	sShaderLocation = sTemp + "diffuseLight";
	directionalLightLocation.DiffuseColorLocation = getUniformLocation(sShaderLocation.c_str());
	sShaderLocation = sTemp + "specularLight";
	directionalLightLocation.SpecularColorLocation = getUniformLocation(sShaderLocation.c_str());

	// Store directional light uniform location
	m_vDirLightsLoc.push_back(directionalLightLocation);

	// Update dir light count
	glUniform1i(m_uiDirLightCountLoc, m_uiDirLightCount);

	// Set light index
	dirLight.lightIndex = lightCount;

	// Set uniform directional light
	setDirectionalLight(dirLight);
}
Esempio n. 2
0
GLLight::GLLight(const Vector3& direction)
:att2(0),att1(0),att0(1)
{
	setDirectionalLight(direction);
}