有人知道如何在 Samsung Galaxy S2 的 fragment 着色器中执行 switch
case
语法吗?我收到编译错误:Expected literal or '(', got 'switch'
。
我的语法如下:
switch(i){
case 0: x = alphas[0]; break;
case 1: //...etc.
}
这在 Nexus 7 上运行良好,但在 Galaxy S2 上出现上述错误。 switch
case
指令在 Galaxy S2 上根本不可能吗?我想使用它们的原因是它们似乎比 Nexus 7 上的 if
else
有性能改进。如果它们在 Galaxy S2 上不可能,是否有查询设备的方法并使用 switch
case
(如果可用)和 if
else
否则?
最佳答案
switch
语句在 OpenGL ES 2.0 中不受支持。
来自OpenGL ES Shading Language 1.0.17规范 3.7:
The following are the keywords reserved for future use. Using them will result in an error:
asm class union enum typedef template this packed goto switch default ...
关于安卓 OpenGL ES 2.0 : Is "switch-case" syntax possible in GLSL fragment shader on Samsung Galaxy S2?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16002378/