A
A
alex_ak12016-12-05 19:48:20
OpenGL
alex_ak1, 2016-12-05 19:48:20

Why is the geometry shader not working?

I'm trying to write a simple geometry shader.
Vertex shader:

in vec4 vert;
void main(void) {
  gl_Position = gl_ModelViewProjectionMatrix  * (vert + vec4(-1,0,0,0));
}

And geometric:
out vec4 vert;
void main(void) { int i;
for( i = 0; i < gl_in.length(); i++ )
  {
    vert = gl_in[i].gl_Position;
    EmitVertex();
  }
EndPrimitive();
}

If I add only the vertex to the program, then everything is fine, a couple of lines are drawn.
If I add a geometric one, nothing happens, that is, the screen is empty.
What I forgot to do in order for this shader to successfully pass through all the primitives.
After attaching the geometry shader, I call setting the parameters:
glProgramParameteriEXT( shader_prog, GL_GEOMETRY_INPUT_TYPE_EXT, GL_LINES);
  glProgramParameteriEXT(	shader_prog, GL_GEOMETRY_OUTPUT_TYPE_EXT, GL_LINES);
  glProgramParameteriEXT(	shader_prog, GL_GEOMETRY_VERTICES_OUT_EXT, 2);

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question