Add code to switch render driver at runtime
This commit is contained in:
parent
6a24b5cb0e
commit
47011140a5
@ -692,6 +692,10 @@ namespace UserConfigParams
|
|||||||
PARAM_DEFAULT( FloatUserConfigParam(3, "font_size",
|
PARAM_DEFAULT( FloatUserConfigParam(3, "font_size",
|
||||||
&m_video_group, "The size of fonts. 0 is the smallest and 6 is the biggest") );
|
&m_video_group, "The size of fonts. 0 is the smallest and 6 is the biggest") );
|
||||||
|
|
||||||
|
PARAM_PREFIX StringUserConfigParam m_render_driver
|
||||||
|
PARAM_DEFAULT( StringUserConfigParam("gl", "render_driver",
|
||||||
|
&m_video_group, "Render video driver to use, at the moment gl or directx9 is supported.") );
|
||||||
|
|
||||||
// ---- Recording
|
// ---- Recording
|
||||||
PARAM_PREFIX GroupUserConfigParam m_recording_group
|
PARAM_PREFIX GroupUserConfigParam m_recording_group
|
||||||
PARAM_DEFAULT(GroupUserConfigParam("Recording",
|
PARAM_DEFAULT(GroupUserConfigParam("Recording",
|
||||||
|
@ -388,6 +388,31 @@ void IrrDriver::initDevice()
|
|||||||
{
|
{
|
||||||
SIrrlichtCreationParameters params;
|
SIrrlichtCreationParameters params;
|
||||||
|
|
||||||
|
video::E_DRIVER_TYPE driver_created = video::EDT_NULL;
|
||||||
|
if (std::string(UserConfigParams::m_render_driver) == "gl")
|
||||||
|
{
|
||||||
|
#if defined(USE_GLES2)
|
||||||
|
driver_created = video::EDT_OGLES2;
|
||||||
|
#else
|
||||||
|
driver_created = video::EDT_OPENGL;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else if (std::string(UserConfigParams::m_render_driver) == "directx9")
|
||||||
|
{
|
||||||
|
driver_created = video::EDT_DIRECT3D9;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Log::warn("IrrDriver", "Unknown driver %s, revert to gl",
|
||||||
|
UserConfigParams::m_render_driver.c_str());
|
||||||
|
UserConfigParams::m_render_driver.revertToDefaults();
|
||||||
|
#if defined(USE_GLES2)
|
||||||
|
driver_created = video::EDT_OGLES2;
|
||||||
|
#else
|
||||||
|
driver_created = video::EDT_OPENGL;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef __SWITCH__
|
#ifndef __SWITCH__
|
||||||
// If --no-graphics option was used, the null device can still be used.
|
// If --no-graphics option was used, the null device can still be used.
|
||||||
if (!GUIEngine::isNoGraphics())
|
if (!GUIEngine::isNoGraphics())
|
||||||
@ -481,11 +506,7 @@ void IrrDriver::initDevice()
|
|||||||
Log::verbose("irr_driver", "Trying to create device with "
|
Log::verbose("irr_driver", "Trying to create device with "
|
||||||
"%i bits\n", bits);
|
"%i bits\n", bits);
|
||||||
|
|
||||||
#if defined(USE_GLES2)
|
params.DriverType = driver_created;
|
||||||
params.DriverType = video::EDT_OGLES2;
|
|
||||||
#else
|
|
||||||
params.DriverType = video::EDT_OPENGL;
|
|
||||||
#endif
|
|
||||||
params.PrivateData = NULL;
|
params.PrivateData = NULL;
|
||||||
params.Stencilbuffer = false;
|
params.Stencilbuffer = false;
|
||||||
params.Bits = bits;
|
params.Bits = bits;
|
||||||
@ -543,11 +564,7 @@ void IrrDriver::initDevice()
|
|||||||
{
|
{
|
||||||
UserConfigParams::m_width = MIN_SUPPORTED_WIDTH;
|
UserConfigParams::m_width = MIN_SUPPORTED_WIDTH;
|
||||||
UserConfigParams::m_height = MIN_SUPPORTED_HEIGHT;
|
UserConfigParams::m_height = MIN_SUPPORTED_HEIGHT;
|
||||||
#if defined(USE_GLES2)
|
m_device = createDevice(driver_created,
|
||||||
m_device = createDevice(video::EDT_OGLES2,
|
|
||||||
#else
|
|
||||||
m_device = createDevice(video::EDT_OPENGL,
|
|
||||||
#endif
|
|
||||||
core::dimension2du(UserConfigParams::m_width,
|
core::dimension2du(UserConfigParams::m_width,
|
||||||
UserConfigParams::m_height ),
|
UserConfigParams::m_height ),
|
||||||
32, //bits per pixel
|
32, //bits per pixel
|
||||||
|
@ -684,6 +684,7 @@ void cmdLineHelp()
|
|||||||
" Takes precedence over trilinear or bilinear\n"
|
" Takes precedence over trilinear or bilinear\n"
|
||||||
" texture filtering.\n"
|
" texture filtering.\n"
|
||||||
" --shadows=n Set resolution of shadows (0 to disable).\n"
|
" --shadows=n Set resolution of shadows (0 to disable).\n"
|
||||||
|
" --render-driver=n Render driver to use (gl or directx9).\n"
|
||||||
" --apitrace This will disable buffer storage and\n"
|
" --apitrace This will disable buffer storage and\n"
|
||||||
" writing gpu query strings to opengl, which\n"
|
" writing gpu query strings to opengl, which\n"
|
||||||
" can be seen later in apitrace.\n"
|
" can be seen later in apitrace.\n"
|
||||||
@ -836,6 +837,8 @@ int handleCmdLinePreliminary()
|
|||||||
stk_config->load(file_manager->getAsset(s));
|
stk_config->load(file_manager->getAsset(s));
|
||||||
Log::info("main", "STK config will be read from %s.",s.c_str());
|
Log::info("main", "STK config will be read from %s.",s.c_str());
|
||||||
}
|
}
|
||||||
|
if(CommandLine::has("--render-driver", &s))
|
||||||
|
UserConfigParams::m_render_driver = s;
|
||||||
if(CommandLine::has("--trackdir", &s))
|
if(CommandLine::has("--trackdir", &s))
|
||||||
TrackManager::addTrackSearchDir(s);
|
TrackManager::addTrackSearchDir(s);
|
||||||
if(CommandLine::has("--kartdir", &s))
|
if(CommandLine::has("--kartdir", &s))
|
||||||
|
Loading…
Reference in New Issue
Block a user