Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ OpenGL shading version error - GLSL x is not supported [Ubuntu 16.04]

I am currently working on a project using OpenGL on Ubuntu 16.04 and have run into a major issue. At this point I have no idea what to do as it feels like I have tried everything in order to fix this.

For some reason my shader just won't compile and returns the following error:

Failed to compile vertex shader!
0:1(10): error: GLSL 4.50 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.00 ES, 3.00 ES, 3.10 ES, and 3.20 ES`

I have adjusted the version in the shader file without any luck. #version 450 core etc. but I keep getting the same result.

For reference, here is the output of sudo glxinfo | grep "OpenGL":

OpenGL vendor string: Intel Open Source Technology Center
OpenGL renderer string: Mesa DRI Intel(R) HD Graphics 520 (Skylake GT2)
OpenGL core profile version string: 4.5 (Core Profile) Mesa 13.1.0-devel
OpenGL core profile shading language version string: 4.50
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 3.0 Mesa 13.1.0-devel
OpenGL shading language version string: 1.30
OpenGL context flags: (none)
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 3.2 Mesa 13.1.0-devel
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20
OpenGL ES profile extensions:

The output from glxinfo shows OpenGL core 4.5 is installed, so why is this not supported?

I have also tried to find the current version of OpenGL used in the project: std::cout << "OpenGL version: " << glGetString(GL_VERSION) << std::endl; which results in a blank return.

I have spent 10 hours on this single issue until now, so any help is appreciated!

Edit: Is there a way to force the project/Ubuntu to use OpenGL and not GLSL by i.e. removing GLSL completely (this part)?

OpenGL ES profile version string: OpenGL ES 3.2 Mesa 13.1.0-devel
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20
OpenGL ES profile extensions:
like image 893
Nicolai Prebensen Avatar asked Nov 13 '16 10:11

Nicolai Prebensen


3 Answers

For anyone else experiencing the same issues, this was the solution that worked for me:

glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
like image 173
Nicolai Prebensen Avatar answered Nov 19 '22 21:11

Nicolai Prebensen


Seems like you're not explicitly asking for a core profile context. Your glxinfo output shows, that compatibility profile contexts (there were no "compatibility" profiles before OpenGL-3.0, but that's a moot point for this) are not supported:

This is telling you that in core profile up to v4.5 is supported:

OpenGL core profile version string: 4.5 (Core Profile) Mesa 13.1.0-devel
OpenGL core profile shading language version string: 4.50
OpenGL core profile profile mask: core profile

… and this does tell you, that the highest version that's not explicitly marked core is going to be OpenGL-3.0:

OpenGL version string: 3.0 Mesa 13.1.0-devel
OpenGL shading language version string: 1.30

So either request a core profile or accept that you're stuck to GL-3.0 and below.


Just for comparison, here's how it looks for an OpenGL implementation (NVidia) that does support OpenGL-4.x even outside a core profile:

OpenGL core profile version string: 4.4.0 NVIDIA 367.27
OpenGL core profile shading language version string: 4.40 NVIDIA via Cg compiler
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL version string: 4.5.0 NVIDIA 367.27
OpenGL shading language version string: 4.50 NVIDIA
like image 32
datenwolf Avatar answered Nov 19 '22 21:11

datenwolf


If you intend to use 4.5 capabilities you need a core profile and that is supported on your system according to this output line

OpenGL core profile version string: 4.5 (Core Profile) Mesa 13.1.0-devel

The other output line

OpenGL version string: 3.0 Mesa 13.1.0-devel

does not mean that you have two different openGL drivers but that you can afford OpenGL 3.0 tops without core profile.

In order to use the core profile capabilities make sure to enable it as well as compiling your shaders with the correct preprocessor directive

// Example using glut for context initialization
glutInitContextVersion(4, 5);
glutInitContextProfile(GLUT_CORE_PROFILE);
glutInit(&argc, argv);

// Shaders
#version 450
...
like image 1
Marco A. Avatar answered Nov 19 '22 19:11

Marco A.