So, in order to draw a line, I track the coordinates of the mouse, then I add them to the array and capture it as GL_LINE_STRIP_ADJACENCY. However, for example, I completed drawing a line1 at P1 and decided to start drawing a different line at P2 as shown in the figure, but my two points P1 and P2 joined together, how to fix it? Need to clear the array after drawing at the point P1, actually it doesn't help if I use glClearColor and glClear(GL_COLOR_BUFFER_BIT).. Is there any other way?
It seems like you're drawing both lines with only one primitive by accumulating vertices frame-by-frame tracked from the mouse position. To fix it, when you're done drawing one line(you release mouse button and press again), you should create another primitive and start accumulating vertices inside it.