I am trying to include the following kernel routine into my Cocoa / objective C project. But I'm getting a compiler error when I build the project. The very first line is flagged with a syntax error saying "expected '=', ',', ';', 'asm' or 'attribute' before 'vec4'.
Any ideas what this means and how to resolve it? As far as I can tell, the declaration looks pretty much just like all the other kernel samples I can find.
kernel vec4 threshold(sampler image, float midPoint, float range ) // First error on this line
//This from http://www.codingadventures.com/2008/06/threshold-filter-in-glsl/
{
vec4 pixel=unpremultiply( sample(image, samplerCoord(image)) );
float high = midPoint + range * 0.5;
float low = midPoint - range * 0.5;
high = min(1.0, high);
low = max(0.0, low);
float brightness = 0.3 * pixel.x + 0.59 * pixel.y+ 0.11 *pixel.z;
brightness = step( low, brightness ) * brightness;
brightness = brightness + step( high, brightness );
brightness = min( 1.0, brightness );
pixel.x = pixel.y =pixel.z = brightness;
return premultiply(pixel);
}