GLSL VERSION Macro Values by Specification

This article provides a comprehensive reference for the integer values produced by the preprocessor macro __VERSION__ across various OpenGL Shading Language (GLSL) and OpenGL ES Shading Language (GLSL ES) specifications. In GLSL, __VERSION__ expands to a three-digit decimal integer corresponding to the version of the shading language supported by the compiler, allowing developers to write version-specific conditional logic directly within their shader source code.

How __VERSION__ Expands

The __VERSION__ macro represents the specification version as a decimal integer, typically derived by multiplying the version number by 100 (formatted as Major * 100 + Minor * 10). For example, GLSL version 4.60 expands to the integer 460.

This macro is automatically defined by the GLSL preprocessor and matches the version specified in the #version directive at the beginning of the shader file. If no #version directive is present, the compiler defaults to version 1.10 (110) for desktop OpenGL or version 1.00 (100) for OpenGL ES.

Desktop GLSL Specifications

Below are the standard desktop OpenGL Shading Language releases and their corresponding integer values:

GLSL Version Corresponding OpenGL Version __VERSION__ Value
GLSL 1.10 OpenGL 2.0 110
GLSL 1.20 OpenGL 2.1 120
GLSL 1.30 OpenGL 3.0 130
GLSL 1.40 OpenGL 3.1 140
GLSL 1.50 OpenGL 3.2 150
GLSL 3.30 OpenGL 3.3 330
GLSL 4.00 OpenGL 4.0 400
GLSL 4.10 OpenGL 4.1 410
GLSL 4.20 OpenGL 4.2 420
GLSL 4.30 OpenGL 4.3 430
GLSL 4.40 OpenGL 4.4 440
GLSL 4.50 OpenGL 4.5 450
GLSL 4.60 OpenGL 4.6 460

Note: Starting with OpenGL 3.3, the Khronos Group aligned the GLSL version numbering directly with the OpenGL core API version to avoid confusion.

OpenGL ES Shading Language (GLSL ES) Specifications

OpenGL ES uses a distinct numbering scheme designated with the es profile qualifier in modern versions:

GLSL ES Version Corresponding OpenGL ES Version __VERSION__ Value
GLSL ES 1.00 OpenGL ES 2.0 100
GLSL ES 3.00 OpenGL ES 3.0 300
GLSL ES 3.10 OpenGL ES 3.1 310
GLSL ES 3.20 OpenGL ES 3.2 320

Practical Preprocessor Usage

Developers use __VERSION__ inside preprocessor directives to branch compilation depending on the underlying hardware driver's supported features or declared shader version:

#if __VERSION__ >= 330
    // Modern syntax (GLSL 3.30+)
    layout(location = 0) in vec3 inPosition;
    layout(location = 0) out vec4 outColor;
#else
    // Legacy syntax (GLSL 1.20 / 1.30)
    attribute vec3 inPosition;
#endif

To differentiate between Desktop GLSL and GLSL ES when integer values might overlap (e.g., distinguishing between desktop version 3.0-era syntax and mobile profiles), check the GL_ES built-in macro alongside __VERSION__:

#if defined(GL_ES)
    // Code specific to OpenGL ES (e.g., setting precision qualifiers)
    precision mediump float;
#endif