使用GPUImage在OpenGL ES着色器中使用bool返回types

我正在使用GPUImage框架在iOS项目上工作。 我无法让我的着色器编译。


在我的片段着色器中有一个函数:

const vec2 boundMin = vec2(0.0, 0.0); const vec2 boundMax = vec2(1.0, 1.0); bool inBounds (vec2 p) { return all(lessThan(boundMin, p)) && all(lessThan(p, boundMax)); } 

着色器编译日志:

 ERROR: 0:1: '_Bool' : syntax error syntax error 

当我replace所有的function

inBounds(vec2 p)

all(lessThan(boundMin, p)) && all(lessThan(p, boundMax))

很好用!


问题:

OpenGL ES 2.0 Fragment Shader是否支持boolfunction? 如果是这样,我哪里错了? 如果没有,为什么有像all()lessThan()等函数

环境:iPad mini,iOS 7,OpenGL ES 2.0,Xcode 5.0.2

我终于明白了!

GPUImage使用SHADER_STRING()来分析着色器。

当我编写bool ,LLVM Objective-C编译器不知道这个代码将被转换为着色器string。 当编译器看到bool ,它将用_Boolreplacebool ,因为在Objective-C中, bool被定义为_Bool