Problem withgeomtry shader and core 150

hi

my geomtry shader dosent work in core 150. my OpenGL version is 3.3

vertex shader code


#version 150 core
in vec3 in_Position;
uniform mat4 in_ModelViewMatrix;
in vec4 in_VertexColor;
out vec4 VertexColor;
void main(void)
{
VertexColor = in_VertexColor;
gl_Position = in_ModelViewMatrix * vec4(in_Position,1.0);
}

geomtry shader:


#version 150
#extension GL_EXT_geometry_shader4 : enable

void main(void)
{
	//increment variable
	int i;

	//Pass-thru!
	for(i=0; i< gl_VerticesIn; i++){
		gl_Position = gl_PositionIn[i];
		EmitVertex();
	}
	EndPrimitive();	
}

fragment shader:


#version 150 core
in vec4 VertexColor;
out vec4 out_Color;
void main(void)
{
   out_Color = vec4(0);
}

what is wrong?

How doesn’t it work?

any thing doesn’t show in screen but it compile successfully

Your fragment shader is outputting solid black with an alpha of zero (vec4(0)). Is your background also black?

Regards,
Patrick

I’d say you’d want to make two changes to make it work.

  1. declare a layout of the type and maximum quantity your geometry shader should output. e.g.:
    layout(triangle, max_vertices = 3) out;

  2. Instead of glPositionIn[i], you want to use gl_in[i].glPosition

I have a tutorial for geometry shaders at http://www.opengl.org/wiki/Tutorial4:_Using_Indices_and_Geometry_Shaders_(C_/SDL) that may be of help.

no
my background is white. and I’m not using blending

Do you try it on both amd card and nvidia card?
You need to specify the input and output layout for geometry shader either in the shader or in the application.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.