Jump to content
  • Advertisement
Sign in to follow this  
Finalspace

Frame update accumulator and input events

This topic is 371 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How do you ensure that you update at least once in a game loop like this - so you dont miss a mouse event you captured before?

Or is it better to handle input separately - before this update loop?

frameAccumulator = Clamp(frameAccumulator, 0.0, 0.5);
while (frameAccumulator >= targetDeltaTime) {
	game->Update(*renderer, *currentInput);
	++updateCount;
	frameAccumulator -= targetDeltaTime;
}

// Rendering...

// Frame ends
f64 frameEndTime = GetHighResolutionTimeInSeconds();
f64 frameDuration = frameEndTime - lastTime;
frameAccumulator += frameDuration;
lastTime = frameEndTime;

 

Edited by Finalspace

Share this post


Link to post
Share on other sites
Advertisement

Never mind, i fixed my issue with missing some input events - even though i handle input in the Update() method of the game class.

Edited by Finalspace

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!