使用GPUImage在OpenGL ES渲染布尔返回类型函数 [英] function with bool return type in OpenGL ES shader using GPUImage

查看:396
本文介绍了使用GPUImage在OpenGL ES渲染布尔返回类型函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用iOS的项目,使用GPUImage框架。我不能让我的着色遵守。

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

界外球(VEC2 P)

所有(每种不超过(boundMin,P))及和放大器;所有(每种不超过(P,boundMax))

它的工作原理太棒了!

问题:

时的OpenGL ES 2.0的片段着色器支持布尔函数?如果是这样,在哪里我会错呢?如果不是,为什么是功能,如所有()每种不超过()

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.

环境:iPad的迷你型,搭载iOS 7,OpenGL ES 2.0的,X code 5.0.2

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

推荐答案

我终于弄明白!

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

GPUImage uses SHADER_STRING() to parse shaders.

当我写布尔中,LLVM的Objective-C编译器不知道这PICE code将被转换为字符串着色器。当编译器看到布尔将取代布尔 _Bool ,因为在Objective-C 布尔定义为 _Bool

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!

这篇关于使用GPUImage在OpenGL ES渲染布尔返回类型函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆