why is windows so bad
This commit is contained in:
parent
5a0252d8d0
commit
733aa19e5a
21
src/main.cpp
21
src/main.cpp
@ -1,6 +1,7 @@
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3/SDL_main.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <imgui/imgui.h>
|
||||
#include <imgui/backends/imgui_impl_sdl3.h>
|
||||
#include <imgui/backends/imgui_impl_sdlrenderer3.h>
|
||||
@ -139,8 +140,11 @@ int main(int argc, char** argv) {
|
||||
//);
|
||||
|
||||
|
||||
#if 1
|
||||
if (render || tick) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1)); // yield for 1ms
|
||||
// why is windows like this
|
||||
//std::this_thread::sleep_for(std::chrono::milliseconds(1)); // yield for 1ms
|
||||
SDL_Delay(1); // yield for 1ms
|
||||
} else {
|
||||
|
||||
#if 0
|
||||
@ -151,14 +155,25 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
#else
|
||||
// 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>(
|
||||
//screen->nextTick() - time_delta_tick,
|
||||
//screen->nextRender() - time_delta_render
|
||||
//)
|
||||
//));
|
||||
SDL_Delay(uint32_t(
|
||||
std::min<float>(
|
||||
screen->nextTick() - time_delta_tick,
|
||||
screen->nextRender() - time_delta_render
|
||||
)
|
||||
) * 1000.f
|
||||
));
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
// why is windows like this
|
||||
//std::this_thread::sleep_for(std::chrono::milliseconds(1)); // yield for 1ms
|
||||
SDL_Delay(1); // yield for 1ms
|
||||
#endif
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user