point->setDistanceAttenuation(attenuation);
attenuationPass->setAttributeAndModes(point);
Pass *spritePass = clone(basicPass, CopyOp::SHALLOW_COPY);
- spritePass->setTextureAttributeAndModes(0, pointSprite,
+ spritePass->setTextureAttributeAndModes(0, pointSprite.get(),
osg::StateAttribute::ON);
Texture2D* texture = gen_standard_light_sprite();
spritePass->setTextureAttribute(0, texture);
Pass *combinedPass = clone(spritePass, CopyOp::SHALLOW_COPY);
combinedPass->setAttributeAndModes(point);
Effect* effect = new Effect;
- std::vector<std::string> combinedExtensions;
- combinedExtensions.push_back("GL_ARB_point_sprite");
- combinedExtensions.push_back("GL_ARB_point_parameters");
- Technique* combinedTniq = new Technique;
- combinedTniq->passes.push_back(combinedPass);
- combinedTniq->setGLExtensionsPred(2.0, combinedExtensions);
- effect->techniques.push_back(combinedTniq);
- std::vector<std::string> spriteExtensions;
- spriteExtensions.push_back(combinedExtensions.front());
- Technique* spriteTniq = new Technique;
- spriteTniq->passes.push_back(spritePass);
- spriteTniq->setGLExtensionsPred(2.0, spriteExtensions);
- effect->techniques.push_back(spriteTniq);
std::vector<std::string> parameterExtensions;
- parameterExtensions.push_back(combinedExtensions.back());
+
+ if (SGSceneFeatures::instance()->getEnablePointSpriteLights())
+ {
+ std::vector<std::string> combinedExtensions;
+ combinedExtensions.push_back("GL_ARB_point_sprite");
+ combinedExtensions.push_back("GL_ARB_point_parameters");
+ Technique* combinedTniq = new Technique;
+ combinedTniq->passes.push_back(combinedPass);
+ combinedTniq->setGLExtensionsPred(2.0, combinedExtensions);
+ effect->techniques.push_back(combinedTniq);
+ std::vector<std::string> spriteExtensions;
+ spriteExtensions.push_back(combinedExtensions.front());
+ Technique* spriteTniq = new Technique;
+ spriteTniq->passes.push_back(spritePass);
+ spriteTniq->setGLExtensionsPred(2.0, spriteExtensions);
+ effect->techniques.push_back(spriteTniq);
+ parameterExtensions.push_back(combinedExtensions.back());
+ }
+
Technique* parameterTniq = new Technique;
parameterTniq->passes.push_back(attenuationPass);
parameterTniq->setGLExtensionsPred(1.4, parameterExtensions);
osg::Vec3Array* vertices = new osg::Vec3Array;
osg::Vec4Array* colors = new osg::Vec4Array;
- vertices->push_back(light.position.osg());
- colors->push_back(light.color.osg());
+ vertices->push_back(toOsg(light.position));
+ colors->push_back(toOsg(light.color));
osg::Geometry* geometry = new osg::Geometry;
geometry->setVertexArray(vertices);
SGVec3f perp1 = perpendicular(normal);
SGVec3f perp2 = cross(normal, perp1);
SGVec3f position = light.position;
- vertices->push_back(position.osg());
- vertices->push_back((position + perp1).osg());
- vertices->push_back((position + perp2).osg());
- colors->push_back(visibleColor.osg());
- colors->push_back(invisibleColor.osg());
- colors->push_back(invisibleColor.osg());
+ vertices->push_back(toOsg(position));
+ vertices->push_back(toOsg(position + perp1));
+ vertices->push_back(toOsg(position + perp2));
+ colors->push_back(toOsg(visibleColor));
+ colors->push_back(toOsg(invisibleColor));
+ colors->push_back(toOsg(invisibleColor));
osg::Geometry* geometry = new osg::Geometry;
geometry->setVertexArray(vertices);
osg::Vec4Array* colors = new osg::Vec4Array;
for (unsigned i = 0; i < lights.getNumLights(); i += inc) {
- vertices->push_back(lights.getLight(i).position.osg());
+ vertices->push_back(toOsg(lights.getLight(i).position));
SGVec4f color = lights.getLight(i).color;
color[3] = SGMiscf::max(0, SGMiscf::min(1, color[3] + alphaOff));
- colors->push_back(color.osg());
+ colors->push_back(toOsg(color));
}
osg::Geometry* geometry = new osg::Geometry;
SGVec3f perp1 = perpendicular(normal);
SGVec3f perp2 = cross(normal, perp1);
SGVec3f position = lights.getLight(i).position;
- vertices->push_back(position.osg());
- vertices->push_back((position + perp1).osg());
- vertices->push_back((position + perp2).osg());
- colors->push_back(visibleColor.osg());
- colors->push_back(invisibleColor.osg());
- colors->push_back(invisibleColor.osg());
+ vertices->push_back(toOsg(position));
+ vertices->push_back(toOsg(position + perp1));
+ vertices->push_back(toOsg(position + perp2));
+ colors->push_back(toOsg(visibleColor));
+ colors->push_back(toOsg(invisibleColor));
+ colors->push_back(toOsg(invisibleColor));
}
osg::Geometry* geometry = new osg::Geometry;