Browse Source

Replaced love.graphics.isSupported and love.graphics.getSystemLimit with love.graphics.getSupported and love.graphics.getSystemLimits, which return tables with graphics feature / system limit enum names as keys, and support status / limit numbers as values.

Removed the 'hdrcanvas', 'dxt', and 'bc5' graphics feature enums now that they're deprecated in 0.9.x in favour of getCanvasFormats and getCompressedImageFormats.

--HG--
branch : minor
Alex Szpakowski 11 years ago
parent
commit
a1d67f0788

+ 0 - 3
src/modules/graphics/Graphics.cpp

@@ -149,10 +149,7 @@ StringMap<Graphics::LineJoin, Graphics::LINE_JOIN_MAX_ENUM> Graphics::lineJoins(
 
 
 StringMap<Graphics::Support, Graphics::SUPPORT_MAX_ENUM>::Entry Graphics::supportEntries[] =
 StringMap<Graphics::Support, Graphics::SUPPORT_MAX_ENUM>::Entry Graphics::supportEntries[] =
 {
 {
-	{ "hdrcanvas", Graphics::SUPPORT_HDR_CANVAS },
 	{ "multicanvas", Graphics::SUPPORT_MULTI_CANVAS },
 	{ "multicanvas", Graphics::SUPPORT_MULTI_CANVAS },
-	{ "dxt", Graphics::SUPPORT_DXT },
-	{ "bc5", Graphics::SUPPORT_BC5 },
 	{ "srgb", Graphics::SUPPORT_SRGB },
 	{ "srgb", Graphics::SUPPORT_SRGB },
 };
 };
 
 

+ 0 - 3
src/modules/graphics/Graphics.h

@@ -82,10 +82,7 @@ public:
 
 
 	enum Support
 	enum Support
 	{
 	{
-		SUPPORT_HDR_CANVAS,
 		SUPPORT_MULTI_CANVAS,
 		SUPPORT_MULTI_CANVAS,
-		SUPPORT_DXT,
-		SUPPORT_BC5,
 		SUPPORT_SRGB,
 		SUPPORT_SRGB,
 		SUPPORT_MAX_ENUM
 		SUPPORT_MAX_ENUM
 	};
 	};

+ 0 - 6
src/modules/graphics/opengl/Graphics.cpp

@@ -1116,14 +1116,8 @@ bool Graphics::isSupported(Support feature) const
 {
 {
 	switch (feature)
 	switch (feature)
 	{
 	{
-	case SUPPORT_HDR_CANVAS:
-		return Canvas::isFormatSupported(Canvas::FORMAT_HDR);
 	case SUPPORT_MULTI_CANVAS:
 	case SUPPORT_MULTI_CANVAS:
 		return Canvas::isMultiCanvasSupported();
 		return Canvas::isMultiCanvasSupported();
-	case SUPPORT_DXT:
-		return Image::hasCompressedTextureSupport(image::CompressedData::FORMAT_DXT5);
-	case SUPPORT_BC5:
-		return Image::hasCompressedTextureSupport(image::CompressedData::FORMAT_BC5);
 	case SUPPORT_SRGB:
 	case SUPPORT_SRGB:
 		// sRGB support for the screen is guaranteed if it's supported as a
 		// sRGB support for the screen is guaranteed if it's supported as a
 		// Canvas format.
 		// Canvas format.

+ 25 - 21
src/modules/graphics/opengl/wrap_Graphics.cpp

@@ -957,25 +957,22 @@ int w_getShader(lua_State *L)
 	return 1;
 	return 1;
 }
 }
 
 
-int w_isSupported(lua_State *L)
+int w_getSupported(lua_State *L)
 {
 {
-	bool supported = true;
+	lua_createtable(L, 0, (int) Graphics::SUPPORT_MAX_ENUM);
 
 
-	for (int i = 1; i <= lua_gettop(L); i++)
+	for (int i = 0; i < (int) Graphics::SUPPORT_MAX_ENUM; i++)
 	{
 	{
-		const char *str = luaL_checkstring(L, i);
-		Graphics::Support feature;
-		if (!Graphics::getConstant(str, feature))
-			return luaL_error(L, "Invalid graphics feature: %s", str);
+		Graphics::Support feature = (Graphics::Support) i;
+		const char *name = nullptr;
 
 
-		if (!instance->isSupported(feature))
-		{
-			supported = false;
-			break;
-		}
+		if (!Graphics::getConstant(feature, name))
+			continue;
+
+		luax_pushboolean(L, instance->isSupported(feature));
+		lua_setfield(L, -2, name);
 	}
 	}
 
 
-	luax_pushboolean(L, supported);
 	return 1;
 	return 1;
 }
 }
 
 
@@ -1032,15 +1029,22 @@ int w_getRendererInfo(lua_State *L)
 	return 4;
 	return 4;
 }
 }
 
 
-int w_getSystemLimit(lua_State *L)
+int w_getSystemLimits(lua_State *L)
 {
 {
-	const char *limitstr = luaL_checkstring(L, 1);
-	Graphics::SystemLimit limittype;
+	lua_createtable(L, 0, (int) Graphics::LIMIT_MAX_ENUM);
 
 
-	if (!Graphics::getConstant(limitstr, limittype))
-		return luaL_error(L, "Invalid system limit type: %s", limitstr);
+	for (int i = 0; i < (int) Graphics::LIMIT_MAX_ENUM; i++)
+	{
+		Graphics::SystemLimit limittype = (Graphics::SystemLimit) i;
+		const char *name = nullptr;
+
+		if (!Graphics::getConstant(limittype, name))
+			continue;
+
+		lua_pushnumber(L, instance->getSystemLimit(limittype));
+		lua_setfield(L, -2, name);
+	}
 
 
-	lua_pushnumber(L, instance->getSystemLimit(limittype));
 	return 1;
 	return 1;
 }
 }
 
 
@@ -1392,11 +1396,11 @@ static const luaL_Reg functions[] =
 	{ "setShader", w_setShader },
 	{ "setShader", w_setShader },
 	{ "getShader", w_getShader },
 	{ "getShader", w_getShader },
 
 
-	{ "isSupported", w_isSupported },
+	{ "getSupported", w_getSupported },
 	{ "getCanvasFormats", w_getCanvasFormats },
 	{ "getCanvasFormats", w_getCanvasFormats },
 	{ "getCompressedImageFormats", w_getCompressedImageFormats },
 	{ "getCompressedImageFormats", w_getCompressedImageFormats },
 	{ "getRendererInfo", w_getRendererInfo },
 	{ "getRendererInfo", w_getRendererInfo },
-	{ "getSystemLimit", w_getSystemLimit },
+	{ "getSystemLimits", w_getSystemLimits },
 
 
 	{ "draw", w_draw },
 	{ "draw", w_draw },
 
 

+ 2 - 2
src/modules/graphics/opengl/wrap_Graphics.h

@@ -88,11 +88,11 @@ int w_setCanvas(lua_State *L);
 int w_getCanvas(lua_State *L);
 int w_getCanvas(lua_State *L);
 int w_setShader(lua_State *L);
 int w_setShader(lua_State *L);
 int w_getShader(lua_State *L);
 int w_getShader(lua_State *L);
-int w_isSupported(lua_State *L);
+int w_getSupported(lua_State *L);
 int w_getCanvasFormats(lua_State *L);
 int w_getCanvasFormats(lua_State *L);
 int w_getCompressedImageFormats(lua_State *L);
 int w_getCompressedImageFormats(lua_State *L);
 int w_getRendererInfo(lua_State *L);
 int w_getRendererInfo(lua_State *L);
-int w_getSystemLimit(lua_State *L);
+int w_getSystemLimits(lua_State *L);
 int w_draw(lua_State *L);
 int w_draw(lua_State *L);
 int w_print(lua_State *L);
 int w_print(lua_State *L);
 int w_printf(lua_State *L);
 int w_printf(lua_State *L);