-> 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);
}
-> Fragment Shader
#version 130
precision highp float;
in vec3 testcolor;
void main() {
gl_FragColor = vec4(testcolor, 1.0);
}
GLSL 1.3 cannot get color
Hello,
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
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?
glGetShaderiv(hShader,GL_COMPILE_STATUS,&result);
glGetShaderiv(hShader,GL_INFO_LOG_LENGTH,&infolength);
glGetShaderInfoLog(hShader,infolength,&l,log);
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)
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?
glGetShaderiv(hShader,GL_COMPILE_STATUS,&result);
glGetShaderiv(hShader,GL_INFO_LOG_LENGTH,&infolength);
glGetShaderInfoLog(hShader,infolength,&l,log);
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)
it worked. i just had some issues in my ShaderManager and i fixed them.
I got several other question about shaders:
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
I got several other question about shaders:
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement