Basic geomerty shader problem

hi all,
I am trying to render points. The rendering works fine if i don’t use the passthrough geometry shader. I am trying to make it work with the passthrough geometry shader but i get an error (1282) Invalid operation after the call to

glDrawArrays(GL_POINTS,0,vertices.size());

This is my geometry shader. Note that the vertex shader is already giving the pos in clipspace (multiply by MVP).


#version 330 

layout (points) in;
layout (points) out;
layout (max_vertices = 3) out;

void main(void)
{	
   for (int i = 0; i < gl_in.length(); i++) {
      gl_Position = gl_in[i].gl_Position;
      EmitVertex();
   }
   EndPrimitive();
}

Am I missing anything here? I have tried to render triangles using the same geometry shader (but with the first two layouts changed to


layout(triangles) in;
layout(triangle_strip) out;

and replaced the draw call to glDrawElements and it works fine. Why doesn’t it work with points?

Are you using point-size mode? If so, you have to write to gl_PointSize as well.

Are you using point-size mode? If so, you have to write to gl_PointSize as well.

No I m not setting the point size from the shader so this is not the problem.

Actually, the shader is correct. I didn’t realize I was working with the shader from a different location while the actual shader used was always working fine. Silly me :slight_smile: So i think the problem is solved.