diff --git a/src/modules/graphics/Graphics.cpp b/src/modules/graphics/Graphics.cpp index a7d66f73e..c8c68ba80 100644 --- a/src/modules/graphics/Graphics.cpp +++ b/src/modules/graphics/Graphics.cpp @@ -149,10 +149,7 @@ StringMap Graphics::lineJoins( StringMap::Entry Graphics::supportEntries[] = { - { "hdrcanvas", Graphics::SUPPORT_HDR_CANVAS }, { "multicanvas", Graphics::SUPPORT_MULTI_CANVAS }, - { "dxt", Graphics::SUPPORT_DXT }, - { "bc5", Graphics::SUPPORT_BC5 }, { "srgb", Graphics::SUPPORT_SRGB }, }; diff --git a/src/modules/graphics/Graphics.h b/src/modules/graphics/Graphics.h index 19ad5e314..725f27534 100644 --- a/src/modules/graphics/Graphics.h +++ b/src/modules/graphics/Graphics.h @@ -82,10 +82,7 @@ public: enum Support { - SUPPORT_HDR_CANVAS, SUPPORT_MULTI_CANVAS, - SUPPORT_DXT, - SUPPORT_BC5, SUPPORT_SRGB, SUPPORT_MAX_ENUM }; diff --git a/src/modules/graphics/opengl/Graphics.cpp b/src/modules/graphics/opengl/Graphics.cpp index 1c93df0f8..bc1a274de 100644 --- a/src/modules/graphics/opengl/Graphics.cpp +++ b/src/modules/graphics/opengl/Graphics.cpp @@ -1116,14 +1116,8 @@ bool Graphics::isSupported(Support feature) const { switch (feature) { - case SUPPORT_HDR_CANVAS: - return Canvas::isFormatSupported(Canvas::FORMAT_HDR); case SUPPORT_MULTI_CANVAS: 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: // sRGB support for the screen is guaranteed if it's supported as a // Canvas format. diff --git a/src/modules/graphics/opengl/wrap_Graphics.cpp b/src/modules/graphics/opengl/wrap_Graphics.cpp index 63f2ab03b..5ccc529a1 100644 --- a/src/modules/graphics/opengl/wrap_Graphics.cpp +++ b/src/modules/graphics/opengl/wrap_Graphics.cpp @@ -957,25 +957,22 @@ int w_getShader(lua_State *L) 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; } @@ -1032,15 +1029,22 @@ int w_getRendererInfo(lua_State *L) 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; } @@ -1392,11 +1396,11 @@ static const luaL_Reg functions[] = { "setShader", w_setShader }, { "getShader", w_getShader }, - { "isSupported", w_isSupported }, + { "getSupported", w_getSupported }, { "getCanvasFormats", w_getCanvasFormats }, { "getCompressedImageFormats", w_getCompressedImageFormats }, { "getRendererInfo", w_getRendererInfo }, - { "getSystemLimit", w_getSystemLimit }, + { "getSystemLimits", w_getSystemLimits }, { "draw", w_draw }, diff --git a/src/modules/graphics/opengl/wrap_Graphics.h b/src/modules/graphics/opengl/wrap_Graphics.h index 6eb793c01..5fdfaed52 100644 --- a/src/modules/graphics/opengl/wrap_Graphics.h +++ b/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_setShader(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_getCompressedImageFormats(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_print(lua_State *L); int w_printf(lua_State *L);