Jump to content
  • Advertisement
Sign in to follow this  

Frame update accumulator and input events

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);
	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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Advertisement

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!