Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Error with Geometry shaders

  1. #1
    Junior Member Regular Contributor
    Join Date
    Jun 2012
    Posts
    191

    Error with Geometry shaders

    Here are my shaders:
    Code :
    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.

  2. #2
    Junior Member Regular Contributor
    Join Date
    Mar 2009
    Posts
    152
    This is not needed:

    #extension GL_EXT_geometry_shader4 : enable

    You are using 'core' Geometry Shader version not EXT.

  3. #3
    Junior Member Regular Contributor
    Join Date
    Jun 2012
    Posts
    191
    Quote Originally Posted by randall View Post
    This is not needed:

    #extension GL_EXT_geometry_shader4 : enable

    You are using 'core' Geometry Shader version not EXT.
    I removed that line and kept only
    #version 150
    But still, same error.

  4. #4
    Senior Member OpenGL Pro
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    1,109
    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.

  5. #5

  6. #6
    Senior Member OpenGL Pro
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    1,109
    Thanks Alfonse

  7. #7
    Junior Member Regular Contributor
    Join Date
    Jun 2012
    Posts
    191
    Can anyone shed some light on this issue?
    BTW, qualifiers in and out is not an issue as it works without geometry shaders.

  8. #8
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    3,126
    Quote Originally Posted by debonair View Post
    Can anyone shed some light on this issue?
    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.

  9. #9
    Junior Member Regular Contributor
    Join Date
    Jun 2012
    Posts
    191
    Quote Originally Posted by Dark Photon View Post
    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 ?

  10. #10
    Advanced Member Frequent Contributor arekkusu's Avatar
    Join Date
    Nov 2003
    Posts
    761
    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.
    Last edited by arekkusu; 02-07-2013 at 10:30 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •