Unknown layout specifier "binding = 1"

I am atm creating a camera with the help of GLM. Everything went well until the point I had to specify a matrix4x4 uniform in my shader.
I use layout specifiers to specify my uniforms. The big problem with this is, that it gives me an error: error C3008: unknown layout specifier ‘binding = 1’.

Does anyone know how I can fix this probem?

(Sorry I do not know how to create codeblocks, if someone can explain this too I would be really gratefull)

My vertex shader:


#version 450

layout(location=0) in vec3 position;
layout(location=1) in vec4 colour;
layout(location=2) in vec2 uv;

out vec4 fragColour;
out vec2 fragUV;

layout(binding = 1)uniform mat4 orthoMat;

void main()
{
    fragColour = colour;
    gl_Position = vec4(orthoMat * vec4(position, 1.0));
    fragUV = vec2(uv.x, 1.0 - uv.y);
}

My fragment shader:


#version 450

in vec4 fragColour;
in vec2 fragUV;

out vec4 colour;

layout(binding = 0) uniform sampler2D diffuse;

void main()
{
    vec4 textureColour = texture(diffuse, fragUV);
    colour = textureColour * fragColour;
}

Uniforms have [i]locations[/i]. Only uniforms of opaque types have bindings.

So that should be layout(location = 1) uniform mat4 orthoMat;.

So when I use a sampler I should bind it, when it uses a normal uniform it should use the location?

The location= qualifier fixes the variable’s location, returned by glGetUniformLocation() and passed to glUniform*(). If you don’t use it, the location is allocated by the linker. In that case, you must use glGetUniformLocation() to query the location in the application code; if you use location=, you can hard-code the location.

The binding= qualifier sets the initial value (texture unit index) for sampler uniforms. If you don’t use it, you need to set the value in the application code using glUniform1i(). If you set the value via a binding= qualifier, then there’s no need to set it in the application code, so you probably don’t care about the variable’s location.