Problem of varying and in

it works well like that:
in the vertex shader
varying float v;
void main()
{

v=10;

}

in the Fragment shader
varying float v;
main()
{
gl_FragColor = gl_Color*v;
}

however ,if i change it like that,it won’t work,why???
in the vertex shader:
out float v;
void main()
{

v=10;

}

in the Fragment shader
in float v;
main()
{
gl_FragColor = gl_Color*v;
}

however ,if i change it like that,it won’t work,why???

I don’t know; do you think this question really needs eight question marks?

:wink:

In any case, you didn’t say what about this doesn’t work. Is it a compiler error? A linker error?

Your shader examples do not seem to have a #version definition, which means that it will be compiled against GLSL version 1.10. And back then, they didn’t have “in” and “out”; only “varying”. If you want to use more up-to-date GLSL syntax, you need to have a #version definition for GLSL 1.30 or greater.

it does not work mean that in the Fragment shader
in float v;
main()
{
gl_FragColor = gl_Color*v;
}

in float v should affect gl_FragColor,but the result teapot is just white , so i think v does not receive any value from vertex shader,i use #version 140 ,but it does not work either.

Isn’t gl_FragColor deprecated since GLSL > 1.2 ?

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.