Question

I'm working on an iOS project, using GPUImage framework. I cannot get my shader complied.


There's a function in my fragment shader:

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

Shader compile log:

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

When I replace all the calls to function

inBounds(vec2 p)

with

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

it works great!


Questions:

Is bool function supported in OpenGL ES 2.0 Fragment Shader? If so, where did I go wrong? If not, why there're functions like all(), lessThan(), etc.

Environment: iPad mini, iOS 7, OpenGL ES 2.0, Xcode 5.0.2

Was it helpful?

Solution

I finally figure it out!

GPUImage uses SHADER_STRING() to parse shaders.

When I write bool, the LLVM Objective-C compiler did not know this pice of code will be converted to shader string. When the compiler sees bool it will replace bool with _Bool, because in Objective-C bool is defined to be _Bool!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top