summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd/modules/lib/osdobj_common.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/osd/modules/lib/osdobj_common.cpp')
-rw-r--r--src/osd/modules/lib/osdobj_common.cpp105
1 files changed, 50 insertions, 55 deletions
diff --git a/src/osd/modules/lib/osdobj_common.cpp b/src/osd/modules/lib/osdobj_common.cpp
index de6c0a4f2fd..92eacddc739 100644
--- a/src/osd/modules/lib/osdobj_common.cpp
+++ b/src/osd/modules/lib/osdobj_common.cpp
@@ -10,12 +10,14 @@
#include "osdobj_common.h"
+#include "modules/osdwindow.h"
#include "modules/debugger/debug_module.h"
#include "modules/font/font_module.h"
#include "modules/input/input_module.h"
#include "modules/midi/midi_module.h"
#include "modules/monitor/monitor_module.h"
#include "modules/netdev/netdev_module.h"
+#include "modules/render/render_module.h"
#include "modules/sound/sound_module.h"
#include "osdnet.h"
@@ -66,7 +68,6 @@ const options_entry osd_options::s_option_entries[] =
{ OSDOPTION_BENCH, "0", core_options::option_type::INTEGER, "benchmark for the given number of emulated seconds; implies -video none -sound none -nothrottle" },
{ nullptr, nullptr, core_options::option_type::HEADER, "OSD VIDEO OPTIONS" },
-// OS X can be trusted to have working hardware OpenGL, so default to it on for the best user experience
{ OSDOPTION_VIDEO, OSDOPTVAL_AUTO, core_options::option_type::STRING, "video output method: " },
{ OSDOPTION_NUMSCREENS "(1-4)", "1", core_options::option_type::INTEGER, "number of output screens/windows to create; usually, you want just one" },
{ OSDOPTION_WINDOW ";w", "0", core_options::option_type::BOOLEAN, "enable window mode; otherwise, full screen mode is assumed" },
@@ -181,7 +182,7 @@ const options_entry osd_options::s_option_entries[] =
{ OSDOPTION_BGFX_LUT, "lut-default.png", core_options::option_type::STRING, "LUT texture name" },
{ OSDOPTION_BGFX_AVI_NAME, OSDOPTVAL_AUTO, core_options::option_type::PATH, "filename for BGFX output logging" },
- // End of list
+ // End of list
{ nullptr }
};
@@ -192,7 +193,7 @@ osd_options::osd_options()
}
// Window list
-std::list<std::shared_ptr<osd_window>> osd_common_t::s_window_list;
+std::list<std::unique_ptr<osd_window> > osd_common_t::s_window_list;
//-------------------------------------------------
// osd_interface - constructor
@@ -237,6 +238,26 @@ void osd_common_t::register_options()
REGISTER_MODULE(m_mod_man, FONT_SDL);
REGISTER_MODULE(m_mod_man, FONT_NONE);
+#if defined(SDLMAME_EMSCRIPTEN)
+ REGISTER_MODULE(m_mod_man, RENDERER_SDL1); // don't bother trying to use video acceleration in browsers
+#endif
+#if defined(OSD_WINDOWS)
+ REGISTER_MODULE(m_mod_man, RENDERER_D3D); // this is only built for OSD=windows, there's no dummy stub
+#endif
+#if defined(OSD_WINDOWS) || defined(SDLMAME_WIN32)
+ REGISTER_MODULE(m_mod_man, RENDERER_BGFX); // try BGFX before GDI on windows to get DirectX 10/11 acceleration
+#endif
+ REGISTER_MODULE(m_mod_man, RENDERER_GDI); // GDI ahead of OpenGL as there's a chance Windows has no OpenGL
+ REGISTER_MODULE(m_mod_man, RENDERER_OPENGL);
+#if !defined(OSD_WINDOWS) && !defined(SDLMAME_WIN32)
+ REGISTER_MODULE(m_mod_man, RENDERER_BGFX); // try BGFX after OpenGL on other operating systems for now
+#endif
+ REGISTER_MODULE(m_mod_man, RENDERER_SDL2);
+#if !defined(SDLMAME_EMSCRIPTEN)
+ REGISTER_MODULE(m_mod_man, RENDERER_SDL1);
+#endif
+ REGISTER_MODULE(m_mod_man, RENDERER_NONE);
+
REGISTER_MODULE(m_mod_man, SOUND_DSOUND);
REGISTER_MODULE(m_mod_man, SOUND_XAUDIO2);
REGISTER_MODULE(m_mod_man, SOUND_COREAUDIO);
@@ -306,23 +327,18 @@ void osd_common_t::register_options()
// after initialization we know which modules are supported
-
- update_option(OSD_MONITOR_PROVIDER, m_mod_man.get_module_names(OSD_MONITOR_PROVIDER));
update_option(OSD_FONT_PROVIDER, m_mod_man.get_module_names(OSD_FONT_PROVIDER));
+ update_option(OSD_RENDERER_PROVIDER, m_mod_man.get_module_names(OSD_RENDERER_PROVIDER));
+ update_option(OSD_SOUND_PROVIDER, m_mod_man.get_module_names(OSD_SOUND_PROVIDER));
+ update_option(OSD_MONITOR_PROVIDER, m_mod_man.get_module_names(OSD_MONITOR_PROVIDER));
update_option(OSD_KEYBOARDINPUT_PROVIDER, m_mod_man.get_module_names(OSD_KEYBOARDINPUT_PROVIDER));
update_option(OSD_MOUSEINPUT_PROVIDER, m_mod_man.get_module_names(OSD_MOUSEINPUT_PROVIDER));
update_option(OSD_LIGHTGUNINPUT_PROVIDER, m_mod_man.get_module_names(OSD_LIGHTGUNINPUT_PROVIDER));
update_option(OSD_JOYSTICKINPUT_PROVIDER, m_mod_man.get_module_names(OSD_JOYSTICKINPUT_PROVIDER));
- update_option(OSD_SOUND_PROVIDER, m_mod_man.get_module_names(OSD_SOUND_PROVIDER));
update_option(OSD_MIDI_PROVIDER, m_mod_man.get_module_names(OSD_MIDI_PROVIDER));
update_option(OSD_NETDEV_PROVIDER, m_mod_man.get_module_names(OSD_NETDEV_PROVIDER));
update_option(OSD_DEBUG_PROVIDER, m_mod_man.get_module_names(OSD_DEBUG_PROVIDER));
update_option(OSD_OUTPUT_PROVIDER, m_mod_man.get_module_names(OSD_OUTPUT_PROVIDER));
-
- // Register video options and update options
- video_options_add("none", nullptr);
- video_register();
- update_option(OSDOPTION_VIDEO, m_video_names);
}
void osd_common_t::update_option(const std::string &key, std::vector<std::string_view> const &values)
@@ -575,28 +591,18 @@ bool osd_common_t::execute_command(const char *command)
{
if (strcmp(command, OSDCOMMAND_LIST_NETWORK_ADAPTERS) == 0)
{
- osd_module *om = select_module_options(options(), OSD_NETDEV_PROVIDER);
-
- if (om->probe())
- {
- om->init(*this, options());
- osd_list_network_adapters();
- om->exit();
- }
+ osd_module &om = select_module_options<osd_module>(OSD_NETDEV_PROVIDER);
+ osd_list_network_adapters();
+ om.exit();
return true;
}
else if (strcmp(command, OSDCOMMAND_LIST_MIDI_DEVICES) == 0)
{
- osd_module *om = select_module_options(options(), OSD_MIDI_PROVIDER);
- auto *pm = select_module_options<midi_module *>(options(), OSD_MIDI_PROVIDER);
+ osd_module &om = select_module_options<osd_module>(OSD_MIDI_PROVIDER);
+ dynamic_cast<midi_module &>(om).list_midi_devices();
+ om.exit();
- if (om->probe())
- {
- om->init(*this, options());
- pm->list_midi_devices();
- om->exit();
- }
return true;
}
@@ -612,10 +618,10 @@ static void output_notifier_callback(const char *outname, int32_t value, void *p
void osd_common_t::init_subsystems()
{
// monitors have to be initialized before video init
- m_monitor_module = select_module_options<monitor_module *>(options(), OSD_MONITOR_PROVIDER);
- assert(m_monitor_module != nullptr);
- m_monitor_module->init(*this, options());
+ m_monitor_module = &select_module_options<monitor_module>(OSD_MONITOR_PROVIDER);
+ // various modules depend on having a window handle
+ m_render = &select_module_options<render_module>(OSD_RENDERER_PROVIDER);
if (!video_init())
{
video_exit();
@@ -625,28 +631,23 @@ void osd_common_t::init_subsystems()
exit(-1);
}
- m_keyboard_input = select_module_options<input_module *>(options(), OSD_KEYBOARDINPUT_PROVIDER);
- m_mouse_input = select_module_options<input_module *>(options(), OSD_MOUSEINPUT_PROVIDER);
- m_lightgun_input = select_module_options<input_module *>(options(), OSD_LIGHTGUNINPUT_PROVIDER);
- m_joystick_input = select_module_options<input_module *>(options(), OSD_JOYSTICKINPUT_PROVIDER);
+ m_keyboard_input = &select_module_options<input_module>(OSD_KEYBOARDINPUT_PROVIDER);
+ m_mouse_input = &select_module_options<input_module>(OSD_MOUSEINPUT_PROVIDER);
+ m_lightgun_input = &select_module_options<input_module>(OSD_LIGHTGUNINPUT_PROVIDER);
+ m_joystick_input = &select_module_options<input_module>(OSD_JOYSTICKINPUT_PROVIDER);
- m_font_module = select_module_options<font_module *>(options(), OSD_FONT_PROVIDER);
- m_sound = select_module_options<sound_module *>(options(), OSD_SOUND_PROVIDER);
- m_sound->m_sample_rate = options().sample_rate();
- m_sound->m_audio_latency = options().audio_latency();
+ m_font_module = &select_module_options<font_module>(OSD_FONT_PROVIDER);
+ m_sound = &select_module_options<sound_module>(OSD_SOUND_PROVIDER);
- m_debugger = select_module_options<debug_module *>(options(), OSD_DEBUG_PROVIDER);
+ m_debugger = &select_module_options<debug_module>(OSD_DEBUG_PROVIDER);
- select_module_options<netdev_module *>(options(), OSD_NETDEV_PROVIDER);
+ select_module_options<netdev_module>(OSD_NETDEV_PROVIDER);
- m_midi = select_module_options<midi_module *>(options(), OSD_MIDI_PROVIDER);
+ m_midi = &select_module_options<midi_module>(OSD_MIDI_PROVIDER);
- m_output = select_module_options<output_module *>(options(), OSD_OUTPUT_PROVIDER);
- m_output->set_machine(&machine());
+ m_output = &select_module_options<output_module>(OSD_OUTPUT_PROVIDER);
machine().output().set_global_notifier(output_notifier_callback, this);
- m_mod_man.init(*this, options());
-
input_init();
}
@@ -665,10 +666,6 @@ bool osd_common_t::no_sound()
return (strcmp(options().sound(),"none")==0) ? true : false;
}
-void osd_common_t::video_register()
-{
-}
-
bool osd_common_t::input_init()
{
m_keyboard_input->input_init(machine());
@@ -693,17 +690,15 @@ void osd_common_t::window_exit()
void osd_common_t::osd_exit()
{
+ // destroy the renderers before shutting down their parent module
+ for (auto const &window : s_window_list)
+ window->renderer_reset();
+
m_mod_man.exit();
exit_subsystems();
}
-void osd_common_t::video_options_add(const char *name, void *type)
-{
- //m_video_options.add(name, type, false);
- m_video_names.push_back(name);
-}
-
osd_font::ptr osd_common_t::font_alloc()
{
return m_font_module->font_alloc();