why is windows so bad
This commit is contained in:
parent
5a0252d8d0
commit
9d967fc47f
11
src/main.cpp
11
src/main.cpp
@ -139,17 +139,18 @@ int main(int argc, char** argv) {
|
|||||||
//);
|
//);
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
if (render || tick) {
|
if (render || tick) {
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(1)); // yield for 1ms
|
std::this_thread::sleep_for(std::chrono::milliseconds(1)); // yield for 1ms
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
// pretty hacky and spins if close to next update
|
// pretty hacky and spins if close to next update
|
||||||
// if next loop >= 1ms away, wait 1ms
|
// if next loop >= 1ms away, wait 1ms
|
||||||
if (time_delta_tick+0.001f < screen->nextTick() && time_delta_render+0.001f < screen->nextRender()) {
|
if (time_delta_tick+0.001f < screen->nextTick() && time_delta_render+0.001f < screen->nextRender()) {
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(1)); // yield for 1ms
|
std::this_thread::sleep_for(std::chrono::milliseconds(1)); // yield for 1ms
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
// dynamic sleep, sleeps the reminder till next update
|
// dynamic sleep, sleeps the reminder till next update
|
||||||
std::this_thread::sleep_for(std::chrono::duration<float, std::chrono::seconds::period>(
|
std::this_thread::sleep_for(std::chrono::duration<float, std::chrono::seconds::period>(
|
||||||
std::min<float>(
|
std::min<float>(
|
||||||
@ -157,8 +158,12 @@ int main(int argc, char** argv) {
|
|||||||
screen->nextRender() - time_delta_render
|
screen->nextRender() - time_delta_render
|
||||||
)
|
)
|
||||||
));
|
));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
// msvc stl sleep_until got "clock aware" in oct 2023, gotta be some time until we can use this
|
||||||
|
std::this_thread::sleep_until(std::chrono::steady_clock::now() + std::chrono::milliseconds(1)); // yield for 1ms
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user