Closed jdarpinian closed 5 months ago
This commit should also set r_swapInterval to 1 to ensure V-sync is enabled otherwise com_maxfps 0
runs as fast as possible after vid_restart (135 FPS for me). Please use #ifdef __EMSCRIPTEN__
as it's more consistent with platform defines.
I think it would be good to not use V-sync by default and improve handling of com_maxfps itself but that a larger change and this PR would be fine for now (with the above things fixed). https://github.com/ioquake/ioq3/issues/675
Done, thanks for the feedback
You can remove the two "See here for discussion: https://github.com/ioquake/ioq3/issues/675" in the source code. I don't think it adds value for future reference.
You can leave r_swapInterval as two separate lines so the original case is unchanged (and matches the opengl1 renderer).
#ifdef __EMSCRIPTEN__
// Under Emscripten we don't throttle framerate with com_maxfps by default, so enable
// vsync by default instead.
r_swapInterval = ri.Cvar_Get( "r_swapInterval", "1",
CVAR_ARCHIVE | CVAR_LATCH );
#else
r_swapInterval = ri.Cvar_Get( "r_swapInterval", "0",
CVAR_ARCHIVE | CVAR_LATCH );
#endif
Thanks.
Default com_maxfps to 0 under Emscripten. Under Emscripten the browser handles throttling the frame rate. Manual framerate throttling interacts poorly with Emscripten's browser-driven event loop.