Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7534031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:53:53+00:00 2026-05-30T05:53:53+00:00

I just want to do a simple animation (for example in C++ using OpenGL)

  • 0

I just want to do a simple animation (for example in C++ using OpenGL) of some moving object – let’s say simple horizontal movement of a square from left to right.

In OpenGL, I can use “double-buffering” method and let’s say a user (running my application with the animation) have turned “vertical sync” on – so I can call some function every time when a monitor refreshes itself (I can achieve that for example using Qt toolkit and its function “swapBuffers”).

So, I think, the “smoothest” animation that I can achieve, is to “move the square by for example 1 pixel (can be other values) every time monitor refreshes”, so at each “frame” the square is 1 pixel further – “I HAVE TESTED THIS, AND IT SURELY WORKS SMOOTHLY”.

But the problem arises when I want to have “separate” thread for “game logic” (moving the square by 1 pixel to the right) and for “animation” (displaying current position of the square on the screen). Because let’s say the game logic thread is a while loop where I move the square by 1 pixel and then “sleep” the thread for some time, for example 10 milliseconds, and my monitor refreshes for example every 16 milliseconds – the movement of the square “won’t be 100% smooth” because sometimes the monitor will refresh two times where the square moves by only by 1 pixel and not by 2 pixels (because there two “different” frequencies of monitor and game logic thread) – and the movement will look “little jerky”.

So, logically, I could stay with the first super smooth method, but, it cannot be used in for example “multiplayer” (for example “server-client”) games – because different computers have different monitor frequencies (so I should use different threads for game logic (on the server) and for animation (on the clients) ).

So my question is:
Is there some method, using different threads for game logic and animation, which do “100% smooth” animation of some moving object and if some exists, please describe it here, or when I just had some “more complex scene to render”, I just would not see that “little jerky movement” which I see now, when I move some simple square horizontally, and I deeply concentrate on it 🙂 ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T05:53:54+00:00Added an answer on May 30, 2026 at 5:53 am

    Well, this is actually typical separate game-loop behavior. You manage all you physics (movement) related actions in one thread, letting the render thread to do its work. This is actually desirable.

    Don´t forget this way of implementation of game loop is to have maximum available frame rate while preserving constant physics speed. At higher FPS, you can not see this effect by any chance, if there is not any other code related problem. Some hooking between framerate and physics for example.

    If you want to achieve what you describe as perfect smoothness, you could synchronize your physics engine with VSync. Simply do all your physics BEFORE refresh kicks in, than wait for another.

    But this all applies to constant speed objects. If you have object with dynamic speed, you can never know when to draw it to be “in sync”. Same problem arises then you want multiple object with different constant speeds.

    Also, this is NOT what you want in complex scenes. The whole idea of V-sync is to limit screen tearing effect. You should definitely NOT hook your physics or rendering code to display refresh rate. You want you physics code to run independent of users display refresh rate. This could be REAL pain in multiplayer games for example. For start, look at this page: How A Game Loop Works

    EDIT:
    I say your vision of perfect smoothness is unrealistic. You can mask it using techniques Kevin wrote. But you will always struggle with HW limits as refresh rate, or display pixelation. For example, you have window of 640×480 px. Now, you want your object to move horizontally. You can move your object by vector heading towards bottom right corner, BUT you must increment object coordinates by float number (640/480). But in rendering, you go to integers. So your object moves jagged. No way around this. In small speed, you can notice it. You can blur it, or make it move faster, but never get rid of it…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just want a simple SVG image that has some arbitrary text on an
I understand that Silverlight 3.0 has binding but just want a simple example on
I just want some simple links where if it's hovered over, instead of having
I'm quite new to android and i want to make some animation (simple game
I just want a simple tool that will help me quickly write scripts/packages that
I just want to design this very simple website. Basically there are multiple pages
Simple question, I just want to select the text from the <Template> tag. Here's
It's really simple, I just want one screen. Wow, that [shiny thing] must have
Simple question, hopefully an easy way and just want to verify I'm doing it
I'm looking for as simple way to create an identity set. I just want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.