+
+template<typename T>
+class UniformArray: public Uniform
+{
+private:
+ typedef typename T::BaseType BaseType;
+ enum { elemsize = sizeof(typename T::Type)/sizeof(typename T::BaseType) };
+
+ BaseType *values;
+ unsigned size;
+
+public:
+ UniformArray(unsigned n, const BaseType *vp):
+ size(n)
+ {
+ values = new BaseType[elemsize*size];
+ std::copy(vp, vp+elemsize*size, values);
+ }
+
+ virtual void apply(int index) const
+ { T::apply(index, size, values); }
+
+ virtual void store(const Program::UniformInfo &info, void *buffer) const
+ {
+ for(unsigned i=0; i<size; ++i)
+ T::store(info, reinterpret_cast<char *>(buffer)+i*info.array_stride, values+i*elemsize);
+ }
+
+ virtual UniformArray *clone() const
+ { return new UniformArray(size, values); }
+};
+