Skip to content

ERROR: 0:3: error(#279) Invalid layout qualifier ‘location’

i am trying to follow a tutorial and when i try to compile the vertex shader he made i get this output:

Vertex shader failed to compile with the following errors:
ERROR: 0:3: error(#279) Invalid layout qualifier 'location'
ERROR: error(#273) 1 compilation errors.  No code generated

I use GLSL 3.2.9232 and my code :

#version 150

layout (location = 0) in vec3 position;

void main()
    gl_Position = vec4(0.25 * position, 1.0);



Input layout locations qualifiers (see Vertex shader attribute index) are introduced in in GLSL 3.30 and cannot be used in GLSL 1.50. Compare OpenGL Shading Language 3.30 Specification and OpenGL Shading Language 1.50 Specification.

Switch to glsl 3.30:

#version 150

#version 330

If your system doesn’t support GLSL 3.30, you have to remove the layout qualifier

layout (location = 0) in vec3 position;

in vec3 position; 

You can specify the attribute location with glBindAttribLocation before the program is linked:

glBindAttribLocation(program, 0, "position"); // has to be done before glLinkProgram
2 People found this is helpful