Skip to content

Commit

Permalink
enable r_swapInterval under Emscripten
Browse files Browse the repository at this point in the history
  • Loading branch information
jdarpinian committed Jun 25, 2024
1 parent 035da58 commit 87b93c6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 3 additions & 2 deletions code/qcommon/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -2741,10 +2741,11 @@ void Com_Init( char *commandLine ) {
// init commands and vars
//
com_altivec = Cvar_Get ("com_altivec", "1", CVAR_ARCHIVE);
#ifdef EMSCRIPTEN
#ifdef __EMSCRIPTEN__
// Under Emscripten the browser handles throttling the frame rate.
// Manual framerate throttling interacts poorly with Emscripten's
// browser-driven event loop. So default throttling to off.
// browser-driven event loop. So default throttling to off. See here
// for discussion: https://github.com/ioquake/ioq3/issues/675
com_maxfps = Cvar_Get ("com_maxfps", "0", CVAR_ARCHIVE);
#else
com_maxfps = Cvar_Get ("com_maxfps", "85", CVAR_ARCHIVE);
Expand Down
10 changes: 8 additions & 2 deletions code/renderergl2/tr_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -1365,8 +1365,14 @@ void R_Register( void )
r_dlightBacks = ri.Cvar_Get( "r_dlightBacks", "1", CVAR_ARCHIVE );
r_finish = ri.Cvar_Get ("r_finish", "0", CVAR_ARCHIVE);
r_textureMode = ri.Cvar_Get( "r_textureMode", "GL_LINEAR_MIPMAP_LINEAR", CVAR_ARCHIVE );
r_swapInterval = ri.Cvar_Get( "r_swapInterval", "0",
CVAR_ARCHIVE | CVAR_LATCH );
#ifdef __EMSCRIPTEN__
// Under Emscripten we don't throttle framerate with com_maxfps by default, so enable
// vsync by default instead. See here for discussion:
// https://github.com/ioquake/ioq3/issues/675
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
r_gamma = ri.Cvar_Get( "r_gamma", "1", CVAR_ARCHIVE );
r_facePlaneCull = ri.Cvar_Get ("r_facePlaneCull", "1", CVAR_ARCHIVE );

Expand Down

0 comments on commit 87b93c6

Please sign in to comment.