I think you’re a little confused about something here.
Eliminate “vertices” with a fragment shader? Frag shader has discard, but you’re not eliminating vertices at that point, but fragments. We’re not dealing with vertices at this point in the pipeline.
glTexParameterf to GL_NEAREST … However, when I display my object in 3D using an element array buffer, I want to achieve the same functionality… Any idea how to do this equivalently?
//glTexParameterf(GL_ELEMENT_ARRAY_BUFFER, GL_TEXTURE_MAG_FILTER,GL_NEAREST); // ← Looking for appropriate function
The TEXTURE_MAG/MIN_FILTER settings are for texture units (the gizmos that sample textures), and the element array buffer is not a texture unit but just a bind point for a data buffer, so this doesn’t work.
But reading between-the-lines, I think I know what you’re trying to ask for. Whereas with texture sampling, MAG/MIN_FILTERS of NEAREST disable color interpolation when sampling, I “think” you’re saying you would like to disable color vertex attribute interpolation across polygons (this is interpolation, but in a different context from texture sampling).
For fixed-function rendering (the old days), you could just use glShadeModel( GL_FLAT ) to disable color interpolation across triangles. Now when using shaders, you instead declare your color interpolator in the shader with the keyword “flat” to tell the driver to use no interpolation for this value – see the GLSL manual. You also have control over which triangle vertex’s attributes are used through PROVOKING_VERTEX control.
Backing up a step though, if you’re trying to throw away whole triangles whose vertices have some color that matches a shader-determined criteria, then it would be much more efficient to kill the triangle in the vertex shader rather than in every single fragment (pixel or sample) generated by the triangle. There’s no discard in the vertex shader, but you can mimic this by just moving each vertex behind the near clip plane. If you’re using a perspective projection, here’s one way to do that:
gl_Position = vec4( 0,0,1,0 ); // Clipped! (with perspective projection)