X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Funiformblock.cpp;h=2ff00fa221295ada6f8578cc89649b6936c70afe;hb=bd3e61a3d71a527b7b87197c2f52c5cf342aba81;hp=95e1c2b368100a2aa920d92efdb2f0ddcb4fc843;hpb=9846a5c6e73b3a146084894a11550dbbf184a22a;p=libs%2Fgl.git diff --git a/source/uniformblock.cpp b/source/uniformblock.cpp index 95e1c2b3..2ff00fa2 100644 --- a/source/uniformblock.cpp +++ b/source/uniformblock.cpp @@ -10,94 +10,9 @@ using namespace std; namespace Msp { namespace GL { -UniformBlock::~UniformBlock() +void UniformBlock::attach(int index, const Uniform &uni) { - for(map::iterator i=uniforms.begin(); i!=uniforms.end(); ++i) - delete i->second; -} - -void UniformBlock::uniform(int index, Uniform *uni) -{ - map::iterator i = uniforms.find(index); - if(i!=uniforms.end()) - { - delete i->second; - i->second = uni; - } - else - uniforms[index] = uni; -} - -void UniformBlock::uniform(int index, const Uniform &uni) -{ - uniform(index, uni.clone()); -} - -void UniformBlock::uniform(int index, int v) -{ - uniform(index, new Uniform1i(v)); -} - -void UniformBlock::uniform(int index, float v) -{ - uniform(index, new Uniform1f(v)); -} - -void UniformBlock::uniform(int index, float v0, float v1) -{ - uniform(index, new Uniform2f(v0, v1)); -} - -void UniformBlock::uniform2(int index, const float *v) -{ - uniform(index, v[0], v[1]); -} - -void UniformBlock::uniform(int index, float v0, float v1, float v2) -{ - uniform(index, new Uniform3f(v0, v1, v2)); -} - -void UniformBlock::uniform(int index, const Vector3 &v) -{ - uniform(index, v.x, v.y, v.z); -} - -void UniformBlock::uniform3(int index, const float *v) -{ - uniform(index, v[0], v[1], v[2]); -} - -void UniformBlock::uniform(int index, float v0, float v1, float v2, float v3) -{ - uniform(index, new Uniform4f(v0, v1, v2, v3)); -} - -void UniformBlock::uniform(int index, const Vector4 &v) -{ - uniform(index, v.x, v.y, v.z, v.w); -} - -void UniformBlock::uniform(int index, const Color &c) -{ - uniform(index, c.r, c.g, c.b, c.a); -} - -void UniformBlock::uniform4(int index, const float *v) -{ - uniform(index, v[0], v[1], v[2], v[3]); -} - -void UniformBlock::uniform_matrix4(int index, const float *v) -{ - uniform(index, new UniformMatrix4x4f(v)); -} - -void UniformBlock::uniform_matrix4(int index, const Matrix &m) -{ - float v[16]; - copy(m.data(), m.data()+16, v); - uniform_matrix4(index, v); + uniforms[index] = &uni; } void UniformBlock::apply(int index) const @@ -105,7 +20,7 @@ void UniformBlock::apply(int index) const if(index>=0) throw logic_error("GL_ARB_uniform_buffer_object support not implemented yet"); - for(map::const_iterator i=uniforms.begin(); i!=uniforms.end(); ++i) + for(map::const_iterator i=uniforms.begin(); i!=uniforms.end(); ++i) i->second->apply(i->first); }