Hello!
I’m learning OpenGL so decided to make an application which draw plots. I decided to make a selection so found that drawing vertical line is slow.
I would like to draw a vertical line at a cursor’s position. The line moves as the cursor moves. The algorithm is:
1. Put data for 2 vertices (-1, 1, 0) and (-1, -1, 0) into array buffer for dynamic drawing.
2. Load shader which in fact just a white pixel.
loop:
3. Catch mouse position.
4. Update the coordinates of the vertieces.
5. Bind the vertex array of the vertieces.
6. Draw arrays in GL_LINES mode.
7. Unbind.
The problem is that the line doesn’t stick to the cursor. It is drawn with some delay. For example if I select files in my file explorer I don’t see such delay of a selection rectangle so it sticks right to the cursor. I don’t see that in a real-time strategy game selecting unites. So here I don’t understand what slows down my application.
I removed everything leaving only drawing the line. Still there 214 lines. You can see the C code here.
If you decide to build it and launch, please notice that path to the shaders supposes the application to be launched from the root of the project.