Skip to content
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

Merged
merged 4 commits into from
Feb 21, 2025
Merged

Conversation

Spodi
Copy link
Contributor

@Spodi Spodi commented Feb 16, 2025

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)

Comment on lines 665 to 670
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);
Copy link
Collaborator

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

Copy link
Contributor Author

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed that

Comment on lines 665 to 671
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);
}
Copy link
Collaborator

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

Copy link
Contributor Author

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?

@briaguya-ai briaguya-ai merged commit 7fb120b into Kenix3:main Feb 21, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants