[of-dev] ofShader

Kyle McDonald kyle at kylemcdonald.net
Sat Apr 23 09:11:53 PDT 2011


agree w both of you, and want to reiterate what memo said: i'm a huge fan of
overloading, but changed it back to i/f after too many accidents where it
silently failed. that said, setUniformInt/Float totally solves all the
problems:

1 overloads for number of operators
2 doesn't silently fail between int vs float
3 doesn't look weird :)

kyle

On Sat, Apr 23, 2011 at 10:54 AM, Memo Akten <memo at memo.tv> wrote:

> I agree with both points, however regarding b.) the issue is concerning
> ints vs floats.
>
> setUniform("alpha", 1);
>
> will call the int setUniform, which will silently fail and not set the
> 'float alpha' you have in your variable (this has caused me to go crazy many
> times, also in ofxXMLSettings).
>
> so you need to do setUniform("alpha", 1.0f);
>
> how about setUniformInt(), setUniformFloat(), and they are overloaded for
> the 1,2,3,4 version? (so we don't need different names for the 1,2,3,4, just
> to separate int from float).
>
> P.S. I think ofVec2f, ofVec3f, ofVec4f version would be good too!
>
> On 23 April 2011 15:49, Zachary Lieberman <zach at eyebeam.org> wrote:
>
>>
>>
>> greetings dev list,
>>
>> some simple q's about ofShader --
>>
>> a) I would like to change "setup" to something more in line with OF
>> naming, such as "loadShader" -- we have loadMovie, loadSound, etc and it
>> seems to be good to keep that naming convention.   any objections?
>>
>> b) at the moment, the setUniforms are done in a non overloaded way:
>>
>> ie,
>> setUniform1i
>> setUniform2i
>>
>> but in the past version of ofxShader, they were done like:
>>
>> void setUniform (char * name, float v1);
>> void setUniform (char * name, float v1, float v2);
>> void setUniform (char * name, float v1, float v2, float v3);
>> void setUniform (char * name, float v1, float v2, float v3, float v4);
>>
>> I personally prefer the older way (overloaded functions) as opposed to the
>> new way -- was wondering is there a specific reason for this?
>>
>>
>> thanks,
>> zach
>>
>>
>> _______________________________________________
>> of-dev mailing list
>> of-dev at dev.openframeworks.cc
>> http://dev.openframeworks.cc/listinfo.cgi/of-dev-openframeworks.cc
>>
>>
>
>
> --
> Memo Akten
>
> www.memo.tv
> www.twitter.com/memotv
> www.msavisuals.com
>
>
>
>
>
> _______________________________________________
> of-dev mailing list
> of-dev at dev.openframeworks.cc
> http://dev.openframeworks.cc/listinfo.cgi/of-dev-openframeworks.cc
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://dev.openframeworks.cc/pipermail/of-dev-openframeworks.cc/attachments/20110423/72ffacec/attachment-0003.htm>


More information about the of-dev mailing list