fix displaymanager crashes when rebooting snes9x (and maybe others) while paused (due to unset virtualsize).

This commit is contained in:
zeromus 2017-07-27 22:42:13 -05:00
parent b5db09dea9
commit 94e2fe2a10
2 changed files with 30 additions and 1 deletions

View File

@ -722,6 +722,16 @@ namespace BizHawk.Client.EmuHawk
return filterProgram;
}
public void Blank()
{
GL.BeginScene();
GL.BindRenderTarget(null);
GL.SetClearColor(Color.Black);
GL.Clear(OpenTK.Graphics.OpenGL.ClearBufferMask.ColorBufferBit);
GL.EndScene();
presentationPanel.GraphicsControl.SwapBuffers();
}
void UpdateSourceDrawingWork(JobInfo job)
{
bool vsync = false;

View File

@ -1970,14 +1970,32 @@ namespace BizHawk.Client.EmuHawk
var video = _currentVideoProvider;
Size currVideoSize = new Size(video.BufferWidth, video.BufferHeight);
Size currVirtualSize = new Size(video.VirtualWidth, video.VirtualHeight);
bool resizeFramebuffer = false;
if (currVideoSize != _lastVideoSize || currVirtualSize != _lastVirtualSize)
resizeFramebuffer = true;
bool isZero = false;
if (currVideoSize.Width == 0 || currVideoSize.Height == 0 || currVirtualSize.Width == 0 || currVirtualSize.Height == 0)
isZero = true;
//don't resize if the new size is 0 somehow; we'll wait until we have a sensible size
if(isZero)
resizeFramebuffer = false;
if(resizeFramebuffer)
{
_lastVideoSize = currVideoSize;
_lastVirtualSize = currVirtualSize;
FrameBufferResized();
}
GlobalWin.DisplayManager.UpdateSource(video);
//rendering flakes out egregiously if we have a zero size
//can we fix it later not to?
if(isZero)
GlobalWin.DisplayManager.Blank();
else
GlobalWin.DisplayManager.UpdateSource(video);
}
// sends a simulation of a plain alt key keystroke
@ -3627,6 +3645,7 @@ namespace BizHawk.Client.EmuHawk
UpdateDumpIcon();
SetMainformMovieInfo();
CurrentlyOpenRomArgs = args;
GlobalWin.DisplayManager.Blank();
Global.Rewinder.Initialize();