I have a problem when compiling a simple vertex shader in OpenGL, I get the following error messages:
error(#106) Version number not supported by GL2
error(#279) Invalid layout qualifier 'location'
I assume that I must be using the wrong version of GL2, but I have no idea how to find my version number or where to go for an upgrade (and yes I tried to search for an answer.) Attached is a copy of my shader code just for reference and my openGL information.
#version 330 core
layout(location = 0) in vec3 Position;
void main() {
gl_Position.xyz = Position;
}
Vendor: ATI Technologies Inc.
Renderer: ATI Radeon HD 5700 Series
Version: 3.2.9756 Compatibility Profile Context
#version 330 core
This says that your shader uses GLSL version 3.30.
This:
Version: 3.2.9756 Compatibility Profile Context
Means that your OpenGL version is 3.2. The GLSL version that corresponds with OpenGL 3.2 is 1.50. Which is less than 3.30. Hence the lack of compilation.
Update your drivers; those are extremely old. Your card should be able to support GL 4.2.
Related
I create context by:
new sf::Window(sf::VideoMode(800, 600), "OpenGL",
sf::Style::Default,
sf::ContextSettings(24, 8, 0, 3, 3, sf::ContextSettings::Core)));
I'm loading extensions by glLoadGen for OpenGL 3.3 Core Profile with one extension EXT_texture_compression_s3tc. When I'm compiling shader:
#version 330 core
layout (location = 0) in vec3 vertPos;
layout (location = 5) uniform mat4 modelMat;
layout (location = 6) uniform mat4 viewMat;
layout (location = 7) uniform mat4 projectionMat;
out vec4 fragColor;
void main()
{
gl_Position = projectionMat * viewMat * modelMat * vec4(vertPos, 1.0);
fragColor = vec4(0.5, 0.5, 0.5, 1.0);
}
``
#version 330 core
in vec4 fragColor;
out vec4 outColor;
void main()
{
outColor = fragColor;
}
I get error string:
ERROR: Shader compilation error at shader: "media/shaders/shader.vs.glsl"
0:7(1): error: uniform explicit location requires GL_ARB_explicit_uniform_location and either GL_ARB_explicit_attrib_location or GLSL 3.30.
0:8(1): error: uniform explicit location requires GL_ARB_explicit_uniform_location and either GL_ARB_explicit_attrib_location or GLSL 3.30.
0:9(1): error: uniform explicit location requires GL_ARB_explicit_uniform_location and either GL_ARB_explicit_attrib_location or GLSL 3.30.
but I have OpenGL 3.3 (so GLSL 3.30).
glxinfo prints:
Extended renderer info (GLX_MESA_query_renderer):
Vendor: X.Org (0x1002)
Device: AMD JUNIPER (DRM 2.43.0, LLVM 3.8.0) (0x68be)
Version: 11.2.0
Accelerated: yes
Video memory: 512MB
Unified memory: no
Preferred profile: core (0x1)
Max core profile version: 3.3
Max compat profile version: 3.0
Max GLES1 profile version: 1.1
Max GLES[23] profile version: 3.0
OpenGL vendor string: X.Org
OpenGL renderer string: Gallium 0.4 on AMD JUNIPER (DRM 2.43.0, LLVM 3.8.0)
OpenGL core profile version string: 3.3 (Core Profile) Mesa 11.2.0
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:
So I should be able use GLSL 3.30.
The ability to specify uniform locations in a shader is not part of OpenGL version 3.3 or GLSL version 3.30. It's only a core feature of GL 4.3 or GLSL 4.30. The ability to specify vertex shader input and fragment shader output locations is 3.30, but uniform locations are not.
Explicit uniform location specification doesn't actually require special hardware; it's purely an interface thing. As such, pre-4.x hardware could implement it. However, if your hardware is limited to GL 3.3, then there's a very good chance that the hardware is so old that it stopped being updated by the IHV with new OpenGL features. So even though it could support it, the feature appeared after the IHV stopped updating the hardware.
While NVIDIA has kept some of their 3.3-only hardware up-to-date on recent, non-hardware features, the same cannot be said for Intel or AMD. So even if you have an NVIDIA 3.x GPU that this works on, it's likely that Intel or AMD's 3.x GPUs won't work.
In your case, "Juniper" refers to the Radeon 67xx line. These are GL 4.x parts. However, you're using the open source driver rather than AMD's actual Linux driver, so you're only able to get 3.3 from it.
It would be better to bump your required OpenGL version to match your shader. However, if you wish to keep it as a 3.30 shader and use it as an extension (since you're using the open source driver instead of AMD's driver), you will need an extension declaration below the #version declaration:
#extension GL_ARB_explicit_uniform_location : require
You could try adding the following line that enables the extension below #version 330 core:
#extension GL_ARB_explicit_uniform_location : require
I just want to make an OpenGL program using GLSL shader. But when I'm compiling it I have the following error message :
Version number not supported by GL2.
Here's my vertex shader code :
#version 400
in vec3 Color;
out vec4 FragColor;
void main() {
FragColor = vec4(Color, 1.0);
}
My device config is the following :
GL render : ATI Radeo HD 4600 Series
GL version : 2.1.8787
GLSL version : 1.30
So I need opengl version 4.3 if it's possible. But I downloaded lots of versions but I didn't find the last one. Plus, I should have GLSL version 4. Does anyone know a link to download the last version of OpenGL?
As Nicol Bolas indicated, this is most likely due to generic or outdated drivers.
Does anyone know a link to download the last version of OpenGL?
OpenGL is not an traditional API with a centralized implementation but rather it is a specification of a feature set that multiple vendors (NVIDIA,AMD, etc..) implement. This allows specific vendors to utilize unique features of their graphics hardware while still providing programmers with a consistent, hardware independent API.
AMD's complete driver catalog can be queried here.
GL render : ATI Radeo HD 4600 Series
The HD 4xxx series of graphics cards doesn't support OpenGL 4.x at all. They're limited to OpenGL 3.x. So download the latest available drivers (sadly, AMD stopped making new drivers for this card last year, so you'll be stuck with the 12.6's), and switch to version 3.30.
I tried to run a simple OpenGL 3 app with the following vertex shader program:-
in vec4 vPosition;
out vec2 otexcoord;
uniform mat4 modelview;
uniform mat4 projection;
void main()
{
gl_Position = projection * modelview * vPosition;
otexcoord.s = vPosition.x;
otexcoord.t = vPosition.y * -1.0;
};
I've run this code on 3 GPUs, from different company, and the results are different.
With Intel's driver, there's no error and it runs perfectly.
With Nvidia's driver, the error is 'out can't be used with non-varying otexcoord'.
With AMD's driver, the error is 'Implicit version number 110 not supported by GL3 forward compatible context'
The AMD's one seems to be the least obvious. In fact I don't have any idea about it.
Below is some query string
Intel: OpenGL 3.2.0 - Build 9.17.10.2932 GLSL 1.50 - Build 9.17.10.2932
Nvidia: OpenGL 3.2.0 GLSL 1.50 NVIDIA via Cg compiler
AMD: OpenGL 3.2.12002 Core Profile Context 9.12.0.0 GLSL 4.20
Intel's and Nvidia's are similar, it's a GLSL 1.50 compiler. The AMD's is GLSL 4.20
Below is the question:-
Between Intel's and Nvidia's compilers, which one is working correctly in this case?
What does the error message from AMD's compiler really mean ? And what do I need to correct the error.
You must always use a #version directive. If you do not, then the compiler will assume you mean GLSL version 1.10. Which means that out is not a valid keyword.
I have a problem when compiling a simple vertex shader in OpenGL, I get the following error messages:
error(#106) Version number not supported by GL2
error(#279) Invalid layout qualifier 'location'
I assume that I must be using the wrong version of GL2, but I have no idea how to find my version number or where to go for an upgrade (and yes I tried to search for an answer.) Attached is a copy of my shader code just for reference and my openGL information.
#version 330 core
layout(location = 0) in vec3 Position;
void main() {
gl_Position.xyz = Position;
}
Vendor: ATI Technologies Inc.
Renderer: ATI Radeon HD 5700 Series
Version: 3.2.9756 Compatibility Profile Context
#version 330 core
This says that your shader uses GLSL version 3.30.
This:
Version: 3.2.9756 Compatibility Profile Context
Means that your OpenGL version is 3.2. The GLSL version that corresponds with OpenGL 3.2 is 1.50. Which is less than 3.30. Hence the lack of compilation.
Update your drivers; those are extremely old. Your card should be able to support GL 4.2.
I am trying to get UBOs working, however I get a compilation error in the fragment shader:
ERROR 0:5:"(": synrax error.
Fragment Shader:
layout(std140) uniform Colors
{
vec3 SCol;
vec3 WCol;
float DCool;
float DWarm;
}colors;
Where am I going wrong?
At the begining of your fragment shader source file (the very first line) put this:
#version 140
This means that you are telling the GLSL compiler that you use the version 1.40 of the shading language (you can, of course, use a higher version - see Wikipedia for details).
Alternatively, if your OpenGL driver (and/or hardware) doesn't support GLSL 1.40 fully (which is part of OpenGL 3.1), but only GLSL 1.30 (OpenGL 3.0), you can try the following:
#version 130
#extension GL_ARB_uniform_buffer_object : require
However, this one will work only if your OpenGL 3.0 driver supports the GL_ARB_uniform_buffer_object extension.
Hope this helps.