Version numbers for OpenGL, OpenGL ES, and GLSL

satya - Thu Aug 30 2012 09:59:43 GMT-0400 (Eastern Daylight Time)

Version numbers for OpenGL, OpenGL ES, and GLSL

Version numbers for OpenGL, OpenGL ES, and GLSL

Search for: Version numbers for OpenGL, OpenGL ES, and GLSL

satya - Thu Aug 30 2012 10:02:46 GMT-0400 (Eastern Daylight Time)

OpenGL versions listed in Wiki

OpenGL versions listed in Wiki

They range from 1.x to 4.x

satya - Thu Aug 30 2012 10:03:01 GMT-0400 (Eastern Daylight Time)

Shading language was introduced in OpenGL 2.0

Shading language was introduced in OpenGL 2.0

satya - Thu Aug 30 2012 10:03:18 GMT-0400 (Eastern Daylight Time)

OpenGL ES 2.0 is based on OpenGL 2.0

OpenGL ES 2.0 is based on OpenGL 2.0

satya - Thu Aug 30 2012 10:03:53 GMT-0400 (Eastern Daylight Time)

Khronos home page: khronos.org

Khronos home page: khronos.org

satya - Thu Aug 30 2012 10:05:07 GMT-0400 (Eastern Daylight Time)

The GLSL version for OpenGL ES 2.0 is 1.00 and specified as


#version 100

if specified must be at the top of the file before anything else.

satya - Thu Aug 30 2012 10:06:21 GMT-0400 (Eastern Daylight Time)

gles specs page

gles specs page

satya - Thu Aug 30 2012 10:10:32 GMT-0400 (Eastern Daylight Time)

The GLSL ES version 1.00 specs: PDF file

The GLSL ES version 1.00 specs: PDF file

This might be useful as the language continues to evolve, especially on the OpenGL side and the books you may read may have key words that are not in this version of ES.

satya - Thu Aug 30 2012 10:12:05 GMT-0400 (Eastern Daylight Time)

The GLSL for OpenGL ES and OpenGL could be different?

One might be based on the other but there could be differences!!! Keep that in mind. For example the GLSL ES 1.00 is based on GLSL 1.2.x but not an exact copy!!

satya - Thu Aug 30 2012 10:13:48 GMT-0400 (Eastern Daylight Time)

Key words of GLSL ES v 1.00


attribute   const   uniform   varying
    break   continue   do   for   while 
    if    else
    in   out   inout
    float   int   void   bool  true  false
    lowp   mediump   highp   precision   invariant
    discard   return
    mat2  mat3  mat4
    vec2   vec3  vec4    ivec2   ivec3   ivec4    bvec2   bvec3   bvec4
    sampler2D    samplerCube   
    struct

satya - Thu Aug 30 2012 10:14:22 GMT-0400 (Eastern Daylight Time)

Future use


asm
    class    union    enum    typedef    template   this   packed  
    goto    switch    default
    inline    noinline    volatile    public    static    extern    external    interface  flat
    long    short    double    half    fixed    unsigned    superp
    input    output
    hvec2    hvec3    hvec4    dvec2    dvec3    dvec4    fvec2    fvec3    fvec4
    sampler1D sampler3D
    sampler1DShadow   sampler2DShadow
    sampler2DRect    sampler3DRect    sampler2DRectShadow
    sizeof    cast
    namespace    using

satya - Thu Aug 30 2012 10:17:43 GMT-0400 (Eastern Daylight Time)

Very nice explanation from the spec

Each compilation unit should declare the version of the language it is written to using the #version

directive:
#version number

where number must be 100 for this specification?s version of the language (following the same convention as __VERSION__ above), in which case the directive will be accepted with no errors or warnings.

Any number less than 100 will cause an error to be generated. Any number greater than the latest version of the language a compiler supports will also cause an error to be generated.

Version 100 of the language does not require compilation units to include this directive, and compilation units that do not include a #version directive will be treated as targeting version 100.

The #version directive must occur in a compilation unit before anything else, except for comments and white space.

satya - Thu Aug 30 2012 10:26:22 GMT-0400 (Eastern Daylight Time)

Here is the GLSL ES 3.00 spec: PDF

Here is the GLSL ES 3.00 spec: PDF

satya - Thu Aug 30 2012 10:27:03 GMT-0400 (Eastern Daylight Time)

Curiously 'varying' and 'attribute' are deprecated in 3.0

Curiously 'varying' and 'attribute' are deprecated

satya - Thu Aug 30 2012 11:23:54 GMT-0400 (Eastern Daylight Time)

'in' replaces 'attribute' in 3.0

Vertex shader input variables (or attributes) receive per-vertex data. They are declared in a vertex shader with the in qualifier . It is an error to use centroid in or interpolation qualifiers in a vertex shader input. The values copied in are established by the OpenGL ES API or through the use of the layout identifier location.

Vertex shader inputs can only be float, floating-point vectors, matrices, signed and unsigned integers and integer vectors. Vertex shader inputs cannot be arrays or structures. 354 Variables and Types

Example declarations in a vertex shader:

in vec4 position;
in vec3 normal;

satya - Thu Aug 30 2012 11:25:36 GMT-0400 (Eastern Daylight Time)

Similarly 'out' replaces the 'varying' in 3.0

Vertex output variables output per-vertex data and are declared using the out storage qualifier or the centroid out storage qualifier. They can only be float, floating-point vectors, matrices, signed or unsigned integers or integer vectors, or arrays or structures of any these. Vertex shader outputs that are, or contain, signed or unsigned integers or integer vectors must be qualified with the interpolation qualifier flat.

Individual vertex outputs are declared as in the following examples:

out vec3 normal;
centroid out vec2 TexCoord;
invariant centroid out vec4 Color;
flat out vec3 myColor;

satya - Thu Aug 30 2012 11:26:29 GMT-0400 (Eastern Daylight Time)

Bottom line, refer to the spec and see which version of GLSL you are using for your shader programs.

Bottom line, refer to the spec and see which version of GLSL you are using for your shader programs.

satya - Thu Aug 30 2012 12:47:37 GMT-0400 (Eastern Daylight Time)

GLSL and GLSL ES versions


GLSL ES 1.00 (meant for ES 2.0) is derived from GLSL 1.2 (OpenGL 2.1)
GLSL ES 3.00 (meant for ES 3.0) is derived from GLSL 3.3 Revision 7 (OpenGL 3.3)

satya - Thu Aug 30 2012 13:47:00 GMT-0400 (Eastern Daylight Time)

Specifying the version number for OpenGL ES 2.0


#version 100

Although version is 1.00, the way you specify it is as a complete integer. Even if your version number is 1.0.3, it appears you still need to specify it as 100 (May be I am reading the spec wrong!! But I feel I am not!)