Error with Geometry shaders

Here are my shaders:


Vertex Shader:

in  vec4 v_color;
flat out vec4 out_color;
in vec2 Position;

void main()
{	
	gl_Position = vec4(Position,0.0,1.0);
	out_color = v_color;
}

Geom shader:

#version 150
#extension GL_EXT_geometry_shader4 : enable
layout (triangles)in;
layout (triangle_strip, max_vertices=4)out;
flat in vec4 out_color[];

flat out vec4 col;

void main()
{
   int i;
   vec4 vertex;

    for(i=0;i<gl_in.length();i++)
	{
		gl_Position = gl_in[i].gl_Position;
		col=out_color[i];
		EmitVertex();
	}

		
	gl_Position = gl_in[1].gl_Position + vec4(0.5,0.5,0.0,0.0);
	col=out_color[1];
	EmitVertex();

	
    EndPrimitive();
}

Frag shader:

out vec4 Color;
flat in  vec4 col;

void main()
{
	Color = vec4(col);	
}


Now, when i execute this on AMD supporting opengl 4.3 it works fine.
But with nvidia supporting 3.2 it gives errors:
"
Compile failed.
ERROR: 0:5: ‘flat’ : non varyings cannot have varying modifier qualifiers
ERROR: 0:7: ‘flat’ : non varyings cannot have varying modifier qualifiers
ERROR: 2 compilation errors. No code generated.
"
it gives error though they are of varying types. Please let me know what changes can be done so that it will work with nvidia too.

This is not needed:

#extension GL_EXT_geometry_shader4 : enable

You are using ‘core’ Geometry Shader version not EXT.

[QUOTE=randall;1247959]This is not needed:

#extension GL_EXT_geometry_shader4 : enable

You are using ‘core’ Geometry Shader version not EXT.[/QUOTE]

I removed that line and kept only
#version 150
But still, same error.

I thought the qualifiers “in” and “out” are from version 3.00 and forward but you have told the compiler you are version 1.5 - this may be confusing it.

GLSL version 1.50 is from OpenGL version 3.2.. They switched to sane numbering for GL 3.3/GLSL 3.30.

Thanks Alfonse

Can anyone shed some light on this issue?
BTW, qualifiers in and out is not an issue as it works without geometry shaders.

What you’re doing in the vertex and fragment shaders is not valid GLSL 1.10 (the default). Slap a #version 330 at the top of each and they’ll compile.

Unfortunately i have to make it work with driver supporting glsl150. Can you please tell me how can i achieve same effect using glsl150 ?

Slap a #version 150 at the top of the vertex and fragment shader. “flat in” was not legal syntax in #version 110 ten years ago, so it fails to parse.

Also, at least in Apple’s Core Profile, you would not be able to link a 110 and 150 shader together anyway; all of your shader versions need to be 140 or higher (#version is mandatory.)

Just to be clear, if you don’t specify #version, the driver has to assume the worst (most backwards-compatible) case and you get the oldest version.

[QUOTE=arekkusu;1248072]Slap a #version 150 at the top of the vertex and fragment shader. “flat in” was not legal syntax in #version 110 ten years ago, so it fails to parse.
[/QUOTE]

I added version 150 in each of the shader still the error persists…

Time to report a bug to Nvidia, then.