Move GlobalWin.GL to MainForm, passing it through from Program
This commit is contained in:
parent
7bf879c095
commit
8ad3ea9cc6
|
@ -1,4 +1,3 @@
|
|||
using BizHawk.Bizware.BizwareGL;
|
||||
using BizHawk.Client.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
|
@ -11,11 +10,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public static IEmulator Emulator => _mainForm.Emulator;
|
||||
|
||||
/// <summary>
|
||||
/// the IGL to be used for rendering
|
||||
/// </summary>
|
||||
public static IGL GL;
|
||||
|
||||
public static Sound Sound;
|
||||
|
||||
public static Config Config { get; set; }
|
||||
|
|
|
@ -2283,7 +2283,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void DisplayConfigMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
using var window = new DisplayConfig(Config, GlobalWin.GL);
|
||||
using var window = new DisplayConfig(Config, GL);
|
||||
if (window.ShowDialog().IsOk())
|
||||
{
|
||||
DisplayManager.RefreshUserShader();
|
||||
|
|
|
@ -273,7 +273,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
CloseRomContextMenuItem.Image = Properties.Resources.Close;
|
||||
}
|
||||
|
||||
public MainForm(Config config, string[] args)
|
||||
public MainForm(Config config, IGL gl, string[] args)
|
||||
{
|
||||
//do this threaded stuff early so it has plenty of time to run in background
|
||||
Database.InitializeDatabase(Path.Combine(PathUtils.ExeDirectoryPath, "gamedb", "gamedb.txt"));
|
||||
|
@ -282,6 +282,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
GlobalWin._mainForm = this;
|
||||
|
||||
_config = config; // skips assignment to GlobalWin.Config as Program already did that
|
||||
GL = gl;
|
||||
|
||||
InputManager.ControllerInputCoalescer = new ControllerInputCoalescer();
|
||||
FirmwareManager = new FirmwareManager();
|
||||
|
@ -330,7 +331,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
// installed separately on Unix (via package manager or from https://developer.nvidia.com/cg-toolkit-download), look in $PATH
|
||||
_presentationPanel = new PresentationPanel(
|
||||
Config,
|
||||
GlobalWin.GL,
|
||||
GL,
|
||||
ToggleFullscreen,
|
||||
MainForm_MouseClick,
|
||||
MainForm_MouseMove,
|
||||
|
@ -338,7 +339,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
GraphicsControl = { MainWindow = true }
|
||||
};
|
||||
DisplayManager = new DisplayManager(GlobalWin.GL, _presentationPanel, () => DisableSecondaryThrottling);
|
||||
DisplayManager = new DisplayManager(GL, _presentationPanel, () => DisableSecondaryThrottling);
|
||||
Controls.Add(_presentationPanel);
|
||||
Controls.SetChildIndex(_presentationPanel, 0);
|
||||
|
||||
|
@ -862,6 +863,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
set => GlobalWin.Config = base.Config = _config = value;
|
||||
}
|
||||
|
||||
private readonly IGL GL;
|
||||
|
||||
public readonly ToolManager Tools;
|
||||
|
||||
private DisplayManager DisplayManager;
|
||||
|
|
|
@ -191,7 +191,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
GlobalWin.Config.DispMethod = EDispMethod.GdiPlus;
|
||||
}
|
||||
|
||||
GlobalWin.GL = TryInitIGL(GlobalWin.Config.DispMethod);
|
||||
var workingGL = TryInitIGL(GlobalWin.Config.DispMethod);
|
||||
|
||||
if (!OSTC.IsUnixHost)
|
||||
{
|
||||
|
@ -211,7 +211,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
try
|
||||
{
|
||||
InitAndRunSingleInstance(GlobalWin.Config, i => exitCode = i, args);
|
||||
InitAndRunSingleInstance(GlobalWin.Config, workingGL, i => exitCode = i, args);
|
||||
}
|
||||
catch (ObjectDisposedException)
|
||||
{
|
||||
|
@ -220,7 +220,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
else
|
||||
{
|
||||
var mf = new MainForm(GlobalWin.Config, args);
|
||||
var mf = new MainForm(GlobalWin.Config, workingGL, args);
|
||||
// var title = mf.Text;
|
||||
mf.Show();
|
||||
// mf.Text = title;
|
||||
|
@ -253,7 +253,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
GlobalWin.Sound?.Dispose();
|
||||
GlobalWin.Sound = null;
|
||||
GlobalWin.GL.Dispose();
|
||||
workingGL.Dispose();
|
||||
Input.Instance.Adapter.DeInitAll();
|
||||
}
|
||||
|
||||
|
@ -326,13 +326,16 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
private readonly Config _config;
|
||||
|
||||
private readonly IGL _gl;
|
||||
|
||||
private readonly Action<int> _setExitCode;
|
||||
|
||||
private readonly string[] cmdArgs;
|
||||
|
||||
public SingleInstanceController(Config config, Action<int> setExitCode, string[] args)
|
||||
public SingleInstanceController(Config config, IGL gl, Action<int> setExitCode, string[] args)
|
||||
{
|
||||
_config = config;
|
||||
_gl = gl;
|
||||
_setExitCode = setExitCode;
|
||||
cmdArgs = args;
|
||||
IsSingleInstance = true;
|
||||
|
@ -349,7 +352,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
protected override void OnCreateMainForm()
|
||||
{
|
||||
MainForm = new MainForm(_config, cmdArgs);
|
||||
MainForm = new MainForm(_config, _gl, cmdArgs);
|
||||
var title = MainForm.Text;
|
||||
MainForm.Show();
|
||||
MainForm.Text = title;
|
||||
|
@ -357,7 +360,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
private static void InitAndRunSingleInstance(Config config, Action<int> setExitCode, string[] args)
|
||||
=> new SingleInstanceController(config, setExitCode, args).Run();
|
||||
private static void InitAndRunSingleInstance(Config config, IGL gl, Action<int> setExitCode, string[] args)
|
||||
=> new SingleInstanceController(config, gl, setExitCode, args).Run();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue