assorted cleanup and quick restore of DIspBlurry and Vsync settings
This commit is contained in:
parent
857dff9cf4
commit
25cab541b1
|
@ -45,15 +45,13 @@ namespace BizHawk.Client.EmuHawk
|
||||||
/// <summary>update Global.RenderPanel from the passed IVideoProvider</summary>
|
/// <summary>update Global.RenderPanel from the passed IVideoProvider</summary>
|
||||||
public void UpdateSource(IVideoProvider videoProvider)
|
public void UpdateSource(IVideoProvider videoProvider)
|
||||||
{
|
{
|
||||||
UpdateSourceEx(videoProvider, GlobalWin.RenderPanel);
|
UpdateSourceEx(videoProvider, GlobalWin.PresentationPanel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// update the passed IRenderer with the passed IVideoProvider
|
/// update the passed IRenderer with the passed IVideoProvider
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="videoProvider"></param>
|
public void UpdateSourceEx(IVideoProvider videoProvider, PresentationPanel renderPanel)
|
||||||
/// <param name="renderPanel">also must implement IBlitter</param>
|
|
||||||
public void UpdateSourceEx(IVideoProvider videoProvider, IRenderer renderPanel)
|
|
||||||
{
|
{
|
||||||
var newPendingSurface = sourceSurfaceSet.AllocateSurface(videoProvider.BufferWidth, videoProvider.BufferHeight, false);
|
var newPendingSurface = sourceSurfaceSet.AllocateSurface(videoProvider.BufferWidth, videoProvider.BufferHeight, false);
|
||||||
newPendingSurface.AcceptIntArray(videoProvider.GetVideoBuffer());
|
newPendingSurface.AcceptIntArray(videoProvider.GetVideoBuffer());
|
||||||
|
|
|
@ -10,6 +10,22 @@ using BizHawk.Bizware.BizwareGL;
|
||||||
|
|
||||||
namespace BizHawk.Client.EmuHawk
|
namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
|
class UIMessage
|
||||||
|
{
|
||||||
|
public string Message;
|
||||||
|
public DateTime ExpireAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
class UIDisplay
|
||||||
|
{
|
||||||
|
public string Message;
|
||||||
|
public int X;
|
||||||
|
public int Y;
|
||||||
|
public bool Alert;
|
||||||
|
public int Anchor;
|
||||||
|
public Color ForeColor;
|
||||||
|
public Color BackGround;
|
||||||
|
}
|
||||||
|
|
||||||
public class OSDManager
|
public class OSDManager
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
#endif
|
#endif
|
||||||
public static IGL GL;
|
public static IGL GL;
|
||||||
public static Sound Sound;
|
public static Sound Sound;
|
||||||
public static IRenderer RenderPanel;
|
public static PresentationPanel PresentationPanel;
|
||||||
public static OSDManager OSD = new OSDManager();
|
public static OSDManager OSD = new OSDManager();
|
||||||
public static DisplayManager DisplayManager = new DisplayManager();
|
public static DisplayManager DisplayManager = new DisplayManager();
|
||||||
|
|
||||||
|
|
|
@ -972,7 +972,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
Global.Config.VSyncThrottle = false;
|
Global.Config.VSyncThrottle = false;
|
||||||
if (old)
|
if (old)
|
||||||
{
|
{
|
||||||
GlobalWin.RenderPanel.Resized = true;
|
GlobalWin.PresentationPanel.Resized = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LimitFrameRateMessage();
|
LimitFrameRateMessage();
|
||||||
|
@ -989,7 +989,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
Global.Config.VSyncThrottle = false;
|
Global.Config.VSyncThrottle = false;
|
||||||
if (old)
|
if (old)
|
||||||
{
|
{
|
||||||
GlobalWin.RenderPanel.Resized = true;
|
GlobalWin.PresentationPanel.Resized = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -997,7 +997,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
private void VsyncThrottleMenuItem_Click(object sender, EventArgs e)
|
private void VsyncThrottleMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Global.Config.VSyncThrottle ^= true;
|
Global.Config.VSyncThrottle ^= true;
|
||||||
GlobalWin.RenderPanel.Resized = true;
|
GlobalWin.PresentationPanel.Resized = true;
|
||||||
if (Global.Config.VSyncThrottle)
|
if (Global.Config.VSyncThrottle)
|
||||||
{
|
{
|
||||||
Global.Config.ClockThrottle = false;
|
Global.Config.ClockThrottle = false;
|
||||||
|
@ -1016,7 +1016,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
Global.Config.VSync ^= true;
|
Global.Config.VSync ^= true;
|
||||||
if (!Global.Config.VSyncThrottle) // when vsync throttle is on, vsync is forced to on, so no change to make here
|
if (!Global.Config.VSyncThrottle) // when vsync throttle is on, vsync is forced to on, so no change to make here
|
||||||
{
|
{
|
||||||
GlobalWin.RenderPanel.Resized = true;
|
GlobalWin.PresentationPanel.Resized = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2020,7 +2020,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private void MainForm_Resize(object sender, EventArgs e)
|
private void MainForm_Resize(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
GlobalWin.RenderPanel.Resized = true;
|
GlobalWin.PresentationPanel.Resized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MainForm_Shown(object sender, EventArgs e)
|
private void MainForm_Shown(object sender, EventArgs e)
|
||||||
|
|
|
@ -94,15 +94,9 @@ namespace BizHawk.Client.EmuHawk
|
||||||
Database.LoadDatabase(Path.Combine(PathManager.GetExeDirectoryAbsolute(), "gamedb", "gamedb.txt"));
|
Database.LoadDatabase(Path.Combine(PathManager.GetExeDirectoryAbsolute(), "gamedb", "gamedb.txt"));
|
||||||
|
|
||||||
//TODO GL - a lot of disorganized wiring-up here
|
//TODO GL - a lot of disorganized wiring-up here
|
||||||
var poop = new BizwareGLRenderPanel();
|
GlobalWin.PresentationPanel = new PresentationPanel();
|
||||||
GlobalWin.RenderPanel = poop;
|
Controls.Add(GlobalWin.PresentationPanel);
|
||||||
_renderTarget = poop.GraphicsControl;
|
Controls.SetChildIndex(GlobalWin.PresentationPanel, 0);
|
||||||
poop.GraphicsControl.SetVsync(false);
|
|
||||||
|
|
||||||
Controls.Add(_renderTarget);
|
|
||||||
Controls.SetChildIndex(_renderTarget, 0);
|
|
||||||
_renderTarget.Dock = DockStyle.Fill;
|
|
||||||
_renderTarget.BackColor = Color.Black;
|
|
||||||
|
|
||||||
//TODO GL - move these event handlers somewhere less obnoxious line in the On* overrides
|
//TODO GL - move these event handlers somewhere less obnoxious line in the On* overrides
|
||||||
Load += (o, e) =>
|
Load += (o, e) =>
|
||||||
|
@ -138,9 +132,9 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
ResizeEnd += (o, e) =>
|
ResizeEnd += (o, e) =>
|
||||||
{
|
{
|
||||||
if (GlobalWin.RenderPanel != null)
|
if (GlobalWin.PresentationPanel != null)
|
||||||
{
|
{
|
||||||
GlobalWin.RenderPanel.Resized = true;
|
GlobalWin.PresentationPanel.Resized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GlobalWin.Sound != null)
|
if (GlobalWin.Sound != null)
|
||||||
|
@ -378,7 +372,8 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
UpdateStatusSlots();
|
UpdateStatusSlots();
|
||||||
|
|
||||||
_renderTarget.Paint += (o, e) =>
|
//TODO POOP
|
||||||
|
GlobalWin.PresentationPanel.Control.Paint += (o, e) =>
|
||||||
{
|
{
|
||||||
GlobalWin.DisplayManager.NeedsToPaint = true;
|
GlobalWin.DisplayManager.NeedsToPaint = true;
|
||||||
};
|
};
|
||||||
|
@ -693,8 +688,8 @@ namespace BizHawk.Client.EmuHawk
|
||||||
int zoom = Global.Config.TargetZoomFactor;
|
int zoom = Global.Config.TargetZoomFactor;
|
||||||
var area = Screen.FromControl(this).WorkingArea;
|
var area = Screen.FromControl(this).WorkingArea;
|
||||||
|
|
||||||
int borderWidth = Size.Width - _renderTarget.Size.Width;
|
int borderWidth = Size.Width - GlobalWin.PresentationPanel.Control.Size.Width;
|
||||||
int borderHeight = Size.Height - _renderTarget.Size.Height;
|
int borderHeight = Size.Height - GlobalWin.PresentationPanel.Control.Size.Height;
|
||||||
|
|
||||||
// start at target zoom and work way down until we find acceptable zoom
|
// start at target zoom and work way down until we find acceptable zoom
|
||||||
for (; zoom >= 1; zoom--)
|
for (; zoom >= 1; zoom--)
|
||||||
|
@ -709,7 +704,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
// Change size
|
// Change size
|
||||||
Size = new Size((video.BufferWidth * zoom) + borderWidth, ((video.BufferHeight * zoom) + borderHeight));
|
Size = new Size((video.BufferWidth * zoom) + borderWidth, ((video.BufferHeight * zoom) + borderHeight));
|
||||||
PerformLayout();
|
PerformLayout();
|
||||||
GlobalWin.RenderPanel.Resized = true;
|
GlobalWin.PresentationPanel.Resized = true;
|
||||||
|
|
||||||
// Is window off the screen at this size?
|
// Is window off the screen at this size?
|
||||||
if (area.Contains(Bounds) == false)
|
if (area.Contains(Bounds) == false)
|
||||||
|
@ -739,7 +734,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
MainStatusBar.Visible = false;
|
MainStatusBar.Visible = false;
|
||||||
PerformLayout();
|
PerformLayout();
|
||||||
GlobalWin.RenderPanel.Resized = true;
|
GlobalWin.PresentationPanel.Resized = true;
|
||||||
_inFullscreen = true;
|
_inFullscreen = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -936,7 +931,6 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private int _lastWidth = -1;
|
private int _lastWidth = -1;
|
||||||
private int _lastHeight = -1;
|
private int _lastHeight = -1;
|
||||||
private Control _renderTarget;
|
|
||||||
private readonly SaveSlotManager _stateSlots = new SaveSlotManager();
|
private readonly SaveSlotManager _stateSlots = new SaveSlotManager();
|
||||||
|
|
||||||
// AVI/WAV state
|
// AVI/WAV state
|
||||||
|
|
|
@ -15,32 +15,21 @@ using BizHawk.Bizware.BizwareGL;
|
||||||
|
|
||||||
namespace BizHawk.Client.EmuHawk
|
namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
public interface IRenderer : IDisposable
|
/// <summary>
|
||||||
|
/// Handles the EmuHawk main presentation control - final display only.
|
||||||
|
/// Compositing, filters, etc., should be handled by DisplayManager
|
||||||
|
/// </summary>
|
||||||
|
public class PresentationPanel : IBlitter
|
||||||
{
|
{
|
||||||
void RenderOverlay(DisplaySurface surface);
|
public PresentationPanel()
|
||||||
void Render(BitmapBuffer surface);
|
|
||||||
void Clear(Color color);
|
|
||||||
void Present();
|
|
||||||
bool Resized { get; set; }
|
|
||||||
Size NativeSize { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// convert coordinates. this is a dumb name
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="p">desktop coordinates</param>
|
|
||||||
/// <returns>ivideoprovider coordinates</returns>
|
|
||||||
sd.Point ScreenToScreen(sd.Point p);
|
|
||||||
}
|
|
||||||
|
|
||||||
//you might think it's cool to make this reusable for other windows, but it's probably a pipe dream. dont even try it. at least, refactor it into a simple render panel and some kind of NicePresentationWindow class
|
|
||||||
public class BizwareGLRenderPanel : IRenderer, IBlitter
|
|
||||||
{
|
|
||||||
|
|
||||||
public BizwareGLRenderPanel()
|
|
||||||
{
|
{
|
||||||
GL = GlobalWin.GL;
|
GL = GlobalWin.GL;
|
||||||
|
|
||||||
GraphicsControl = GL.CreateGraphicsControl();
|
GraphicsControl = GL.CreateGraphicsControl();
|
||||||
|
GraphicsControl.Control.Dock = DockStyle.Fill;
|
||||||
|
GraphicsControl.Control.BackColor = Color.Black;
|
||||||
|
|
||||||
|
//prepare a renderer
|
||||||
Renderer = new GuiRenderer(GL);
|
Renderer = new GuiRenderer(GL);
|
||||||
|
|
||||||
//pass through these events to the form. we might need a more scalable solution for mousedown etc. for zapper and whatnot.
|
//pass through these events to the form. we might need a more scalable solution for mousedown etc. for zapper and whatnot.
|
||||||
|
@ -64,6 +53,14 @@ namespace BizHawk.Client.EmuHawk
|
||||||
//gl shouldnt be disposed! it should be a global resource! probably managed elsewhere
|
//gl shouldnt be disposed! it should be a global resource! probably managed elsewhere
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Control Control { get { return GraphicsControl.Control; } }
|
||||||
|
public static implicit operator Control(PresentationPanel self) { return self.GraphicsControl.Control; }
|
||||||
|
StringRenderer TheOneFont;
|
||||||
|
public Bizware.BizwareGL.GraphicsControl GraphicsControl;
|
||||||
|
static Bizware.BizwareGL.IGL GL;
|
||||||
|
GuiRenderer Renderer;
|
||||||
|
Texture2d LastSurfaceTexture;
|
||||||
|
|
||||||
private void HandleFullscreenToggle(object sender, MouseEventArgs e)
|
private void HandleFullscreenToggle(object sender, MouseEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.Button == MouseButtons.Left)
|
if (e.Button == MouseButtons.Left)
|
||||||
|
@ -105,12 +102,6 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
public sd.Rectangle ClipBounds { get; set; }
|
public sd.Rectangle ClipBounds { get; set; }
|
||||||
|
|
||||||
StringRenderer TheOneFont;
|
|
||||||
public Bizware.BizwareGL.GraphicsControl GraphicsControl;
|
|
||||||
static Bizware.BizwareGL.IGL GL;
|
|
||||||
GuiRenderer Renderer;
|
|
||||||
Texture2d LastSurfaceTexture;
|
|
||||||
|
|
||||||
public bool Resized { get; set; }
|
public bool Resized { get; set; }
|
||||||
|
|
||||||
public void Clear(Color color)
|
public void Clear(Color color)
|
||||||
|
@ -153,9 +144,11 @@ namespace BizHawk.Client.EmuHawk
|
||||||
int sw=1, sh=1;
|
int sw=1, sh=1;
|
||||||
public void RenderExec(BitmapBuffer surface, DisplaySurface displaySurface)
|
public void RenderExec(BitmapBuffer surface, DisplaySurface displaySurface)
|
||||||
{
|
{
|
||||||
|
GraphicsControl.Begin();
|
||||||
|
|
||||||
if (Resized || Vsync != VsyncRequested)
|
if (Resized || Vsync != VsyncRequested)
|
||||||
{
|
{
|
||||||
//recreate device
|
GraphicsControl.SetVsync(VsyncRequested);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool overlay = false;
|
bool overlay = false;
|
||||||
|
@ -169,13 +162,18 @@ namespace BizHawk.Client.EmuHawk
|
||||||
if (sw != surface.Width || sh != surface.Height || LastSurfaceTexture == null)
|
if (sw != surface.Width || sh != surface.Height || LastSurfaceTexture == null)
|
||||||
{
|
{
|
||||||
LastSurfaceTexture = GL.LoadTexture(surface);
|
LastSurfaceTexture = GL.LoadTexture(surface);
|
||||||
LastSurfaceTexture.SetFilterNearest();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GL.LoadTextureData(LastSurfaceTexture, surface);
|
GL.LoadTextureData(LastSurfaceTexture, surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(Global.Config.DispBlurry)
|
||||||
|
LastSurfaceTexture.SetFilterLinear();
|
||||||
|
else
|
||||||
|
LastSurfaceTexture.SetFilterNearest();
|
||||||
|
|
||||||
|
|
||||||
sw = surface.Width;
|
sw = surface.Width;
|
||||||
sh = surface.Height;
|
sh = surface.Height;
|
||||||
|
|
||||||
|
@ -190,10 +188,9 @@ namespace BizHawk.Client.EmuHawk
|
||||||
float dx = (int)((vw - finalScale * surface.Width)/2);
|
float dx = (int)((vw - finalScale * surface.Width)/2);
|
||||||
float dy = (int)((vh - finalScale * surface.Height)/2);
|
float dy = (int)((vh - finalScale * surface.Height)/2);
|
||||||
|
|
||||||
GraphicsControl.Begin();
|
|
||||||
if (!overlay)
|
if (!overlay)
|
||||||
{
|
{
|
||||||
GL.ClearColor(Color.Black); //TODO set from background color
|
GL.ClearColor(Color.Black); //TODO GL - set from background color
|
||||||
GL.Clear(ClearBufferMask.ColorBufferBit);
|
GL.Clear(ClearBufferMask.ColorBufferBit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,6 +202,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
Renderer.Modelview.Scale(finalScale);
|
Renderer.Modelview.Scale(finalScale);
|
||||||
Renderer.Draw(LastSurfaceTexture);
|
Renderer.Draw(LastSurfaceTexture);
|
||||||
Renderer.End();
|
Renderer.End();
|
||||||
|
|
||||||
GraphicsControl.End();
|
GraphicsControl.End();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -221,8 +219,6 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public interface IBlitter
|
public interface IBlitter
|
||||||
{
|
{
|
||||||
void Open();
|
void Open();
|
||||||
|
@ -235,22 +231,4 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
public interface IBlitterFont { }
|
public interface IBlitterFont { }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class UIMessage
|
|
||||||
{
|
|
||||||
public string Message;
|
|
||||||
public DateTime ExpireAt;
|
|
||||||
}
|
|
||||||
|
|
||||||
class UIDisplay
|
|
||||||
{
|
|
||||||
public string Message;
|
|
||||||
public int X;
|
|
||||||
public int Y;
|
|
||||||
public bool Alert;
|
|
||||||
public int Anchor;
|
|
||||||
public Color ForeColor;
|
|
||||||
public Color BackGround;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -238,7 +238,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
)]
|
)]
|
||||||
public static int ScreenHeight()
|
public static int ScreenHeight()
|
||||||
{
|
{
|
||||||
return GlobalWin.RenderPanel.NativeSize.Height;
|
return GlobalWin.PresentationPanel.NativeSize.Height;
|
||||||
}
|
}
|
||||||
|
|
||||||
[LuaMethodAttributes(
|
[LuaMethodAttributes(
|
||||||
|
@ -306,7 +306,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
)]
|
)]
|
||||||
public static int ScreenWidth()
|
public static int ScreenWidth()
|
||||||
{
|
{
|
||||||
return GlobalWin.RenderPanel.NativeSize.Width;
|
return GlobalWin.PresentationPanel.NativeSize.Width;
|
||||||
}
|
}
|
||||||
|
|
||||||
[LuaMethodAttributes(
|
[LuaMethodAttributes(
|
||||||
|
|
|
@ -40,7 +40,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
var buttons = _lua.NewTable();
|
var buttons = _lua.NewTable();
|
||||||
//TODO - ZEROMUS - this could use a more sophisticated system, it's just a stopgap
|
//TODO - ZEROMUS - this could use a more sophisticated system, it's just a stopgap
|
||||||
var p = GlobalWin.RenderPanel.ScreenToScreen(Control.MousePosition);
|
var p = GlobalWin.PresentationPanel.ScreenToScreen(Control.MousePosition);
|
||||||
buttons["X"] = p.X;
|
buttons["X"] = p.X;
|
||||||
buttons["Y"] = p.Y;
|
buttons["Y"] = p.Y;
|
||||||
buttons[MouseButtons.Left.ToString()] = (Control.MouseButtons & MouseButtons.Left) != 0;
|
buttons[MouseButtons.Left.ToString()] = (Control.MouseButtons & MouseButtons.Left) != 0;
|
||||||
|
|
Loading…
Reference in New Issue