private static void Window_MouseMove(object sender, OpenTK.Input.MouseMoveEventArgs e)
{
GameWindow window = sender as GameWindow;
if (flag)
{
//CLEAR THE BUFFER AFTER EACH LINE DRAWN NOT TO HAVE MILLION LINES ON SCREEN.
GL.Clear(ClearBufferMask.ColorBufferBit);
float x = (e.X - window.Width / 2f) / (window.Width / 2f);
float y = -(e.Y - window.Height / 2f) / (window.Height / 2f);
//THESE FOLLOWING COORDINATES ARE STORED IN AN ARRAY WHEN I CLICK THE MOUSE.
float x2 = (vectors[vectors.Count - 1].X - window.Width / 2f) / (window.Width / 2f);
float y2 = -(vectors[vectors.Count - 1].Y - window.Height / 2f) / (window.Height / 2f);
//DRAWING LINE.
Draw.DrawLine(new Vector3(x2, y2, 0), new Vector3(x, y, 0f), programDrawing, "aPos");
window.SwapBuffers();
}
}
This code works ok except that the line doesn’t follow the cursor on time, it always lags behind, I wonder why does this happen and how can I eliminate this problem?!