Sign in to follow this  
Kasya

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);

}

-> 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

Share this post


Link to post
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?

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)

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this