Added a 'refreshrate' field to the table returned by love.window.getMode. The value may be 0 if the refresh rate of the monitor can't be determined. It might also be 59 instead of 60 on 59.94hz monitors on some operating systems.

This commit is contained in:
Alex Szpakowski
2014-08-20 20:22:46 -03:00
parent 9e93d854b8
commit e1f7e4abd3
4 changed files with 16 additions and 4 deletions
+6 -4
View File
@@ -105,17 +105,16 @@ int w_setMode(lua_State *L)
settings.minheight = luax_intflag(L, 3, settingName(Window::SETTING_MIN_HEIGHT), 1);
settings.borderless = luax_boolflag(L, 3, settingName(Window::SETTING_BORDERLESS), false);
settings.centered = luax_boolflag(L, 3, settingName(Window::SETTING_CENTERED), true);
settings.display = luax_intflag(L, 3, settingName(Window::SETTING_DISPLAY), 1);
settings.display = luax_intflag(L, 3, settingName(Window::SETTING_DISPLAY), 1) - 1;
settings.highdpi = luax_boolflag(L, 3, settingName(Window::SETTING_HIGHDPI), false);
settings.sRGB = luax_boolflag(L, 3, settingName(Window::SETTING_SRGB), false);
// We don't explicitly set the refresh rate, it's "read-only".
// For backward-compatibility. TODO: remove!
int fsaa = luax_intflag(L, 3, settingName(Window::SETTING_FSAA), 0);
if (fsaa > settings.msaa) settings.msaa = fsaa;
// Display index is 1-based in Lua and 0-based internally.
settings.display--;
luax_catchexcept(L,
[&](){ luax_pushboolean(L, instance()->setWindow(w, h, &settings)); }
);
@@ -176,6 +175,9 @@ int w_getMode(lua_State *L)
luax_pushboolean(L, settings.sRGB);
lua_setfield(L, -2, settingName(Window::SETTING_SRGB));
lua_pushnumber(L, settings.refreshrate);
lua_setfield(L, -2, settingName(Window::SETTING_REFRESHRATE));
return 3;
}