I have this vague recollection that there's some kind of genericity/abstract type feature in GLSL that gets you something similar to template functions in C++, but I can't find it. Does it exist?
That is, something which avoids you having to do this:
Code :#define FOO_TEMPLATE(TTYPE) \ TTYPE foo( TTYPE tc, TTYPE N, TTYPE M ) \ { \ return tc * (M-1)/N + 0.5/N ; \ } FOO_TEMPLATE(float) FOO_TEMPLATE(vec2) FOO_TEMPLATE(vec3) FOO_TEMPLATE(vec4)
Please ignore the fact that in this simple case I could just make this a macro to get around the problem:
Code :#define FOO(tc,N,M) ((tc) * ((M)-1)/(N) + 0.5/(N))



