I just want to make a simple animation (for example, in C ++ using OpenGL) of some moving object - let’s say, a simple horizontal movement of a square from left to right.
In OpenGL, I can use the “double buffering” method and say that the user (running my animation application) has turned on “vertical sync”, so I can call some function every time the monitor is updated (I can achieve this, for example, using Qt toolkit and its functions "swapBuffers").
So, I think that the “smoothest” animation that I can achieve is to “move a square, for example, 1 pixel (maybe different values) every time the monitor is updated,” so on every “frame” the square is 1 pixel further - "I TEST THIS, AND THIS WORKS HARDLY TO MIX."
But the problem arises when I want to have a "separate" thread for the "game logic" (moving the square 1 pixel to the right) and for the "animation" (displaying the current position of the square on the screen). Because let them say that the game logical thread is a while loop in which I move the square by 1 pixel, and then “sleep” the stream for some time, for example 10 milliseconds, and my monitor is updated, for example, every 16 milliseconds - movement the square “will not be 100% smooth”, because sometimes the monitor is updated twice, when the square moves only 1 pixel, and not 2 pixels (because there are two “different” frequencies of the monitor and game logic) - and the movement will look "a little jerk."
So, logically, I could stay with the first super-smooth method, but it cannot be used, for example, in multiplayer games (for example, server-client), since different computers have different monitor frequencies (therefore I should use different threads for game logic (on the server) and for animation (on the clients)).
So my question is: Is there any method that uses different threads for the logic of the game and animation, which perform a “100% smooth” animation of some moving object, and if there is any other, please describe it here, or when I just had some kind of “more complicated scene for rendering”, I just won’t see this “little jerky movement” that I see now when I move some simple square horizontally and I concentrate deeply on it :)?