summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp54
-rw-r--r--src/script/lua_api/l_mainmenu.cpp32
-rw-r--r--src/script/lua_api/l_mainmenu.h2
3 files changed, 62 insertions, 26 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 1b91edd21..9d336825e 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1365,41 +1365,43 @@ int main(int argc, char *argv[])
u16 fsaa = g_settings->getU16("fsaa");
// Determine driver
-
- video::E_DRIVER_TYPE driverType;
-
- std::string driverstring = g_settings->get("video_driver");
-
- if (driverstring == "null")
- driverType = video::EDT_NULL;
- else if (driverstring == "software")
- driverType = video::EDT_SOFTWARE;
- else if (driverstring == "burningsvideo")
- driverType = video::EDT_BURNINGSVIDEO;
- else if (driverstring == "direct3d8")
- driverType = video::EDT_DIRECT3D8;
- else if (driverstring == "direct3d9")
- driverType = video::EDT_DIRECT3D9;
- else if (driverstring == "opengl")
- driverType = video::EDT_OPENGL;
+ video::E_DRIVER_TYPE driverType = video::EDT_OPENGL;
+ static const char* driverids[] = {
+ "null",
+ "software",
+ "burningsvideo",
+ "direct3d8",
+ "direct3d9",
+ "opengl"
#ifdef _IRR_COMPILE_WITH_OGLES1_
- else if (driverstring == "ogles1")
- driverType = video::EDT_OGLES1;
+ ,"ogles1"
#endif
#ifdef _IRR_COMPILE_WITH_OGLES2_
- else if (driverstring == "ogles2")
- driverType = video::EDT_OGLES2;
+ ,"ogles2"
#endif
- else {
- errorstream << "WARNING: Invalid video_driver specified; defaulting "
- << "to opengl" << std::endl;
- driverType = video::EDT_OPENGL;
+ ,"invalid"
+ };
+
+ std::string driverstring = g_settings->get("video_driver");
+ for (unsigned int i = 0;
+ i < (sizeof(driverids)/sizeof(driverids[0]));
+ i++)
+ {
+ if (strcasecmp(driverstring.c_str(), driverids[i]) == 0) {
+ driverType = (video::E_DRIVER_TYPE) i;
+ break;
+ }
+
+ if (strcasecmp("invalid", driverids[i]) == 0) {
+ errorstream << "WARNING: Invalid video_driver specified; defaulting "
+ << "to opengl" << std::endl;
+ break;
+ }
}
/*
List video modes if requested
*/
-
MyEventReceiver* receiver = new MyEventReceiver();
if (cmd_args.getFlag("videomodes")) {
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 <IFileArchive.h>
#include <IFileSystem.h>
@@ -1002,6 +1003,36 @@ 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);
+ }
+ }
+
+ return 1;
+}
+
+/******************************************************************************/
int ModApiMainMenu::l_gettext(lua_State *L)
{
std::wstring wtext = wstrgettext((std::string) luaL_checkstring(L, 1));
@@ -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);
}
diff --git a/src/script/lua_api/l_mainmenu.h b/src/script/lua_api/l_mainmenu.h
index 7a9cafd1f..1783a3f7f 100644
--- a/src/script/lua_api/l_mainmenu.h
+++ b/src/script/lua_api/l_mainmenu.h
@@ -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);