Hi all,
I have a basic geometry shader that is rendering the tetrahedron triangles as triangle strips. I strippify the triangles as follows. Assuming that the tetrahedron has 4 vertices p0,p1,p2 and p3 with p3 being the apex vertex. A very simple stripification should be this sequence p0p1p3p2p0p1 so I render the geometry in opengl as follows.
for(size_t i=0;i<indices.size();i+=4) {
glm::vec3 p0 = positions[indices[i]];
glm::vec3 p1 = positions[indices[i+1]];
glm::vec3 p2 = positions[indices[i+2]];
glm::vec3 p3 = positions[indices[i+3]];
glBegin(GL_TRIANGLE_STRIP);
glVertex3f(p0.x,p0.y,p0.z);
glVertex3f(p1.x,p1.y,p1.z);
glVertex3f(p3.x,p3.y,p3.z);
glVertex3f(p2.x,p2.y,p2.z);
glVertex3f(p0.x,p0.y,p0.z);
glVertex3f(p1.x,p1.y,p1.z);
glEnd();
}
This renders fine. However, doing the same thing in the following geometry shader, some triangles are missing.
//single strip
gl_Position = p0; EmitVertex();
gl_Position = p1; EmitVertex();
gl_Position = p3; EmitVertex();
gl_Position = p2; EmitVertex();
gl_Position = p0; EmitVertex();
gl_Position = p1; EmitVertex(); EndPrimitive();
If I split the sequence into two strips (like this)
//two strips
gl_Position = p0; EmitVertex();
gl_Position = p1; EmitVertex();
gl_Position = p3; EmitVertex();
gl_Position = p2; EmitVertex(); EndPrimitive();
gl_Position = p3; EmitVertex();
gl_Position = p0; EmitVertex();
gl_Position = p2; EmitVertex();
gl_Position = p1; EmitVertex(); EndPrimitive();
it renders fine. Could anyone tell me why the single strip version does not work?