What versions of GLSL can I use in OpenGL ES 2.0?
Asked Answered
A

4

30

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?

Ardithardme answered 15/1, 2012 at 18:16 Comment(0)
S
12

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 using glGetString() 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.

Stratosphere answered 15/1, 2012 at 18:23 Comment(4)
And I thought 140 was pretty old. :(Ardithardme
Doesn't really answer the question. If something supports OpenGL ES 2.0 -- What version of GLSL does it support? (At least, at a minimum, I mean).Headcheese
@BrainSlugs83: If something supports OpenGL ES 2.0 it is guaranteed to support GLSL ES 100. There is a lot of confusion when comparing these numbers sadly, as people see the #version ... directive and immediately think that apples (desktop GLSL) are somehow comparable to oranges (embedded GLSL). They are similar in many respects, but divergent in many more (and version numbering is one area where they diverge drastically). Have a look at: opengl.org/registry/gles - if you look under the heading "OpenGL ES 2.0 Specific", that tells you the GLSL ES version associated with it.Invalid
That is a valid point, however. The question was about GLSL ES and the accepted answer does not mention the fact that the version numbers are incongruent with desktop GLSL. The takeaway point here is that there is no version 140 in GLSL ES; we have 100 in ES 2.0 and the draft specification for ES 3.0 provides 300. There have been no new language specification versions published in-between 2.0 and 3.0.Invalid
B
33

The OpenGL ES 2.0 spec refers to GLSL ES, which is not the same as GLSL.

The spec GLSL ES spec says:

This version of the language is based on version 1.10 of the desktop GLSL. However it includes a number of features that are in version 1.20 but not 1.10.

Check out the spec to see what's supported.

Barstow answered 15/1, 2012 at 18:27 Comment(4)
Apparently I'm horrible at googling. Okay.Ardithardme
It's worth adding that the OpenGL ES 2.0 spec states that it supports GLSL ES 1.0 at a minimum.Swindle
Link's dead, I think this is now correct: khronos.org/files/opengles_shading_language.pdfLeach
Updated links, thanks.Barstow
C
15

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.

Cutout answered 15/1, 2012 at 18:28 Comment(0)
S
12

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 using glGetString() 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.

Stratosphere answered 15/1, 2012 at 18:23 Comment(4)
And I thought 140 was pretty old. :(Ardithardme
Doesn't really answer the question. If something supports OpenGL ES 2.0 -- What version of GLSL does it support? (At least, at a minimum, I mean).Headcheese
@BrainSlugs83: If something supports OpenGL ES 2.0 it is guaranteed to support GLSL ES 100. There is a lot of confusion when comparing these numbers sadly, as people see the #version ... directive and immediately think that apples (desktop GLSL) are somehow comparable to oranges (embedded GLSL). They are similar in many respects, but divergent in many more (and version numbering is one area where they diverge drastically). Have a look at: opengl.org/registry/gles - if you look under the heading "OpenGL ES 2.0 Specific", that tells you the GLSL ES version associated with it.Invalid
That is a valid point, however. The question was about GLSL ES and the accepted answer does not mention the fact that the version numbers are incongruent with desktop GLSL. The takeaway point here is that there is no version 140 in GLSL ES; we have 100 in ES 2.0 and the draft specification for ES 3.0 provides 300. There have been no new language specification versions published in-between 2.0 and 3.0.Invalid
M
2

First of all you need to be clear:

  • OpenGL and GLSL are for desktop
  • OpenGL ES and GLSL ES are for Embedded System

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

OpenGL ES and WebGL use OpenGL ES Shading Language

enter image description here

Before OpenGL 3.3, the version naming was messy for both of them, but from OpenGL 3.3, the naming started to be clean

Magnesite answered 30/3, 2023 at 4:41 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.