refine direct3d missing error handling

This commit is contained in:
zeromus 2011-08-21 01:07:58 +00:00
parent cfb2f91292
commit 9418dff3b2
5 changed files with 30 additions and 14 deletions

View File

@ -169,7 +169,7 @@
public int DispMultix = 36;
public int DispMultiy = 0;
public int DispMultianchor = 0;
public bool ForceGDI = false;
public bool DisplayGDI = false;
public bool DisplayStatusBar = true;
// Sound options

View File

@ -1215,7 +1215,7 @@
//
this.forceGDIPPresentationToolStripMenuItem.Name = "forceGDIPPresentationToolStripMenuItem";
this.forceGDIPPresentationToolStripMenuItem.Size = new System.Drawing.Size(220, 22);
this.forceGDIPPresentationToolStripMenuItem.Text = "Force GDI+ Presentation";
this.forceGDIPPresentationToolStripMenuItem.Text = "Use GDI+ Display Method";
this.forceGDIPPresentationToolStripMenuItem.Click += new System.EventHandler(this.forceGDIPPresentationToolStripMenuItem_Click);
//
// runInBackgroundToolStripMenuItem

View File

@ -428,7 +428,7 @@ namespace BizHawk.MultiClient
private void forceGDIPPresentationToolStripMenuItem_Click(object sender, EventArgs e)
{
Global.Config.ForceGDI ^= true;
Global.Config.DisplayGDI ^= true;
SyncPresentationMode();
}
@ -1099,7 +1099,7 @@ namespace BizHawk.MultiClient
saveWindowPositionToolStripMenuItem.Checked = Global.Config.SaveWindowPosition;
startPausedToolStripMenuItem.Checked = Global.Config.StartPaused;
enableRewindToolStripMenuItem.Checked = Global.Config.RewindEnabled;
forceGDIPPresentationToolStripMenuItem.Checked = Global.Config.ForceGDI;
forceGDIPPresentationToolStripMenuItem.Checked = Global.Config.DisplayGDI;
acceptBackgroundInputToolStripMenuItem.Checked = Global.Config.AcceptBackgroundInput;
singleInstanceModeToolStripMenuItem.Checked = Global.Config.SingleInstanceMode;
enableContextMenuToolStripMenuItem.Checked = Global.Config.ShowContextMenu;

View File

@ -237,11 +237,10 @@ namespace BizHawk.MultiClient
void SyncPresentationMode()
{
bool gdi = Global.Config.ForceGDI;
if (Global.Direct3D == null)
{
gdi = Global.Config.ForceGDI = true;
}
bool gdi = Global.Config.DisplayGDI;
if(Global.Direct3D == null)
gdi = true;
if (renderTarget != null)
{
@ -268,7 +267,19 @@ namespace BizHawk.MultiClient
}
else
{
Global.RenderPanel = new Direct3DRenderPanel(Global.Direct3D, renderTarget);
try
{
var d3dPanel = new Direct3DRenderPanel(Global.Direct3D, renderTarget);
d3dPanel.CreateDevice();
Global.RenderPanel = d3dPanel;
}
catch
{
Program.DisplayDirect3DError();
Global.Direct3D.Dispose();
Global.Direct3D = null;
SyncPresentationMode();
}
}
}
@ -1547,6 +1558,7 @@ namespace BizHawk.MultiClient
string fps_string = runloop_last_fps + " fps";
if (ff) fps_string += " >>";
Global.RenderPanel.FPS = fps_string;
Console.WriteLine(fps_string);
}
if (!suppressCaptureRewind && Global.Config.RewindEnabled) CaptureRewindState();

View File

@ -26,10 +26,9 @@ namespace BizHawk.MultiClient
try { Global.Direct3D = new Direct3D(); }
catch
{
//can fallback to GDI rendering
if (Global.Config.ForceGDI == true)
MessageBox.Show("Failure to initialize Directx, reverting to GDI rendering.", "Initialization Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
Global.Config.ForceGDI = true;
//fallback to GDI rendering
if (!Global.Config.DisplayGDI)
DisplayDirect3DError();
}
try
@ -87,5 +86,10 @@ namespace BizHawk.MultiClient
mf.ProgramRunLoop();
}
}
public static void DisplayDirect3DError()
{
MessageBox.Show("Failure to initialize Direct3D, reverting to GDI+ display method. Change the option in Config > GUI or install DirectX web update.", "Initialization Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}