From 996ea60642c5d78fc915573af0641d78bc7e2d49 Mon Sep 17 00:00:00 2001 From: sapier Date: Wed, 16 Jul 2014 14:04:50 +0200 Subject: Add video driver selection to settings menu (based uppon idea from webdesigner97) --- src/script/lua_api/l_mainmenu.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src/script/lua_api/l_mainmenu.cpp') diff --git a/src/script/lua_api/l_mainmenu.cpp b/src/script/lua_api/l_mainmenu.cpp index ae2fddf6d..1760d2794 100644 --- a/src/script/lua_api/l_mainmenu.cpp +++ b/src/script/lua_api/l_mainmenu.cpp @@ -34,6 +34,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "sound.h" #include "settings.h" #include "main.h" // for g_settings +#include "EDriverTypes.h" #include #include @@ -1001,6 +1002,36 @@ int ModApiMainMenu::l_download_file(lua_State *L) return 1; } +/******************************************************************************/ +int ModApiMainMenu::l_get_video_drivers(lua_State *L) +{ + static const char* drivernames[] = { + "NULL Driver", + "Software", + "Burningsvideo", + "Direct3D 8", + "Direct3D 9", + "OpenGL", + "OGLES1", + "OGLES2" + }; + unsigned int index = 1; + lua_newtable(L); + int top = lua_gettop(L); + + for (unsigned int i = irr::video::EDT_SOFTWARE; + i < MYMIN(irr::video::EDT_COUNT, (sizeof(drivernames)/sizeof(drivernames[0]))); + i++) { + if (irr::IrrlichtDevice::isDriverSupported((irr::video::E_DRIVER_TYPE) i)) { + lua_pushnumber(L,index++); + lua_pushstring(L,drivernames[i]); + lua_settable(L, top); + } + } + + return 1; +} + /******************************************************************************/ int ModApiMainMenu::l_gettext(lua_State *L) { @@ -1094,6 +1125,7 @@ void ModApiMainMenu::Initialize(lua_State *L, int top) API_FCT(sound_play); API_FCT(sound_stop); API_FCT(gettext); + API_FCT(get_video_drivers); API_FCT(get_screen_info); API_FCT(do_async_callback); } -- cgit v1.2.3