SaintJob 2.0
SaintJob 2.0

Reputation: 574

GLSL - program link error: Slot 0 unavailable from layout location request

I'm trying to draw a textured quad copying some code from a tutorial but I'm afraid there is a problem with the shaders.

Both the vertex shader and the fragment shader compilation works, but when linking the program I get the error:

ERROR: Active attribute aliasing. Slot 0 unavailable for 'vertex' from layout location request.

Shouldn't the location of the second vector be (location = 1)?

I use SDL2 window - OpengGL context: OpenGL Version: 4.1 INTEL-10.6.20 (MAC OSX)

These are the shader files:

vertex.glsl

#version 330 core

layout(location = 0) in vec3 vertex;
layout(location = 0) in vec2 uv;

// will be used in fragment shader
out vec2 uv_frag;

void main(){
    uv_frag = uv;
    gl_Position = vec4(vertex, 1.0);
}

fragment.glsl

#version 330 core

// has to have same name as vertex shader
in vec2 uv_frag;

// our texture
uniform sampler2D tex;

// actual output
// gl_FragColor is deprecated
out vec4 frag_color;

void main(){
    frag_color = texture(tex, uv_frag);
}

Upvotes: 1

Views: 590

Answers (1)

derhass
derhass

Reputation: 45342

Well, the situation is very clear. You already gave the answer yourself.

Shouldn't the location of the second vector be (location = 1)?

Yes. Or less specific: it should be something else than 0. Attribute locations must be unique in a single program, for obvious reasons. The code you copied from wherever is just invalid.

Upvotes: 2

Related Questions