diff options
author | kwolekr <kwolekr@minetest.net> | 2015-01-18 13:14:25 -0500 |
---|---|---|
committer | kwolekr <kwolekr@minetest.net> | 2015-01-18 13:24:25 -0500 |
commit | 976d0b2caa3f69c0b7c40e98517073e08e87774d (patch) | |
tree | 8af2e586e32eed924e42e8d5aab6a33737fc6a18 /src/script | |
parent | 44e4f5ab6e20689f7106b957de62a1d7737cb28f (diff) | |
download | minetest-976d0b2caa3f69c0b7c40e98517073e08e87774d.tar.gz minetest-976d0b2caa3f69c0b7c40e98517073e08e87774d.tar.bz2 minetest-976d0b2caa3f69c0b7c40e98517073e08e87774d.zip |
Reorganize supported video driver query mechanisms
Diffstat (limited to 'src/script')
-rw-r--r-- | src/script/lua_api/l_mainmenu.cpp | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/src/script/lua_api/l_mainmenu.cpp b/src/script/lua_api/l_mainmenu.cpp index 572b8efc8..c8389d889 100644 --- a/src/script/lua_api/l_mainmenu.cpp +++ b/src/script/lua_api/l_mainmenu.cpp @@ -1025,28 +1025,25 @@ int ModApiMainMenu::l_download_file(lua_State *L) /******************************************************************************/ 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); - } + std::vector<irr::video::E_DRIVER_TYPE> drivers + = porting::getSupportedVideoDrivers(); + + lua_newtable(L); + for (u32 i = 0; i != drivers.size(); i++) { + const char *name = porting::getVideoDriverName(drivers[i]); + const char *fname = porting::getVideoDriverFriendlyName(drivers[i]); + + lua_newtable(L); + lua_pushstring(L, name); + lua_setfield(L, -2, "name"); + lua_pushstring(L, fname); + lua_setfield(L, -2, "friendly_name"); + + lua_rawseti(L, -2, i + 1); } return 1; |