-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
V-Sync toggle in SDL (OpenGL + Metal) #822
Conversation
src/graphic/Fast3D/gfx_sdl2.cpp
Outdated
if (vsync_enabled != Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger(CVAR_VSYNC_ENABLED, 1)) { | ||
// Make sure only 0 or 1 is set. | ||
vsync_enabled = !!Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger(CVAR_VSYNC_ENABLED, 1); | ||
} | ||
SDL_GL_SetSwapInterval(vsync_enabled); | ||
SDL_RenderSetVSync(renderer, vsync_enabled); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i feel like we shouldn't be calling these every time we call SDL_GL_SwapWindow
. this really should only happen when the cvar changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where and how would i do that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, or do you mean setting the swap interval? I thought you ment getting the cvar.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed that
src/graphic/Fast3D/gfx_sdl2.cpp
Outdated
if (vsync_enabled != Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger(CVAR_VSYNC_ENABLED, 1)) { | ||
// Make sure only 0 or 1 is set. | ||
vsync_enabled = | ||
(Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger(CVAR_VSYNC_ENABLED, 1) ? 1 : 0); | ||
SDL_GL_SetSwapInterval(vsync_enabled); | ||
SDL_RenderSetVSync(renderer, vsync_enabled); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this does seem better than calling SDL_GL_SetSwapInterval
and SDL_RenderSetVSync
every time, but it'd still prefer to find a way to not need to check the cvar all the time like this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, but I have no idea how. Any suggestion?
Works without changes on the port side, but similar changes like this are recommended: HarbourMasters/Shipwright#5074 (This can also be used as Test-PR)