PDA

View Full Version : Problem of varying and in



apapaxionga
04-03-2011, 10:30 PM
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;
}

Alfonse Reinheart
04-03-2011, 10:52 PM
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?

;)

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 (http://www.opengl.org/wiki/GLSL_Core_Language#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.

apapaxionga
04-04-2011, 01:13 AM
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.

McLeary
04-04-2011, 07:50 AM
Isn't gl_FragColor deprecated since GLSL > 1.2 ?