C++ - SDL: Limiting framerate issue -
although following code power saving, fps not capped properly. when supposed lock framerate @ 60 fps, 82. same 30, 49 fps.
calculating fps:
previoustime = currenttime; currenttime = sdl_getticks(); fps_++; if (currenttime - lastoutput >= 1000) { lastoutput = currenttime; fps = fps_; // variable 'fps' displayed fps_ = 0; } limiting fps:
if (currenttime - previoustime < 1000 / maxfps) { sdl_delay(1000 / maxfps - currenttime + previoustime); } what did mess up?
i'm defo not expert, can try this!
sdl_delay(1000 / maxfps - sdl_getticks() + previoustime); using newly calculated current time might help
Comments
Post a Comment