1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Add video driver selection to settings menu (based uppon idea from webdesigner97)

This commit is contained in:
sapier 2014-07-16 14:04:50 +02:00
parent 26f4a5c110
commit 996ea60642
5 changed files with 92 additions and 27 deletions

View file

@ -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 <IFileArchive.h>
#include <IFileSystem.h>
@ -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);
}

View file

@ -133,6 +133,8 @@ private:
static int l_download_file(lua_State *L);
static int l_get_video_drivers(lua_State *L);
// async
static int l_do_async_callback(lua_State *L);