Good way to handle frames per second?
Hi, I'm writing an application that must show frames at a specified speed... I'm doing it like this:
Code:
Uint32 offset = SDL_GetTicks();
for (unsigned int i=0; i<videoFileManager.getFramesNumber(); i++){
showNextFrame();
while ((SDL_GetTicks() - offset) < (i*1000/videoFileManager.getFPS()) ){} //Waits until it's time to show the next frame
}
Ok. That works great... However, when I try to close my application before all the frames have been shown, it hangs (I get that Windows error message with the "Don't send" button). How could I manage to achieve managing the frames per second, being also able to manually close the application?