diff --git a/irr/include/IrrlichtDevice.h b/irr/include/IrrlichtDevice.h index 6ae21a212..d159142c4 100644 --- a/irr/include/IrrlichtDevice.h +++ b/irr/include/IrrlichtDevice.h @@ -16,6 +16,7 @@ #include "IrrCompileConfig.h" #include "position2d.h" #include "SColor.h" // video::ECOLOR_FORMAT +#include #include namespace irr @@ -332,6 +333,12 @@ public: used. */ virtual E_DEVICE_TYPE getType() const = 0; + //! Get the version string of the underlying system (e.g. SDL) + virtual std::string getVersionString() const + { + return ""; + } + //! Get the display density in dots per inch. //! Returns 0.0f on failure. virtual float getDisplayDensity() const = 0; diff --git a/irr/src/CIrrDeviceSDL.h b/irr/src/CIrrDeviceSDL.h index 8a7e5f680..33d97ce56 100644 --- a/irr/src/CIrrDeviceSDL.h +++ b/irr/src/CIrrDeviceSDL.h @@ -109,6 +109,14 @@ public: return EIDT_SDL; } + //! Get the SDL version + std::string getVersionString() const override + { + SDL_version ver; + SDL_GetVersion(&ver); + return std::to_string(ver.major) + "." + std::to_string(ver.minor) + "." + std::to_string(ver.patch); + } + //! Get the display density in dots per inch. float getDisplayDensity() const override; diff --git a/src/script/lua_api/l_mainmenu.cpp b/src/script/lua_api/l_mainmenu.cpp index 7070952e6..240927a4a 100644 --- a/src/script/lua_api/l_mainmenu.cpp +++ b/src/script/lua_api/l_mainmenu.cpp @@ -945,8 +945,9 @@ int ModApiMainMenu::l_get_active_renderer(lua_State *L) /******************************************************************************/ int ModApiMainMenu::l_get_active_irrlicht_device(lua_State *L) { - const char *device_name = [] { - switch (RenderingEngine::get_raw_device()->getType()) { + auto device = RenderingEngine::get_raw_device(); + std::string device_name = [device] { + switch (device->getType()) { case EIDT_WIN32: return "WIN32"; case EIDT_X11: return "X11"; case EIDT_OSX: return "OSX"; @@ -955,7 +956,9 @@ int ModApiMainMenu::l_get_active_irrlicht_device(lua_State *L) default: return "Unknown"; } }(); - lua_pushstring(L, device_name); + if (auto version = device->getVersionString(); !version.empty()) + device_name.append(" " + version); + lua_pushstring(L, device_name.c_str()); return 1; }