--------------------------------------------------------------------------------
+local filters = {
+ {"No Filter,Bilinear Filter,Trilinear Filter"},
+ {"", "bilinear_filter", "trilinear_filter"},
+}
+
+local mipmap = {
+ {"No Mipmap,Mipmap,Mipmap + Aniso. Filter"},
+ {"", "mip_map", "anisotropic_filter"},
+}
+
+local function getFilterSettingIndex()
+ if (core.setting_get(filters[2][3]) == "true") then
+ return 3
+ end
+ if (core.setting_get(filters[2][3]) == "false" and core.setting_get(filters[2][2]) == "true") then
+ return 2
+ end
+ return 1
+end
+
+local function getMipmapSettingIndex()
+ if (core.setting_get(mipmap[2][3]) == "true") then
+ return 3
+ end
+ if (core.setting_get(mipmap[2][3]) == "false" and core.setting_get(mipmap[2][2]) == "true") then
+ return 2
+ end
+ return 1
+end
+
+local function video_driver_fname_to_name(selected_driver)
+ local video_drivers = core.get_video_drivers()
+
+ for i=1, #video_drivers do
+ if selected_driver == video_drivers[i].friendly_name then
+ return video_drivers[i].name:lower()
+ end
+ end
+
+ return ""
+end
+
local function dlg_confirm_reset_formspec(data)
local retval =
"size[8,3]" ..
end
local function gui_scale_to_scrollbar()
-
local current_value = tonumber(core.setting_get("gui_scaling"))
if (current_value == nil) or current_value < 0.25 then
return 0
end
-
if current_value <= 1.25 then
return ((current_value - 0.25)/ 1.0) * 700
end
-
if current_value <= 6 then
return ((current_value -1.25) * 100) + 700
end
end
local function scrollbar_to_gui_scale(value)
-
value = tonumber(value)
if (value <= 700) then
return ((value / 700) * 1.0) + 0.25
end
-
if (value <=1000) then
return ((value - 700) / 100) + 1.25
end
local function formspec(tabview, name, tabdata)
local video_drivers = core.get_video_drivers()
-
- local video_driver_string = ""
- local current_video_driver_idx = 0
- local current_video_driver = core.setting_get("video_driver")
- for i=1, #video_drivers, 1 do
-
- if i ~= 1 then
- video_driver_string = video_driver_string .. ","
+ local current_video_driver = core.setting_get("video_driver"):lower()
+
+ local driver_formspec_string = ""
+ local driver_current_idx = 0
+
+ for i=2, #video_drivers do
+ driver_formspec_string = driver_formspec_string .. video_drivers[i].friendly_name
+ if i ~= #video_drivers then
+ driver_formspec_string = driver_formspec_string .. ","
end
- video_driver_string = video_driver_string .. video_drivers[i]
- local video_driver = string.gsub(video_drivers[i], " ", "")
- if current_video_driver:lower() == video_driver:lower() then
- current_video_driver_idx = i
+ if current_video_driver == video_drivers[i].name:lower() then
+ driver_current_idx = i - 1
end
end
-local filters = {
- {"No Filter,Bilinear Filter,Trilinear Filter"},
- {"", "bilinear_filter", "trilinear_filter"},
-}
-
-local mipmap = {
- {"No Mipmap,Mipmap,Mipmap + Aniso. Filter"},
- {"", "mip_map", "anisotropic_filter"},
-}
-
-local function getFilterSettingIndex()
- if (core.setting_get(filters[2][3]) == "true") then
- return 3
- end
- if (core.setting_get(filters[2][3]) == "false" and core.setting_get(filters[2][2]) == "true") then
- return 2
- end
- return 1
-end
-
-local function getMipmapSettingIndex()
- if (core.setting_get(mipmap[2][3]) == "true") then
- return 3
- end
- if (core.setting_get(mipmap[2][3]) == "false" and core.setting_get(mipmap[2][2]) == "true") then
- return 2
- end
- return 1
-end
-
local tab_string =
"box[0,0;3.5,3.9;#999999]" ..
"checkbox[0.25,0;cb_smooth_lighting;".. fgettext("Smooth Lighting")
.. getMipmapSettingIndex() .. "]" ..
"label[3.85,2.15;".. fgettext("Rendering:") .. "]"..
"dropdown[3.85,2.6;3.85;dd_video_driver;"
- .. video_driver_string .. ";" .. current_video_driver_idx .. "]" ..
+ .. driver_formspec_string .. ";" .. driver_current_idx .. "]" ..
"tooltip[dd_video_driver;" ..
fgettext("Restart minetest for driver change to take effect") .. "]" ..
"box[7.75,0;4,4;#999999]" ..
core.setting_set("touchscreen_threshold",fields["dd_touchthreshold"])
ddhandled = true
end
+
if fields["dd_video_driver"] then
- local video_driver = string.gsub(fields["dd_video_driver"], " ", "")
- core.setting_set("video_driver",string.lower(video_driver))
+ core.setting_set("video_driver",
+ video_driver_fname_to_name(fields["dd_video_driver"]))
ddhandled = true
end
if fields["dd_filters"] == "No Filter" then
caption = fgettext("Settings"),
cbf_formspec = formspec,
cbf_button_handler = handle_settings_buttons
- }
+}
bool ClientLauncher::create_engine_device(int log_level)
{
- static const char *driverids[] = {
- "null",
- "software",
- "burningsvideo",
- "direct3d8",
- "direct3d9",
- "opengl"
-#ifdef _IRR_COMPILE_WITH_OGLES1_
- ,"ogles1"
-#endif
-#ifdef _IRR_COMPILE_WITH_OGLES2_
- ,"ogles2"
-#endif
- ,"invalid"
- };
-
static const irr::ELOG_LEVEL irr_log_level[5] = {
ELL_NONE,
ELL_ERROR,
// Determine driver
video::E_DRIVER_TYPE driverType = video::EDT_OPENGL;
-
std::string driverstring = g_settings->get("video_driver");
- for (size_t 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;
+ std::vector<video::E_DRIVER_TYPE> drivers
+ = porting::getSupportedVideoDrivers();
+ u32 i;
+ for (i = 0; i != drivers.size(); i++) {
+ if (!strcasecmp(driverstring.c_str(),
+ porting::getVideoDriverName(drivers[i]))) {
+ driverType = drivers[i];
break;
}
}
+ if (i == drivers.size()) {
+ errorstream << "Invalid video_driver specified; "
+ "defaulting to opengl" << std::endl;
+ }
SIrrlichtCreationParameters params = SIrrlichtCreationParameters();
params.DriverType = driverType;
#endif // RUN_IN_PLACE
}
-static irr::IrrlichtDevice* device;
+static irr::IrrlichtDevice *device;
-void initIrrlicht(irr::IrrlichtDevice * _device) {
- device = _device;
+void initIrrlicht(irr::IrrlichtDevice *device_)
+{
+ device = device_;
}
void setXorgClassHint(const video::SExposedVideoData &video_data,
const std::string &name)
{
#ifdef XORG_USED
+ if (video_data.OpenGLLinux.X11Display == NULL)
+ return;
+
XClassHint *classhint = XAllocClassHint();
classhint->res_name = (char *)name.c_str();
classhint->res_class = (char *)name.c_str();
return device->getVideoDriver()->getScreenSize();
}
+
+std::vector<core::vector3d<u32> > getVideoModes()
+{
+ std::vector<core::vector3d<u32> > mlist;
+ video::IVideoModeList *modelist = device->getVideoModeList();
+
+ u32 num_modes = modelist->getVideoModeCount();
+ for (u32 i = 0; i != num_modes; i++) {
+ core::dimension2d<u32> mode_res = modelist->getVideoModeResolution(i);
+ s32 mode_depth = modelist->getVideoModeDepth(i);
+ mlist.push_back(core::vector3d<u32>(mode_res.Width, mode_res.Height, mode_depth));
+ }
+
+ return mlist;
+}
+
+std::vector<irr::video::E_DRIVER_TYPE> getSupportedVideoDrivers()
+{
+ std::vector<irr::video::E_DRIVER_TYPE> drivers;
+
+ for (int i = 0; i != irr::video::EDT_COUNT; i++) {
+ if (irr::IrrlichtDevice::isDriverSupported((irr::video::E_DRIVER_TYPE)i))
+ drivers.push_back((irr::video::E_DRIVER_TYPE)i);
+ }
+
+ return drivers;
+}
+
+const char *getVideoDriverName(irr::video::E_DRIVER_TYPE type)
+{
+ static const char *driver_ids[] = {
+ "null",
+ "software",
+ "burningsvideo",
+ "direct3d8",
+ "direct3d9",
+ "opengl",
+ "ogles1",
+ "ogles2",
+ };
+
+ return driver_ids[type];
+}
+
+
+const char *getVideoDriverFriendlyName(irr::video::E_DRIVER_TYPE type)
+{
+ static const char *driver_names[] = {
+ "NULL Driver",
+ "Software Renderer",
+ "Burning's Video",
+ "Direct3D 8",
+ "Direct3D 9",
+ "OpenGL",
+ "OpenGL ES1",
+ "OpenGL ES2",
+ };
+
+ return driver_names[type];
+}
+
+
#ifndef __ANDROID__
#ifdef XORG_USED
float getDisplayDensity()
/******************************************************************************/
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;