mirror of
https://github.com/love2d/love.git
synced 2026-08-18 03:34:23 +02:00
The vsync field in t.window and love.window.setMode is now an integer.
0 disables vsync, 1 sets it to sync every screen refreshes, 2 sets it to sync every 2 screen refreshes (effectively setting the framerate to half the monitor's refresh rate), etc. As a special case, -1 also attempts to use adaptive vsync (vsync enabled when FPS is >= monitor's refresh rate, disabled whe not) if the driver supports it. --HG-- branch : minor
This commit is contained in:
@@ -483,7 +483,12 @@ bool Window::setWindow(int width, int height, WindowSettings *settings)
|
||||
|
||||
SDL_RaiseWindow(window);
|
||||
|
||||
SDL_GL_SetSwapInterval(f.vsync ? 1 : 0);
|
||||
SDL_GL_SetSwapInterval(f.vsync);
|
||||
|
||||
// Check if adaptive vsync was requested but not supported, and fall back
|
||||
// to regular vsync if so.
|
||||
if (f.vsync == -1 && SDL_GL_GetSwapInterval() != -1)
|
||||
SDL_GL_SetSwapInterval(1);
|
||||
|
||||
updateSettings(f);
|
||||
|
||||
@@ -568,7 +573,7 @@ void Window::updateSettings(const WindowSettings &newsettings)
|
||||
SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &samples);
|
||||
|
||||
settings.msaa = (buffers > 0 ? samples : 0);
|
||||
settings.vsync = SDL_GL_GetSwapInterval() != 0;
|
||||
settings.vsync = SDL_GL_GetSwapInterval();
|
||||
|
||||
SDL_DisplayMode dmode = {};
|
||||
SDL_GetCurrentDisplayMode(settings.display, &dmode);
|
||||
|
||||
Reference in New Issue
Block a user