【发布时间】:2015-11-08 01:40:29
【问题描述】:
根据this document APPLE_clip_distance 扩展存在于OpenGL ES 3.0 和iPhone 6+ 硬件上。我试图通过首先在代码中启用它然后在着色器中使用来使用它。
我可以通过做查询最大裁剪平面数
GLint i;
glGetIntegerv(GL_MAX_CLIP_DISTANCES_APPLE, &i);
printf("i: %d\n", i);
这会打印出 8。
当尝试像这样在着色器中使用它时:
const mediump int gl_MaxClipDistances = 8;
out highp float gl_ClipDistance[gl_MaxClipDistances];
我收到以下错误:
ERROR: 0:24: Identifier name 'gl_MaxClipDistances' cannot start with 'gl_'
ERROR: 0:25: Use of undeclared identifier 'gl_MaxClipDistances'
ERROR: 0:33: Use of undeclared identifier 'gl_ClipDistance'
This document 描述了扩展,据我了解,由于我使用的是 ES 3.0,我应该重新声明剪辑距离数组:
(1) GLSL 300 doesn't support unsized arrays, how should gl_ClipDistance
be sized?
RESOLVED: For maximal compatibility, it works like ES2/desktop,
remaining unsized until sized by direct access or explicitly
redeclared. Language describing this behavior must be added to the
extension specification since it's gone from the base language
specification.
也这样声明:
out highp float gl_ClipDistance[];
给出这个错误:
ERROR: 0:25: Unsized array 'gl_ClipDistance' requires sized initializer under GLSL 300
ERROR: 0:33: Use of undeclared identifier 'gl_ClipDistance'
有人有这个扩展的工作示例吗?
【问题讨论】: