Page 1 of 1

make GpuProgramParameters::setConstant easier to use

Posted: Wed Jul 16, 2008 1:23 am
by cyrfer
Hi,
The goal:
Have a function that provides the uniform index when the uniform name is known, much like glGetUniformLocation, so that GpuProgramParameters::setConstant can be used.

I'm not even sure yet that it is possible to use GpuProgramParameters::setConstant, unless you are comfortable when blindly guessing the value to pass for the "index" parameter. I think Ogre should have an easy to use function, maybe called 'GpuProgramParameters::getUniformLocationFromName' so that you will be able to figure out which value should be passed to GpuProgramParameters::setConstant. I've been trying to implement something like this for the past day, but if someone knows already, the solution would be much appreciated.

Thanks.

Posted: Wed Jul 16, 2008 2:48 am
by Praetor
You mean setting a shader constant by name, like the setNamedConstant function? I think that'll do what you want.

Posted: Wed Jul 16, 2008 5:26 pm
by nullsquared
Praetor wrote:You mean setting a shader constant by name, like the setNamedConstant function? I think that'll do what you want.
Check out this thread here: http://www.ogre3d.org/phpBB2/viewtopic.php?p=295259

Posted: Wed Jul 16, 2008 6:18 pm
by Praetor
Ok, I'm trying to understand the request, and I haven't yet "gotten" it. The other thread only helped a little. Let me try to work it out.

You have a high level shader, which uses named constants. Named constants are mapped to indices, which normally you look up and then use that looked up index to set it. You want to store and use directly that index each time you set the constant, instead of using the name?

I may have completely misread your intent, in fact it's likely.

Posted: Wed Jul 16, 2008 6:57 pm
by nullsquared
Praetor wrote:You have a high level shader, which uses named constants. Named constants are mapped to indices, which normally you look up and then use that looked up index to set it. You want to store and use directly that index each time you set the constant, instead of using the name?
According to his previous thread, that's what he wants, AFAICU.

Posted: Wed Jul 16, 2008 11:13 pm
by cyrfer
Praetor wrote:You have a high level shader, which uses named constants. Named constants are mapped to indices, which normally you look up and then use that looked up index to set it. You want to store and use directly that index each time you set the constant, instead of using the name?
That is precisely correct. Please, just read the link about glGetUniformLocation.

Thank you.