Easy answer, a vertex shader cannot use EmitVertex
and EndPrimitive
. A vertex shader is invoked once for each vertex passed through the pipeline and puts out the varying values for that single vertex. It cannot create or discard any vertices or primitives (it doesn't even have a reasonable notion of primitives at all). What you need for this is a geometry shader (though your code doesn't make so much sense at all, putting out a triangle that has the same vertex for each corner, so there wouldn't be anything rasterized at all).
So given that this vertex shader is plain illegal, I actually doubt the truth of the statement "This glsl shader compiles fine", and the GL_INVALID_VALUE
error seems reasonable. Though GL_INVALID_VALUE
would actually be thrown for a program that wasn't generated by the GL (but that may also be due to some wrapper framework just deleting a not successfully compiled and linked program, strange though).