mirror of
https://github.com/love2d/love.git
synced 2026-08-12 08:30:56 +02:00
Add refreshrate field to love.window.getFullscreenModes table entries.
This commit is contained in:
@@ -122,14 +122,15 @@ public:
|
||||
THEME_MAX_ENUM
|
||||
};
|
||||
|
||||
struct WindowSize
|
||||
struct DisplayMode
|
||||
{
|
||||
int width;
|
||||
int height;
|
||||
double refreshRate;
|
||||
|
||||
bool operator == (const WindowSize &w) const
|
||||
bool operator == (const DisplayMode &w) const
|
||||
{
|
||||
return w.width == width && w.height == height;
|
||||
return w.width == width && w.height == height && refreshRate == w.refreshRate;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -185,7 +186,7 @@ public:
|
||||
|
||||
virtual DisplayOrientation getDisplayOrientation(int displayindex) const = 0;
|
||||
|
||||
virtual std::vector<WindowSize> getFullscreenSizes(int displayindex) const = 0;
|
||||
virtual std::vector<DisplayMode> getFullscreenModes(int displayindex) const = 0;
|
||||
|
||||
virtual void getDesktopDimensions(int displayindex, int &width, int &height) const = 0;
|
||||
|
||||
|
||||
@@ -919,9 +919,9 @@ Window::DisplayOrientation Window::getDisplayOrientation(int displayindex) const
|
||||
return ORIENTATION_UNKNOWN;
|
||||
}
|
||||
|
||||
std::vector<Window::WindowSize> Window::getFullscreenSizes(int displayindex) const
|
||||
std::vector<Window::DisplayMode> Window::getFullscreenModes(int displayindex) const
|
||||
{
|
||||
std::vector<WindowSize> sizes;
|
||||
std::vector<DisplayMode> sizes;
|
||||
|
||||
int count = 0;
|
||||
SDL_DisplayMode **modes = SDL_GetFullscreenDisplayModes(GetSDLDisplayIDForIndex(displayindex), &count);
|
||||
@@ -929,7 +929,8 @@ std::vector<Window::WindowSize> Window::getFullscreenSizes(int displayindex) con
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
// TODO: other mode properties?
|
||||
WindowSize w = {modes[i]->w, modes[i]->h};
|
||||
double refreshrate = (double)modes[i]->refresh_rate_numerator / (double)modes[i]->refresh_rate_denominator;
|
||||
DisplayMode w = {modes[i]->w, modes[i]->h, refreshrate};
|
||||
|
||||
// SDL2's display mode list has multiple entries for modes of the same
|
||||
// size with different bits per pixel, so we need to filter those out.
|
||||
|
||||
@@ -62,7 +62,7 @@ public:
|
||||
|
||||
DisplayOrientation getDisplayOrientation(int displayindex) const override;
|
||||
|
||||
std::vector<WindowSize> getFullscreenSizes(int displayindex) const override;
|
||||
std::vector<DisplayMode> getFullscreenModes(int displayindex) const override;
|
||||
|
||||
void getDesktopDimensions(int displayindex, int &width, int &height) const override;
|
||||
|
||||
|
||||
@@ -280,7 +280,7 @@ int w_getFullscreenModes(lua_State *L)
|
||||
instance()->getPosition(x, y, displayindex);
|
||||
}
|
||||
|
||||
std::vector<Window::WindowSize> modes = instance()->getFullscreenSizes(displayindex);
|
||||
std::vector<Window::DisplayMode> modes = instance()->getFullscreenModes(displayindex);
|
||||
|
||||
lua_createtable(L, (int) modes.size(), 0);
|
||||
|
||||
@@ -297,6 +297,9 @@ int w_getFullscreenModes(lua_State *L)
|
||||
lua_pushinteger(L, modes[i].height);
|
||||
lua_setfield(L, -2, "height");
|
||||
|
||||
lua_pushnumber(L, modes[i].refreshRate);
|
||||
lua_setfield(L, -2, "refreshrate");
|
||||
|
||||
// Inner table attribs end.
|
||||
|
||||
lua_settable(L, -3);
|
||||
|
||||
Reference in New Issue
Block a user