我可以在 OpenGL ES 2.0 中使用哪些版本的 GLSL?
尽管进行了数小时的谷歌搜索,我似乎无法找到明确的答案。有人可以告诉我发生了什么事吗?我收到诸如“不支持版本 140”之类的错误消息。这是我的设备 (Kindle Fire) 还是 GL ES 2.0?我需要添加库或其他东西吗?
I can't seem to find a clear answer on this, despite hours of googling. Can someone just tell me what's going on? I get errors saying things like, "version 140 is not supported." Is this my device (Kindle Fire) or GL ES 2.0? Do I need to add libraries or anything?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
OpenGL ES 2.0 规范指< a href="https://www.khronos.org/registry/OpenGL/specs/es/2.0/GLSL_ES_Specification_1.00.pdf" rel="nofollow noreferrer">GLSL ES,与 GLSL 不同。
GLSL ES 规范说:
查看规范以了解支持的内容。
The OpenGL ES 2.0 spec refers to GLSL ES, which is not the same as GLSL.
The spec GLSL ES spec says:
Check out the spec to see what's supported.
OpenGL ES 不是 OpenGL,因此同样 OpenGL ES 的着色器语言也不是 OpenGL 的着色器语言。它们相似,但并不相同。因此没有与 GLSL ES 版本匹配的桌面 GLSL 版本。
OpenGL ES is not OpenGL, so similarly OpenGL ES's shader language is not OpenGL's shader language. They are similar, but they are not the same. So there is no desktop GLSL version that matches with GLSL ES's version.
实际上,您不必添加任何库,140 对于 Kindle Fire 来说太新了。删除版本规范或递减它直到着色器编译。您可能需要修复着色器中的一些其他错误,因为语言的各个版本确实存在一些差异。
您还可以使用
glGetString()
查询GL_SHADING_LANGUAGE_VERSION
以获取您的设备支持的 GLSL 版本(保证至少 100 - ES 2.0 是第一个具有着色语言)。另外,正如其他人提到的,OpenGL ES GLSL 与 OpenGL ES 不是同一语言(我认为这是相当明显的,OpenGL ES 不是 OpenGL),因此版本号不匹配。然而,有 GL_ARB_ES2_compatibility 及其对 ES3、ES3.1 和 ES3 的扩展.2,其中描述了 ES/非 ES GLSL 语言的映射,并且使用这些语言可以在非 ES 上下文上获得类似 ES 的功能。
you actually don't have to add any libraries, 140 is far too new for Kindle Fire. Either remove the version specification or decrement it until the shader compiles. You may need to fix some other errors in the shader as the individual versions of the language do have some differences.
You can also query
GL_SHADING_LANGUAGE_VERSION
usingglGetString()
to get version of GLSL that is supported on your device (guaranteed to be 100 at least - ES 2.0 is the first one with a shading language).Also, as mentioned by the others, OpenGL ES GLSL is not the same language as OpenGL ES (I thought that was rather obvious, OpenGL ES is not OpenGL) so the version numbers will not match. There is however GL_ARB_ES2_compatibility and its extensions to ES3, ES3.1 and ES3.2, where the mapping of the ES / non-ES GLSL languages is described, and using those it is possible to get ES-like functionality on an non-ES context.
首先你需要明确:
如果你的系统使用OpenGL ES 2.0,那么你必须使用GLSL ES 1.0(着色器预处理器:#version 100)
这里很棘手,如果你使用#version 110或#version 120,那么机器会理解你想使用GLSL,而不是GLSL ES。下表来自维基百科将帮助您清楚
在 OpenGL 3.3 之前,两者的版本命名都很混乱,但是从 OpenGL 3.3 开始,命名开始变得干净
First of all you need to be clear:
If your system is using OpenGL ES 2.0, then you have to use GLSL ES 1.0 (Shader Preprocessor: #version 100)
It's tricky here that if you use #version 110 or #version 120, then the machine will understand that you want to use GLSL, not GLSL ES. Following table from Wikipedia will help you to be clear
Before OpenGL 3.3, the version naming was messy for both of them, but from OpenGL 3.3, the naming started to be clean