Removed love.window.checkMode (resolves issue #653, invalidates issue #592).

Also fixed love.window.setMode to fail instead of bug out when trying to set a fullscreen mode which is too large for the monitor.
This commit is contained in:
Alex Szpakowski
2013-09-19 18:13:52 -03:00
parent 74f26160da
commit ffe0485173
12 changed files with 60 additions and 125 deletions
+1 -1
View File
@@ -179,7 +179,7 @@ int w_triangulate(lua_State *L)
lua_createtable(L, triangles.size(), 0);
for (size_t i = 0; i < triangles.size(); ++i)
{
Triangle &tri = triangles[i];
const Triangle &tri = triangles[i];
lua_createtable(L, 6, 0);
lua_pushnumber(L, tri.a.x);
+2 -2
View File
@@ -98,9 +98,9 @@ int Physics::newPolygonShape(lua_State *L)
// 3 to 8 (b2_maxPolygonVertices) vertices
int vcount = argc / 2;
if (vcount < 3)
luaL_error(L, "Expected a minimum of 3 vertices, got %d.", vcount);
return luaL_error(L, "Expected a minimum of 3 vertices, got %d.", vcount);
else if (vcount > b2_maxPolygonVertices)
luaL_error(L, "Expected a maximum of %d vertices, got %d.", b2_maxPolygonVertices, vcount);
return luaL_error(L, "Expected a maximum of %d vertices, got %d.", b2_maxPolygonVertices, vcount);
b2PolygonShape *s = new b2PolygonShape();
-1
View File
@@ -68,7 +68,6 @@ public:
virtual int getDisplayCount() const = 0;
virtual bool checkWindowSize(int width, int height, bool fullscreen, int displayindex) const = 0;
virtual std::vector<WindowSize> getFullscreenSizes(int displayindex) const = 0;
virtual int getWidth() const = 0;
+9 -28
View File
@@ -103,15 +103,16 @@ bool Window::setWindow(int width, int height, WindowFlags *flags)
if (f.fullscreen)
{
switch (f.fstype)
{
case FULLSCREEN_TYPE_NORMAL:
default:
sdlflags |= SDL_WINDOW_FULLSCREEN;
break;
case FULLSCREEN_TYPE_DESKTOP:
if (f.fstype == FULLSCREEN_TYPE_DESKTOP)
sdlflags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
break;
else
{
sdlflags |= SDL_WINDOW_FULLSCREEN;
// Fullscreen window creation will bug out if no mode can be used.
SDL_DisplayMode mode = {0, width, height, 0, 0};
if (SDL_GetClosestDisplayMode(f.display, &mode, &mode) == 0)
return false;
}
}
@@ -373,26 +374,6 @@ int Window::getDisplayCount() const
return SDL_GetNumVideoDisplays();
}
bool Window::checkWindowSize(int width, int height, bool fullscreen, int displayindex) const
{
if (fullscreen)
{
SDL_DisplayMode mode = {}, closest = {};
mode.w = width;
mode.h = height;
SDL_GetClosestDisplayMode(displayindex, &mode, &closest);
return (mode.w == closest.w && mode.h == closest.h);
}
else
{
SDL_DisplayMode mode = {};
SDL_GetDesktopDisplayMode(displayindex, &mode);
return (width <= mode.w && height <= mode.h);
}
}
typedef Window::WindowSize WindowSize;
std::vector<WindowSize> Window::getFullscreenSizes(int displayindex) const
-1
View File
@@ -51,7 +51,6 @@ public:
int getDisplayCount() const;
bool checkWindowSize(int width, int height, bool fullscreen, int displayindex) const;
std::vector<WindowSize> getFullscreenSizes(int displayindex) const;
int getWidth() const;
-29
View File
@@ -34,34 +34,6 @@ int w_getDisplayCount(lua_State *L)
return 1;
}
int w_checkMode(lua_State *L)
{
int w = luaL_checkint(L, 1);
int h = luaL_checkint(L, 2);
bool fs = false;
int displayindex = 0;
if (lua_istable(L, 3))
{
lua_getfield(L, 3, "fullscreen");
fs = luax_toboolean(L, -1);
lua_getfield(L, 3, "display");
displayindex = luaL_optint(L, -1, 1) - 1;
lua_pop(L, 2);
}
else
{
fs = luax_toboolean(L, 3);
displayindex = luaL_optint(L, 4, 1) - 1;
}
luax_pushboolean(L, instance->checkWindowSize(w, h, fs, displayindex));
return 1;
}
int w_setMode(lua_State *L)
{
int w = luaL_checkint(L, 1);
@@ -308,7 +280,6 @@ int w_isVisible(lua_State *L)
static const luaL_Reg functions[] =
{
{ "getDisplayCount", w_getDisplayCount },
{ "checkMode", w_checkMode },
{ "setMode", w_setMode },
{ "getMode", w_getMode },
{ "getFullscreenModes", w_getFullscreenModes },
-1
View File
@@ -30,7 +30,6 @@ namespace window
{
int w_getDisplayCount(lua_State *L);
int w_checkMode(lua_State *L);
int w_setMode(lua_State *L);
int w_getMode(lua_State *L);
int w_getFullscreenModes(lua_State *L);