glLineStipple gap colour filling..

we have a requirment to fill the stripple lines with two alternative colours , all the gaps in the stripple line should be filled with different colour. In the end it should look like a solid line with two colours. However this alternative colour setting is not aviable in stripple patterns. To achive this we are rendering the same stripple with ~pattern using different colour.

Comming to my problem if i have million points representing the line stripple i have to repeate this loop twice(for gap colour line) which is expensive, or i can render two lines after every two points one after other with different colour this however increases my glBegin() and glEnd() steps.

Can any body advise me what should be the optimal approach?

If it is possible for you, use shaders with interpolated custom parameter to select a color at a given point. You could also use 1D texture with the color pattern (probably the easiest way).

a million lines can be a bit hard to render, but they are lines and that means you have few fragments and that your vertex transform limited and not fillrate limited, so you could try uploading those point’s into a VBO, that will give you a nice boost, even if you render it twice.

Thanks for your valuble suggestions, however i tried using display lists and it works havent yet tested for huge data points, do you think display list is the right solution to render the same line twice with different colour and ~pattern.

No, it is better than immediate mode (glBegin/glEnd) when rendering static meshes, but on modern hardware Vertex Buffer Objects is the way to go since you upload all the data for it in the graphics memory and keep it there, in some cases i can get more than 5 times the rendering speed just by using VBOs.