mirror of
https://github.com/minetest/minetest.git
synced 2024-11-27 01:53:45 +01:00
Move video_driver default selection to runtime
This commit is contained in:
parent
67068cfaf4
commit
c26e122485
@ -171,7 +171,7 @@ local function formspec(tabview, name, tabdata)
|
||||
.. getSettingIndex.Antialiasing() .. "]" ..
|
||||
"box[8,0;3.75,4.5;#999999]"
|
||||
|
||||
local video_driver = core.settings:get("video_driver")
|
||||
local video_driver = core.get_active_driver()
|
||||
local shaders_enabled = core.settings:get_bool("enable_shaders")
|
||||
if video_driver == "opengl" then
|
||||
tab_string = tab_string ..
|
||||
|
@ -1664,7 +1664,7 @@ shader_path (Shader path) path
|
||||
# Note: A restart is required after changing this!
|
||||
# OpenGL is the default for desktop, and OGLES2 for Android.
|
||||
# Shaders are supported by OpenGL and OGLES2 (experimental).
|
||||
video_driver (Video driver) enum opengl opengl,ogles1,ogles2
|
||||
video_driver (Video driver) enum opengl,ogles1,ogles2,
|
||||
|
||||
# Distance in nodes at which transparency depth sorting is enabled
|
||||
# Use this to limit the performance impact of transparency depth sorting
|
||||
|
@ -203,7 +203,10 @@ GUI
|
||||
will be added to fieldname value is set to formname itself
|
||||
* if `is_file_select` is `true`, a file and not a folder will be selected
|
||||
* returns nil or selected file/folder
|
||||
* `core.get_active_renderer()`: Ex: "OpenGL 4.6".
|
||||
* `core.get_active_driver()`:
|
||||
* technical name of active video driver, e.g. "opengl"
|
||||
* `core.get_active_renderer()`:
|
||||
* name of current renderer, e.g. "OpenGL 4.6"
|
||||
* `core.get_window_info()`: Same as server-side `get_player_window_information` API.
|
||||
|
||||
-- Note that none of these things are constant, they are likely to change
|
||||
|
@ -99,22 +99,27 @@ RenderingEngine::RenderingEngine(IEventReceiver *receiver)
|
||||
u16 fsaa = g_settings->getU16("fsaa");
|
||||
|
||||
// Determine driver
|
||||
video::E_DRIVER_TYPE driverType = video::EDT_OPENGL;
|
||||
video::E_DRIVER_TYPE driverType;
|
||||
const std::string &driverstring = g_settings->get("video_driver");
|
||||
std::vector<video::E_DRIVER_TYPE> drivers =
|
||||
RenderingEngine::getSupportedVideoDrivers();
|
||||
u32 i;
|
||||
for (i = 0; i != drivers.size(); i++) {
|
||||
if (!strcasecmp(driverstring.c_str(),
|
||||
RenderingEngine::getVideoDriverInfo(drivers[i]).name.c_str())) {
|
||||
auto &driverinfo = RenderingEngine::getVideoDriverInfo(drivers[i]);
|
||||
if (!strcasecmp(driverstring.c_str(), driverinfo.name.c_str())) {
|
||||
driverType = drivers[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == drivers.size()) {
|
||||
errorstream << "Invalid video_driver specified; "
|
||||
"defaulting to opengl"
|
||||
<< std::endl;
|
||||
driverType = drivers.at(0);
|
||||
auto &name = RenderingEngine::getVideoDriverInfo(driverType).name;
|
||||
if (driverstring.empty()) {
|
||||
infostream << "Defaulting to video_driver = " << name << std::endl;
|
||||
} else {
|
||||
errorstream << "Invalid video_driver specified; defaulting to "
|
||||
<< name << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
SIrrlichtCreationParameters params = SIrrlichtCreationParameters();
|
||||
@ -517,20 +522,20 @@ void RenderingEngine::draw_menu_scene(gui::IGUIEnvironment *guienv,
|
||||
get_video_driver()->endScene();
|
||||
}
|
||||
|
||||
std::vector<irr::video::E_DRIVER_TYPE> RenderingEngine::getSupportedVideoDrivers()
|
||||
std::vector<video::E_DRIVER_TYPE> RenderingEngine::getSupportedVideoDrivers()
|
||||
{
|
||||
// Only check these drivers.
|
||||
// We do not support software and D3D in any capacity.
|
||||
static const irr::video::E_DRIVER_TYPE glDrivers[4] = {
|
||||
irr::video::EDT_NULL,
|
||||
irr::video::EDT_OPENGL,
|
||||
irr::video::EDT_OGLES1,
|
||||
irr::video::EDT_OGLES2,
|
||||
// Only check these drivers. We do not support software and D3D in any capacity.
|
||||
// Order by preference (best first)
|
||||
static const video::E_DRIVER_TYPE glDrivers[] = {
|
||||
video::EDT_OPENGL,
|
||||
video::EDT_OGLES2,
|
||||
video::EDT_OGLES1,
|
||||
video::EDT_NULL,
|
||||
};
|
||||
std::vector<irr::video::E_DRIVER_TYPE> drivers;
|
||||
std::vector<video::E_DRIVER_TYPE> drivers;
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (irr::IrrlichtDevice::isDriverSupported(glDrivers[i]))
|
||||
for (u32 i = 0; i < ARRLEN(glDrivers); i++) {
|
||||
if (IrrlichtDevice::isDriverSupported(glDrivers[i]))
|
||||
drivers.push_back(glDrivers[i]);
|
||||
}
|
||||
|
||||
|
@ -700,7 +700,7 @@ ShadowRenderer *createShadowRenderer(IrrlichtDevice *device, Client *client)
|
||||
{
|
||||
// disable if unsupported
|
||||
if (g_settings->getBool("enable_dynamic_shadows") && (
|
||||
g_settings->get("video_driver") != "opengl" ||
|
||||
device->getVideoDriver()->getDriverType() != video::EDT_OPENGL ||
|
||||
!g_settings->getBool("enable_shaders"))) {
|
||||
g_settings->setBool("enable_dynamic_shadows", false);
|
||||
}
|
||||
|
@ -207,11 +207,7 @@ void set_default_settings()
|
||||
settings->setDefault("lighting_boost_spread", "0.2");
|
||||
settings->setDefault("texture_path", "");
|
||||
settings->setDefault("shader_path", "");
|
||||
#if ENABLE_GLES
|
||||
settings->setDefault("video_driver", "ogles2");
|
||||
#else
|
||||
settings->setDefault("video_driver", "opengl");
|
||||
#endif
|
||||
settings->setDefault("video_driver", "");
|
||||
settings->setDefault("cinematic", "false");
|
||||
settings->setDefault("camera_smoothing", "0");
|
||||
settings->setDefault("cinematic_camera_smoothing", "0.7");
|
||||
|
@ -894,7 +894,7 @@ int ModApiMainMenu::l_download_file(lua_State *L)
|
||||
/******************************************************************************/
|
||||
int ModApiMainMenu::l_get_video_drivers(lua_State *L)
|
||||
{
|
||||
std::vector<irr::video::E_DRIVER_TYPE> drivers = RenderingEngine::getSupportedVideoDrivers();
|
||||
auto drivers = RenderingEngine::getSupportedVideoDrivers();
|
||||
|
||||
lua_newtable(L);
|
||||
for (u32 i = 0; i != drivers.size(); i++) {
|
||||
@ -953,6 +953,13 @@ int ModApiMainMenu::l_get_window_info(lua_State *L)
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
int ModApiMainMenu::l_get_active_driver(lua_State *L)
|
||||
{
|
||||
auto drivertype = RenderingEngine::get_video_driver()->getDriverType();
|
||||
lua_pushstring(L, RenderingEngine::getVideoDriverInfo(drivertype).name.c_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int ModApiMainMenu::l_get_active_renderer(lua_State *L)
|
||||
{
|
||||
@ -1102,6 +1109,7 @@ void ModApiMainMenu::Initialize(lua_State *L, int top)
|
||||
API_FCT(gettext);
|
||||
API_FCT(get_video_drivers);
|
||||
API_FCT(get_window_info);
|
||||
API_FCT(get_active_driver);
|
||||
API_FCT(get_active_renderer);
|
||||
API_FCT(get_min_supp_proto);
|
||||
API_FCT(get_max_supp_proto);
|
||||
|
@ -106,6 +106,8 @@ private:
|
||||
|
||||
static int l_get_window_info(lua_State *L);
|
||||
|
||||
static int l_get_active_driver(lua_State *L);
|
||||
|
||||
static int l_get_active_renderer(lua_State *L);
|
||||
|
||||
//filesystem
|
||||
|
Loading…
Reference in New Issue
Block a user