|
From: Johan S. <joh...@gm...> - 2005-09-07 06:15:19
|
On 9/6/05, Christopher Dyken <e.c...@cm...> wrote:
>=20
>=20
> I tried updating an uniform attribute from within Renderable::render with
> the mechanisms of shallows, but
>=20
> void Foo::render() const
> {
> ...
> for(size_t i=3D0; i<m_Nt; i++) {
> m_shader->setParam3fv("b", 9, &m_tri_data[i].b[0]);
> ...
> }
> }
>=20
> fails with:
>=20
> sview: src/GLProgram.cpp:432: GLint
> shallows::GLProgram::validate_uniform(const char*) const:
> Assertion `it !=3D uniformsNameToType_.end() && "Internal
> Shallows error. The uniform map does not correspond with
> OpenGL."' failed.
> Aborted
Ish. This is indeed a bug. Could you send me the offending shader?=20
However, if I circumvent a little bit by adding
>=20
> unsigned int getProgramHandle() const { return programHandle_; }
>=20
> in GLProgram, the following
>=20
> void Foo::render() const
> {
> GLint location =3D glGetUniformLocation(m_shader->getProgramHandle(), "b"=
);
> if(location =3D=3D -1)
> throw std::runtime_error("fuuuu");
>=20
> for(size_t i=3D0; i<m_Nt; i++) {
> glUniform3fv(location, 9, &m_tri_data[i].b[0]);
> ...
> }
> }
>=20
> works like a charm.
>=20
> Could it be possible to add a back-door to do stuff like this, or does
> it completely break with the philosophy? The location index, or at
> least the program handle, is also needed for throwing uniform shader
> variables into buffer objects.
It does indeed break with the philosophy, but at the same time we must allo=
w=20
for different scenarios. I do think the getProgramHandle() is a good idea.=
=20
--=20
Help a man with his math problems and you get him off your back for a day.
Teach a man math, and you scare him off for the rest of your life.
Regards Johan Seland
PhD Student
Center of Mathematics for Applications
University of Oslo
|