public:
UniformScalar(Type v): value(v) { }
+ void set(Type v) { value = v; }
+
Type get() const { return value; }
virtual void apply(int index) const
Type value;
public:
- UniformVector(const T *vp)
+ UniformVector(const T *vp) { set(vp); }
+
+ void set(const T *vp)
{ std::copy(vp, vp+vecsize, value); }
BaseType get(unsigned i) const { return value[i]; }
Type value;
public:
- UniformMatrix(const T *vp)
+ UniformMatrix(const T *vp) { set(vp); }
+
+ void set(const T *vp)
{ std::copy(vp, vp+rows*cols, value); }
virtual void apply(int index) const
typedef typename T::BaseType BaseType;
enum { elemsize = sizeof(typename T::Type)/sizeof(typename T::BaseType) };
+ unsigned size_;
BaseType *values;
- unsigned size;
public:
UniformArray(unsigned n, const BaseType *vp):
- size(n)
+ size_(n),
+ values(new BaseType[elemsize*size_])
{
- values = new BaseType[elemsize*size];
- std::copy(vp, vp+elemsize*size, values);
+ set(vp);
}
~UniformArray()
delete[] values;
}
+ unsigned size() const { return size_; }
+
+ void set(const BaseType *vp)
+ { std::copy(vp, vp+elemsize*size_, values); }
+
virtual void apply(int index) const
- { T::apply(index, size, values); }
+ { T::apply(index, size_, values); }
virtual void store(const Program::UniformInfo &info, void *buffer) const
{
- for(unsigned i=0; i<size; ++i)
+ 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); }
+ { return new UniformArray(size_, values); }
};
} // namespace GL