GLSL 1.3 cannot get color

Started by
3 comments, last by Kasya 14 years, 2 months ago
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);

}

-> Fragment Shader

#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
Advertisement
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)
[size=2]My Projects:
[size=2]Portfolio Map for Android - Free Visual Portfolio Tracker
[size=2]Electron Flux for Android - Free Puzzle/Logic Game
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
Documentation will set you free:

glVertexAttribPointer
glBindAttribLocation
[size=2]My Projects:
[size=2]Portfolio Map for Android - Free Visual Portfolio Tracker
[size=2]Electron Flux for Android - Free Puzzle/Logic Game
Thank you for the link. Helped me a lot :) I now have my shader manager class full working :)

This topic is closed to new replies.

Advertisement