Unfortunately, you may have to actually completely convert your geometry into linear primitives and render them using GL_LINES . However, this, of course, is not easy to replace GL_TRIANGLES (or something else) with GL_LINES in your draw calls, you will have to completely reorder your vertices in order to adapt to the new primitive mode. This requires that you at least use different index arrays in glDrawElements... or, for non-indexed rendering ( glDrawArrays... ), generally different vertex arrays (although if you really decide to do this, this may be a good time to switching to indexed drawing instead).
However, if you have Geometry Shaders (although WebGL does not seem to support them, OpenGL ES should start with 3.2, as desptop GL does, but in any case it has the good old glPolygonMode ) and no longer uses them for something of another, everything becomes easier. In this case, you can simply set a fairly simple geometric shader between processing the vertex and the fragment, which takes triangles and displays 3 lines for each of them:
layout(triangles) in; layout(line_strip, max_vertices=4) out; void main() { for(int i=0; i<4; ++i) {
If you use the correct block shader interface, you should be able to use your existing vertex and fragment shaders for the rest and just intercept this geometric shader between them to wireframe rendering all kinds of triangle-based primitives.
source share