开发者

compiler error on vec4 kernel routine

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);
}


You're missing a framework import. The error is that the compiler doesn't know what kernel means (it's expecting you to assign it a value or otherwise declare it).

Try following these steps:

  1. Choose Project > Add to Project.
  2. Navigate to System/Library/Frameworks, choose the QuartzCore.framework and click Add.
  3. In the sheet that appears, click Add.

And then you may need to additionally #import <QuartzCore/QuartzCore.h> in all the files you wish to use Core Image.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜