Skip to content
Advertisement

How to fix compatibility issues between GLSL version 1.5 and version 3.0 ES

I’ve recently come back to working on an old passion project of mine (I last worked on this 2 years ago for the last time) which uses GLSL shaders. The project uses a whole bunch of shader files like this:

#version 150

in vec3 color;

out vec4 out_Color;

void main(void){

    out_Color = vec4(color,1.0);

}

I get the following error when running the program using this file:

error: GLSL 1.50 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.00 ES, and 3.00 ES

I’m assuming that in the last 2 years I have updated some of the drivers of my PC and GLSL version 1.5 is no longer supported on my PC. I’ve tried using any of the other versions by using the following headers, each giving different errors reported here in order of supported versions given above:

#version 110:

0:3(1): error: `in' qualifier in declaration of `color' only valid for function parameters in GLSL 1.10
0:5(1): error: `out' qualifier in declaration of `out_Color' only valid for function parameters in GLSL 1.10

#version 120:

0:3(1): error: `in' qualifier in declaration of `color' only valid for function parameters in GLSL 1.20
0:5(1): error: `out' qualifier in declaration of `out_Color' only valid for function parameters in GLSL 1.20

#version 130:

0:1(1): error: `in' qualifier in declaration of `position' only valid for function parameters in GLSL 1.10
0:2(1): error: `in' qualifier in declaration of `textureCoordinates' only valid for function parameters in GLSL 1.10
0:4(1): error: `out' qualifier in declaration of `passTextureCoordinates' only valid for function parameters in GLSL 1.10

#version 100:

0:3(1): error: `in' qualifier in declaration of `color' only valid for function parameters in GLSL ES 1.00
0:3(1): error: No precision specified in this scope for type `vec3'
0:5(1): error: `out' qualifier in declaration of `out_Color' only valid for function parameters in GLSL ES 1.00
0:5(1): error: No precision specified in this scope for type `vec4'

#version 300 es:

0:3(1): error: No precision specified in this scope for type `vec3'
0:5(1): error: No precision specified in this scope for type `vec4'

So now, assuming just reverting to version 1.5 is not possible anymore or not the right solution here, I need to convert my shader files to one of the versions above and fix the errors. So here is my question: Is this the right approach? Do I really need to change GLSL version and, in that case, which version would be the best to use? Do I need to also change the java code or will changing the version of GLSL not have any effect on my java LWJGL code?

I’m sorry if this is a bit of a beginner question and I’m completely wrong here, as I mentioned I just got back into this project.

Here is some info about my current installation:

glxinfo | grep OpenGL
OpenGL vendor string: Intel Open Source Technology Center
OpenGL renderer string: Mesa DRI Intel(R) Ivybridge Mobile 
OpenGL core profile version string: 3.3 (Core Profile) Mesa 13.0.6
OpenGL core profile shading language version string: 3.30
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 3.0 Mesa 13.0.6
OpenGL shading language version string: 1.30
OpenGL context flags: (none)
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 3.0 Mesa 13.0.6
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.00
OpenGL ES profile extensions:

I’m working on debian:

Distributor ID: Debian
Description:    Debian GNU/Linux 9.13 (stretch)
Release:    9.13
Codename:   stretch

I added the following code to find out the versions of LWJGL & OpenGL used for the project:

System.out.println("[DEBUG]: OS name " + System.getProperty("os.name"));
System.out.println("[DEBUG]: OS version " + System.getProperty("os.version"));
System.out.println("[DEBUG]: LWJGL version " + org.lwjgl.Sys.getVersion());
System.out.println("[DEBUG]: OpenGL version " + glGetString(GL_VERSION));

The output of that was:

[DEBUG]: OS name Linux
[DEBUG]: OS version 4.9.0-4-amd64
[DEBUG]: LWJGL version 3.0.0a
[DEBUG]: OpenGL version 3.0 Mesa 13.0.6

Advertisement

Answer

Your GPU supports either up to OpenGL 3.0 in a Compatibility profile, or OpenGL 3.3 in a Core Profile. The requested version 150 (OpenGL 3.2) is not supported.

Your shader seems to be compatible with OpenGL 3.3 Core Profile, so I recommend to use the following settings:

GLFW.glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
GLFW.glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
GLFW.glfwWindowHint(GLFW.GLFW_OPENGL_PROFILE, GLFW.GLFW_OPENGL_CORE_PROFILE);

Note, that these window hints have to be set before calling glCreateWindow.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement