//---------------------------------------- ofLight::ofLight() :data(new Data){ setAmbientColor(ofColor(0,0,0)); setDiffuseColor(ofColor(255,255,255)); setSpecularColor(ofColor(255,255,255)); setPointLight(); // assume default attenuation factors // setAttenuation(1.f,0.f,0.f); }
//---------------------------------------- ofLight::ofLight(){ glIndex = -1; isEnabled = false; setAmbientColor(ofColor(0,0,0)); setDiffuseColor(ofColor(255,255,255)); setSpecularColor(ofColor(255,255,255)); setPointLight(); // assume default attenuation factors // setAttenuation(1.f,0.f,0.f); }
void PhongLightTechnique::addPointLight(PointLight& pointLight) { // Add light source to point light vector list m_vPointLights.push_back(pointLight); ++m_uiPointLightCount; // Enable shader program enable(); // Get the location for the current light uniform GLuint lightCount = (GLuint)(m_vPointLights.size() - 1); std::string sLightIndex = std::to_string(lightCount); std::string sTemp = "pointLight[" + sLightIndex + "]."; std::string sShaderLocation; // Init dir light location structure PointLightLocation pointLightLocation; memset(&pointLightLocation, 0, sizeof(PointLightLocation)); sShaderLocation = sTemp + "lightPosition"; pointLightLocation.PositionLocation = getUniformLocation(sShaderLocation.c_str()); sShaderLocation = sTemp + "ambientLight"; pointLightLocation.AmbientColorLocation = getUniformLocation(sShaderLocation.c_str()); sShaderLocation = sTemp + "diffuseLight"; pointLightLocation.DiffuseColorLocation = getUniformLocation(sShaderLocation.c_str()); sShaderLocation = sTemp + "specularLight"; pointLightLocation.SpecularColorLocation = getUniformLocation(sShaderLocation.c_str()); sShaderLocation = sTemp + "attenuation"; pointLightLocation.AttenuationLocation = getUniformLocation(sShaderLocation.c_str()); // Store point light uniform location m_vPointLightsLoc.push_back(pointLightLocation); // Update point light count glUniform1i(m_uiPointLightCountLoc, m_uiPointLightCount); // Set light index pointLight.lightIndex = lightCount; // Set uniform point light setPointLight(pointLight); // Create mesh representation of the light source addLightSourceMesh(&pointLight); }
//---------------------------------------- ofLight::ofLight(){ glIndex = -1; isEnabled = false; setPointLight(); }