Introduced new shader composition approach that utilizes #pragma requires(), #pragma import_defines() and #ifdef in GLSL to enable multiple different versions of shaders based
on defines passed in from osg::StateSet::setDefine(..). git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14681 16af8721-9629-0410-8352-f15c8da7e697
This commit is contained in:
@@ -850,49 +850,6 @@ void Geometry::drawPrimitivesImplementation(RenderInfo& renderInfo) const
|
||||
}
|
||||
}
|
||||
|
||||
class AttributeFunctorArrayVisitor : public ArrayVisitor
|
||||
{
|
||||
public:
|
||||
|
||||
AttributeFunctorArrayVisitor(Drawable::AttributeFunctor& af):
|
||||
_af(af),
|
||||
_type(0) {}
|
||||
|
||||
virtual ~AttributeFunctorArrayVisitor() {}
|
||||
|
||||
virtual void apply(ByteArray& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); }
|
||||
virtual void apply(ShortArray& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); }
|
||||
virtual void apply(IntArray& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); }
|
||||
virtual void apply(UByteArray& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); }
|
||||
virtual void apply(UShortArray& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); }
|
||||
virtual void apply(UIntArray& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); }
|
||||
virtual void apply(Vec4ubArray& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); }
|
||||
virtual void apply(FloatArray& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); }
|
||||
virtual void apply(Vec2Array& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); }
|
||||
virtual void apply(Vec3Array& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); }
|
||||
virtual void apply(Vec4Array& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); }
|
||||
virtual void apply(DoubleArray& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); }
|
||||
virtual void apply(Vec2dArray& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); }
|
||||
virtual void apply(Vec3dArray& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); }
|
||||
virtual void apply(Vec4dArray& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); }
|
||||
|
||||
|
||||
inline void applyArray(Drawable::AttributeType type,Array* array)
|
||||
{
|
||||
if (array)
|
||||
{
|
||||
_type = type;
|
||||
array->accept(*this);
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
AttributeFunctorArrayVisitor& operator = (const AttributeFunctorArrayVisitor&) { return *this; }
|
||||
Drawable::AttributeFunctor& _af;
|
||||
Drawable::AttributeType _type;
|
||||
};
|
||||
|
||||
void Geometry::accept(AttributeFunctor& af)
|
||||
{
|
||||
AttributeFunctorArrayVisitor afav(af);
|
||||
@@ -923,49 +880,6 @@ void Geometry::accept(AttributeFunctor& af)
|
||||
}
|
||||
}
|
||||
|
||||
class ConstAttributeFunctorArrayVisitor : public ConstArrayVisitor
|
||||
{
|
||||
public:
|
||||
|
||||
ConstAttributeFunctorArrayVisitor(Drawable::ConstAttributeFunctor& af):
|
||||
_af(af),
|
||||
_type(0) {}
|
||||
|
||||
virtual ~ConstAttributeFunctorArrayVisitor() {}
|
||||
|
||||
virtual void apply(const ByteArray& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); }
|
||||
virtual void apply(const ShortArray& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); }
|
||||
virtual void apply(const IntArray& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); }
|
||||
virtual void apply(const UByteArray& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); }
|
||||
virtual void apply(const UShortArray& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); }
|
||||
virtual void apply(const UIntArray& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); }
|
||||
virtual void apply(const Vec4ubArray& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); }
|
||||
virtual void apply(const FloatArray& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); }
|
||||
virtual void apply(const Vec2Array& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); }
|
||||
virtual void apply(const Vec3Array& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); }
|
||||
virtual void apply(const Vec4Array& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); }
|
||||
virtual void apply(const DoubleArray& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); }
|
||||
virtual void apply(const Vec2dArray& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); }
|
||||
virtual void apply(const Vec3dArray& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); }
|
||||
virtual void apply(const Vec4dArray& array) { if (!array.empty()) _af.apply(_type,array.size(),&(array.front())); }
|
||||
|
||||
|
||||
inline void applyArray(Drawable::AttributeType type,const Array* array)
|
||||
{
|
||||
if (array)
|
||||
{
|
||||
_type = type;
|
||||
array->accept(*this);
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
ConstAttributeFunctorArrayVisitor& operator = (const ConstAttributeFunctorArrayVisitor&) { return *this; }
|
||||
|
||||
Drawable::ConstAttributeFunctor& _af;
|
||||
Drawable::AttributeType _type;
|
||||
};
|
||||
|
||||
void Geometry::accept(ConstAttributeFunctor& af) const
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user