Merge pull request #1119 from GiuseppeGorgoglione/master

BGFX: fix crash when bgfx effect folder is not present or incomplete
This commit is contained in:
Vas Crabb 2016-07-19 02:07:06 +10:00 committed by GitHub
commit 1c363eeff0
3 changed files with 22 additions and 2 deletions

View File

@ -235,6 +235,12 @@ int renderer_bgfx::create()
m_screen_effect[2] = m_effects->effect("screen_multiply");
m_screen_effect[3] = m_effects->effect("screen_add");
if ( m_gui_effect[0] == nullptr || m_gui_effect[1] == nullptr || m_gui_effect[2] == nullptr || m_gui_effect[3] == nullptr ||
m_screen_effect[0] == nullptr || m_screen_effect[1] == nullptr || m_screen_effect[2] == nullptr || m_screen_effect[3] == nullptr)
{
fatalerror("BGFX: Unable to load required shaders. Please check and reinstall the %s folder\n", m_options.bgfx_path());
}
m_chains = new chain_manager(win->machine(), m_options, *m_textures, *m_targets, *m_effects, win->m_index, *this);
m_sliders_dirty = true;
@ -283,6 +289,20 @@ void renderer_bgfx::record()
}
}
bool renderer_bgfx::init(running_machine &machine)
{
const char *bgfx_path = downcast<osd_options &>(machine.options()).bgfx_path();
osd::directory::ptr directory = osd::directory::open(bgfx_path);
if (directory == nullptr)
{
osd_printf_verbose("Unable to find the %s folder. Please reinstall it to use the BGFX renderer\n", bgfx_path);
return true;
}
return false;
}
void renderer_bgfx::exit()
{
imguiDestroy();

View File

@ -36,7 +36,7 @@ public:
renderer_bgfx(std::shared_ptr<osd_window> w);
virtual ~renderer_bgfx();
static void init(running_machine &machine) { }
static bool init(running_machine &machine);
static void exit();
virtual int create() override;

View File

@ -172,7 +172,7 @@ bool windows_osd_interface::window_init()
error = renderer_gdi::init(machine());
break;
case VIDEO_MODE_BGFX:
renderer_bgfx::init(machine());
error = renderer_bgfx::init(machine());
break;
#if (USE_OPENGL)
case VIDEO_MODE_OPENGL: