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

OpenGL versions listed in Wiki

They range from 1.x to 4.x

Shading language was introduced in OpenGL 2.0

OpenGL ES 2.0 is based on OpenGL 2.0

Khronos home page: khronos.org


#version 100

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

gles specs page

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.

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!!


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

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

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.

Here is the GLSL ES 3.00 spec: PDF

Curiously 'varying' and 'attribute' are deprecated

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;

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;

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


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)

#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!)