Sign in to follow this  
Finalspace

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

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