opengl - Invalide value when using EmitVertex in GLSL version 150 -


this glsl shader compiles fine, when try activate gluseprogram(); opengl gives me invalid value error:

@vert #version 150 uniform mat4 projectionmodelview_matrix_; in vec3 global_position_;  void main(void) {     gl_position = projectionmodelview_matrix_ * vec4(global_position_, 1.0);     emitvertex();      gl_position = projectionmodelview_matrix_ * vec4(global_position_, 1.0);     emitvertex();      gl_position = projectionmodelview_matrix_ * vec4(global_position_, 1.0);     emitvertex();     endprimitive(); }  @frag #version 150 out vec4 out_color_; void main(void) {     out_color_ = vec4(1.0, 0.0, 0.0, 1.0); } 

however, if remove parts emit vertices, works. doing wrong?

easy answer, vertex shader cannot use emitvertex , endprimitive. vertex shader invoked once each vertex passed through pipeline , puts out varying values single vertex. cannot create or discard vertices or primitives (it doesn't have reasonable notion of primitives @ all). need geometry shader (though code doesn't make sense @ all, putting out triangle has same vertex each corner, there wouldn't rasterized @ all).

so given vertex shader plain illegal, doubt truth of statement "this glsl shader compiles fine", , gl_invalid_value error seems reasonable. though gl_invalid_value thrown program wasn't generated gl (but may due wrapper framework deleting not compiled , linked program, strange though).


Comments