Advertisement Jump to content
Sign in to follow this  
Finalspace

Frame update accumulator and input events

This topic is 460 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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!