Is there any way to parameterize a vector of lines or triangles for other than color?


For a list of shapes, is it possible to pass in for each not only the colors with the vertices, but some information about how to render?

As far as I know, if I havesome solid, some wireframe, some points, I must call once for each kind of shape.

Furthermore, even for lines, if some lines are to be drawn solid and others with various dash patterns, I don’t know of any way to draw that in a single call either.

Is it possible to do any of the above in a single call, passing information to associate with each vertex or line?


Wireframe vs. solid rendering is a rasterizer setting; that cannot be done in the middle of a rendering command.

But solid lines vs. “dash patterns” is almost certainly entirely up to how you want to draw your lines. So that’s in-shader stuff. You can implement that however you like. Which means you can implement it as a per-vertex parameter or something.


Thanks, can you point me to any example showing this?


Note that glEnable(GL_LINE_STIPPLE) and glLineStipple() aren’t available in the core profile. They’re still available in the compatibility profile but can’t be controlled via shaders. If you want shader-controlled line stipple you have to implement it yourself in the fragment shader. The simplest way to do this is via texturing; you’ll need to calculate the appropriate texture coordinates for each vertex.


You can add other attributes to the vertex buffer other than position, it’s really largely arbitrary what they are as long as you’re using custom shaders. I’m not sure if you are or if you’re using fixed function, but consider trying shaders instead if you are using fixed function.

You may want to look into geometry shaders for the case of wireframe, solid, and point being mixed in one draw call. However, I’m kind of doubtful it’s worth the effort and complexity in most cases. Still, you may find geometry shaders useful for this kind of thing in more general terms.

You could implement a vertex-attribute controlled stipple pattern in a fragment shader.