I was working on my options menu, while looking through the wiki I noticed that adaptive vsync wasn't supported on all graphics drivers.
So I thought maybe there's a function to check if it is supported or not, but couldn't find one.
But I know you can set the vsync inside conf.lua to either 0 or 1 or -1(adaptive).
So my questions are:
What would happen if t.window.vsync = -1 will the game just crash or love just set vsync to either 0 or 1 ?
Is there a function to check if adaptive vsync is supported ? Have I just missed it somewhere on the wiki ?
Is the code below a valid way to check if it is supported ?
function window.isAdaptiveVSyncSupported()
local refreshRate = love.window.getDPIScale() * love.window.getDisplayRefreshRate()
local frameRate = 60
return refreshRate % frameRate == 0
end
the code above, in theory:
Check the refresh rate of the monitor and compare it to the desired frame rate of the game. If the refresh rate is a multiple of the frame rate, then adaptive VSync is supported.
What would happen if t.window.vsync = -1 will the game just crash or love just set vsync to either 0 or 1 ?
If -1 (adaptive vsync) is requested but not supported, love will try setting it to 1 (regular vsync) instead. Even that request might fail if the user has set up their graphics driver settings to override app vsync settings.
love.window.getVSync will return the actual current vsync value.
function window.isAdaptiveVSyncSupported()
local refreshRate = love.window.getDPIScale() * love.window.getDisplayRefreshRate()
local frameRate = 60
return refreshRate % frameRate == 0
end
I don't think that will do what you expect.
DPI scale is completely unrelated to refresh rate (it's a thing that affects resolution and content scale rather than refresh rate).
Also getDisplayRefreshRate isn't a function that exists in love (love.window.getMode returns the current refresh rate as part of its settings table). Where did you get that code from?
So basically when I toggle the checkbox I Should set and get VSync and if getVSync return 1 or -1 everything is fine and if getVSync return 0 then I just uncheck the checkbox and potentially use love.window.showMessageBox() to inform the user.
I don't think that will do what you expect.
DPI scale is completely unrelated to refresh rate (it's a thing that affects resolution and content scale rather than refresh rate).
Also getDisplayRefreshRate isn't a function that exists in love (love.window.getMode returns the current refresh rate as part of its settings table). Where did you get that code from?
Actually I came up with that code, although I think getDisplayRefreshRate came from an old forum post I found online a few weeks ago. (not this forum)
Maybe an old function that got removed ? either that or it what just complete bs.
Trastaroots wrote: ↑Sat Apr 08, 2023 2:28 am
if getVSync return [something other than -1] then I just uncheck the checkbox and potentially use love.window.showMessageBox() to inform the user.
IMO it's better UI/UX to let the checkbox stay ticked as the user chose it instead of forcing it to change, and then show the warning message (maybe as a tooltip from a new UI element shown next to the checkbox, a warning sign ⚠).
IMO it's better UI/UX to let the checkbox stay ticked as the user chose it instead of forcing it to change, and then show the warning message (maybe as a tooltip from a new UI element shown next to the checkbox, a warning sign ⚠).
Yeah, actually I might just do that, thx for the idea! I tried to use the showMessageBox function, but it seems more adapted for an app than a game.