I am dealing with geometry shaders using GL_ARB_geometry_shader4 extension.
My code goes like :
GLfloat vertices[] =
{
0.5,0.25,1.0,
0.5,0.75,1.0,
-0.5,0.75,1.0,
-0.5,0.25,1.0,
0.6,0.35,1.0,
0.6,0.85,1.0,
-0.6,0.85,1.0,
-0.6,0.35,1.0
};
glProgramParameteriEXT(psId, GL_GEOMETRY_INPUT_TYPE_EXT, GL_TRIANGLES);
glProgramParameteriEXT(psId, GL_GEOMETRY_OUTPUT_TYPE_EXT, GL_TRIANGLE_STRIP);
glLinkProgram(psId);
glBindAttribLocation(psId,0,"Position");
glEnableVertexAttribArray (0);
glVertexAttribPointer(0, 3, GL_FLOAT, 0, 0, vertices);
glDrawArrays(GL_TRIANGLE_STRIP,0,4);
My vertex shader is :
#version 150
in vec3 Position;
void main()
{
gl_Position = vec4(Position,1.0);
}
Geometry shader is :
#version 150
#extension GL_EXT_geometry_shader4 : enable
in vec4 pos[3];
void main()
{
int i;
vec4 vertex;
gl_Position = pos[0];
EmitVertex();
gl_Position = pos[1];
EmitVertex();
gl_Position = pos[2];
EmitVertex();
gl_Position = pos[0] + vec4(0.3,0.0,0.0,0.0);
EmitVertex();
EndPrimitive();
}
Nothing is rendered with this code. What exactly should be the mode in glDrawArrays() ? How does the GL_GEOMETRY_OUTPUT_TYPE_EXT parameter will affect glDrawArrays() ?
What I expect is 3 vertices will be passed on to Geometry Shader and using those we construct a primitive of size 4 (assuming GL_TRIANGLE_STRIP requires 4 vertices). Can somebody please throw some light on this ?