Question

I'm using GLFW 3 and OpenGL 4 + GLSL 4 on a MacBook Pro. I get the following syntax error, when starting my program:

ERROR: 0:5: 'varying' : syntax error syntax error

The shader code:

#version 410

varying vec3 vertex;

void main() {
}

Why am I not allowed to use varying variables?

Was it helpful?

Solution

Why am I not allowed to use varying variables?

Because they have been replaced by the more generic in/out variable concept since GLSL 1.30.

That became necessary because with GL3, the geometry shader was introduced, so a more generic communication method between shader stages was needed. Nowadays you just declare out variables in one shader stage and have the same declarations as in in the next shader stage you are using. The concept of varying is still the same - the outputs of the last shader stage (you use) before the rasterizer should match the inputs of the fragment shader (or the first shader stage after the rasterizer, but currently, there is no other), and the data will be interpolated across the primitive per default (if you don't declare it as flat, or use types which can't be interpolated).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top