Syntaxerror 'varying' in GLSL
Asked Answered
K

1

6

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?

Katmandu answered 4/5, 2014 at 13:20 Comment(0)
M
6

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

Muscular answered 4/5, 2014 at 13:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.