Search code examples
copenglglslshader

Why GL_VERSION differs from GL_SHADING_LANGUAGE_VERSION and what to do


when running

printf("%s\n", glGetString(GL_VERSION));
printf("%s\n", glGetString(GL_SHADING_LANGUAGE_VERSION));

on my computer it prints out:

3.1 Mesa 19.2.8

1.40

But when trying to access features from 3.1 in a shader I get the following error message:

Supported versions are: 1.10, 1.20, 1.30, 1.40, 1.00 ES, and 3.00 ES

What confuses me:

  1. The GL_SHADING_LANGUAGE_VERSION doesn't support many features GL_VERSION supports. Whats the reason for this? Is there any possibility that I can use 3.1 features in my shader?

  2. According to the error message of my shader my computer supports 3.00 ES which differs from GL_SHADING_LANGUAGE_VERSION. Why is this the case?


Solution

  • The GLSL Version 1.40 corresponds to OpenGL 3.1. See the GLSL tag info.

    OpenGL specification - Khronos OpenGL registry

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

    OpenGL ES Specification - Khronos OpenGL ES Registry

    | GLSL ES | OpenGL ES |                 |
    |---------|-----------|-----------------|
    | 1.00    | ES 2.0    | #version 100 es |
    | 3.00    | ES 3.0    | #version 300 es |
    | 3.10    | ES 3.1    | #version 310 es |
    | 3.20    | ES 3.2    | #version 320 es |