# GLSL 1.3 cannot get color

## Recommended Posts

Hello,
-> VertexShader

#version 130

in vec3 in_position;
out vec3 testcolor;

void main() {

gl_Position = gl_ModelViewProjectionMatrix * vec4(in_position, 1.0);
testcolor = vec3(1.0, 1.0, 0.0);

}

#version 130

precision highp float;

in vec3 testcolor;

void main() {

gl_FragColor = vec4(testcolor, 1.0);

}

What is the problem here? It works (shows the color) when gl_FragColor = vec4(1.0, 1.0, 0.0, 1.0) but doesn't work when using in (for VS) and out (for FS). Thanks, Kasya

##### Share on other sites
Nothing stands out to me as an error, but I'm not a guru.

Does it work if you use attribute/varying instead of in/out? I'm not sure what version those keywords were depreciated in.

Also are you checking for errors after you compile the shader?

etc?

In my compiler I get an error (not warning) that gl_ModelViewProjectionMatrix is depreciated after version 1.20 and it actually fails to compile, so I don't know if that might have something to do with your situation (your compiler may be different though)

##### Share on other sites
it worked. i just had some issues in my ShaderManager and i fixed them.

1. glVertexAttribPointer(index, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void *) bufferoffset);

Do i suppose to add buffer offset into pointer argument like i did in glVertexPointer, glColorPointer?

2. When do i have Bind Attribute (glBindAttribLocation) - before or after Linking program?

Thanks,
Kasya

##### Share on other sites
Documentation will set you free:

glVertexAttribPointer
glBindAttribLocation

##### Share on other sites
Thank you for the link. Helped me a lot :) I now have my shader manager class full working :)

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628305
• Total Posts
2981967

• 9
• 13
• 11
• 12
• 11