Rendering Linepattern , dashed lines

Hello everyone,
I am working on a project in which i need to render linepatterns( dashed lines)
First of all the glLineStipple is depreciated and i don’t want to use that.
I went through multiple articles:

I am somewhere confused with which implementation should i follow.
Please Help and suggest me what and how (any possible idea) should i use which is according to my requirements and is doable.

My requirements–
1–> I need to apply line pattern on individual line segments(GL_LINES) and polygon also…(GL_LINE_STRIP and GL_LINE_LOOP)

2–> The pattern (to be used) stored in CPU (is in an array/vector) is like this…

example  A= {20} 
   dash(20)->||gap(20)->|| dash(20) ->||gap(20) ->|| dash(20) ->||gap(20) on

like this…2

 Example B= {20,10} 
 dash(20)->gap(10)->|| dash(20) ->gap(10) ->|| dash(20) ->gap(20) on

like this… 2-2

 Example C={20,10,5}
 dash(20)->gap(10)->dash(5)|| gap(20) -> dash(10) ->gap(5)||dash(20)->gap(10)->dash(5) 

…so on like this… 23
means alternatively dash and gap (always starting from dash…)
NOTE: The above images are rendering by cairo graphics… I need to implement the same using pure OpenGL
Please Help :slightly_smiling_face: