some small cleanup
This commit is contained in:
parent
7417ea7b8f
commit
857dff9cf4
|
@ -1,8 +1,7 @@
|
||||||
using SlimDX.Direct3D9;
|
using BizHawk.Client.Common;
|
||||||
|
using BizHawk.Bizware.BizwareGL;
|
||||||
using SlimDX.DirectSound;
|
using SlimDX.DirectSound;
|
||||||
|
|
||||||
using BizHawk.Client.Common;
|
|
||||||
|
|
||||||
namespace BizHawk.Client.EmuHawk
|
namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
public static class GlobalWin
|
public static class GlobalWin
|
||||||
|
@ -11,8 +10,8 @@ namespace BizHawk.Client.EmuHawk
|
||||||
public static ToolManager Tools;
|
public static ToolManager Tools;
|
||||||
#if WINDOWS
|
#if WINDOWS
|
||||||
public static DirectSound DSound;
|
public static DirectSound DSound;
|
||||||
public static Direct3D Direct3D;
|
|
||||||
#endif
|
#endif
|
||||||
|
public static IGL GL;
|
||||||
public static Sound Sound;
|
public static Sound Sound;
|
||||||
public static IRenderer RenderPanel;
|
public static IRenderer RenderPanel;
|
||||||
public static OSDManager OSD = new OSDManager();
|
public static OSDManager OSD = new OSDManager();
|
||||||
|
|
|
@ -1341,69 +1341,6 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// private void SyncPresentationMode()
|
|
||||||
// {
|
|
||||||
// GlobalWin.DisplayManager.Suspend();
|
|
||||||
|
|
||||||
//#if WINDOWS
|
|
||||||
// bool gdi = Global.Config.DisplayGDI || GlobalWin.Direct3D == null;
|
|
||||||
//#endif
|
|
||||||
// if (_renderTarget != null)
|
|
||||||
// {
|
|
||||||
// _renderTarget.Dispose();
|
|
||||||
// Controls.Remove(_renderTarget);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (_retainedPanel != null)
|
|
||||||
// {
|
|
||||||
// _retainedPanel.Dispose();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (GlobalWin.RenderPanel != null)
|
|
||||||
// {
|
|
||||||
// GlobalWin.RenderPanel.Dispose();
|
|
||||||
// }
|
|
||||||
|
|
||||||
//#if WINDOWS
|
|
||||||
// if (gdi)
|
|
||||||
//#endif
|
|
||||||
// _renderTarget = _retainedPanel = new RetainedViewportPanel();
|
|
||||||
//#if WINDOWS
|
|
||||||
// else _renderTarget = new ViewportPanel();
|
|
||||||
//#endif
|
|
||||||
// Controls.Add(_renderTarget);
|
|
||||||
// Controls.SetChildIndex(_renderTarget, 0);
|
|
||||||
|
|
||||||
// _renderTarget.Dock = DockStyle.Fill;
|
|
||||||
// _renderTarget.BackColor = Color.Black;
|
|
||||||
|
|
||||||
//#if WINDOWS
|
|
||||||
// if (gdi)
|
|
||||||
// {
|
|
||||||
//#endif
|
|
||||||
// GlobalWin.RenderPanel = new SysdrawingRenderPanel(_retainedPanel);
|
|
||||||
// _retainedPanel.ActivateThreaded();
|
|
||||||
//#if WINDOWS
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// var d3dPanel = new BizwareGLRenderPanel(_renderTarget);
|
|
||||||
// GlobalWin.RenderPanel = d3dPanel;
|
|
||||||
// }
|
|
||||||
// catch
|
|
||||||
// {
|
|
||||||
// Program.DisplayDirect3DError();
|
|
||||||
// GlobalWin.Direct3D.Dispose();
|
|
||||||
// GlobalWin.Direct3D = null;
|
|
||||||
// SyncPresentationMode();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//#endif
|
|
||||||
|
|
||||||
// GlobalWin.DisplayManager.Resume();
|
|
||||||
// }
|
|
||||||
|
|
||||||
private void SyncThrottle()
|
private void SyncThrottle()
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,7 +5,6 @@ using System.Reflection;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
#if WINDOWS
|
#if WINDOWS
|
||||||
using SlimDX.Direct3D9;
|
|
||||||
using SlimDX.DirectSound;
|
using SlimDX.DirectSound;
|
||||||
using Microsoft.VisualBasic.ApplicationServices;
|
using Microsoft.VisualBasic.ApplicationServices;
|
||||||
#endif
|
#endif
|
||||||
|
@ -76,16 +75,12 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
MessageBox.Show("Couldn't initialize DirectSound! Things may go poorly for you. Try changing your sound driver to 41khz instead of 48khz in mmsys.cpl.", "Initialization Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show("Couldn't initialize DirectSound! Things may go poorly for you. Try changing your sound driver to 41khz instead of 48khz in mmsys.cpl.", "Initialization Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
|
|
||||||
try { GlobalWin.Direct3D = new Direct3D(); }
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
//fallback to GDI rendering
|
|
||||||
if (!Global.Config.DisplayGDI)
|
|
||||||
DisplayDirect3DError();
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//create IGL context.
|
||||||
|
//at some point in the future, we may need to select from several drivers
|
||||||
|
GlobalWin.GL = new BizHawk.Bizware.BizwareGL.Drivers.OpenTK.IGL_TK();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
#if WINDOWS
|
#if WINDOWS
|
||||||
|
@ -152,8 +147,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
if (GlobalWin.DSound != null && GlobalWin.DSound.Disposed == false)
|
if (GlobalWin.DSound != null && GlobalWin.DSound.Disposed == false)
|
||||||
GlobalWin.DSound.Dispose();
|
GlobalWin.DSound.Dispose();
|
||||||
if (GlobalWin.Direct3D != null && GlobalWin.Direct3D.Disposed == false)
|
GlobalWin.GL.Dispose();
|
||||||
GlobalWin.Direct3D.Dispose();
|
|
||||||
GamePad.CloseAll();
|
GamePad.CloseAll();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -250,10 +244,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,8 +8,6 @@ using System.Threading;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
#if WINDOWS
|
#if WINDOWS
|
||||||
using SlimDX;
|
using SlimDX;
|
||||||
using SlimDX.Direct3D9;
|
|
||||||
using d3d9font=SlimDX.Direct3D9.Font;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using BizHawk.Client.Common;
|
using BizHawk.Client.Common;
|
||||||
|
@ -17,7 +15,6 @@ using BizHawk.Bizware.BizwareGL;
|
||||||
|
|
||||||
namespace BizHawk.Client.EmuHawk
|
namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
|
|
||||||
public interface IRenderer : IDisposable
|
public interface IRenderer : IDisposable
|
||||||
{
|
{
|
||||||
void RenderOverlay(DisplaySurface surface);
|
void RenderOverlay(DisplaySurface surface);
|
||||||
|
@ -38,6 +35,24 @@ namespace BizHawk.Client.EmuHawk
|
||||||
//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
|
//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 class BizwareGLRenderPanel : IRenderer, IBlitter
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public BizwareGLRenderPanel()
|
||||||
|
{
|
||||||
|
GL = GlobalWin.GL;
|
||||||
|
|
||||||
|
GraphicsControl = GL.CreateGraphicsControl();
|
||||||
|
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.
|
||||||
|
//http://stackoverflow.com/questions/547172/pass-through-mouse-events-to-parent-control (HTTRANSPARENT)
|
||||||
|
GraphicsControl.Control.MouseDoubleClick += (o, e) => HandleFullscreenToggle(o, e);
|
||||||
|
GraphicsControl.Control.MouseClick += (o, e) => GlobalWin.MainForm.MainForm_MouseClick(o, e);
|
||||||
|
|
||||||
|
using (var xml = typeof(Program).Assembly.GetManifestResourceStream("BizHawk.Client.EmuHawk.Resources.courier16px.fnt"))
|
||||||
|
using (var tex = typeof(Program).Assembly.GetManifestResourceStream("BizHawk.Client.EmuHawk.Resources.courier16px_0.png"))
|
||||||
|
TheOneFont = new StringRenderer(GL, xml, tex);
|
||||||
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
//this hasnt been analyzed real well yet
|
//this hasnt been analyzed real well yet
|
||||||
|
@ -66,27 +81,10 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public BizwareGLRenderPanel()
|
|
||||||
{
|
|
||||||
if(gl == null)
|
|
||||||
gl = new BizHawk.Bizware.BizwareGL.Drivers.OpenTK.IGL_TK();
|
|
||||||
GraphicsControl = gl.CreateGraphicsControl();
|
|
||||||
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.
|
|
||||||
//http://stackoverflow.com/questions/547172/pass-through-mouse-events-to-parent-control (HTTRANSPARENT)
|
|
||||||
GraphicsControl.Control.MouseDoubleClick += (o, e) => HandleFullscreenToggle(o, e);
|
|
||||||
GraphicsControl.Control.MouseClick += (o, e) => GlobalWin.MainForm.MainForm_MouseClick(o, e);
|
|
||||||
|
|
||||||
using (var xml = typeof(Program).Assembly.GetManifestResourceStream("BizHawk.Client.EmuHawk.Resources.courier16px.fnt"))
|
|
||||||
using (var tex = typeof(Program).Assembly.GetManifestResourceStream("BizHawk.Client.EmuHawk.Resources.courier16px_0.png"))
|
|
||||||
TheOneFont = new StringRenderer(gl,xml,tex);
|
|
||||||
}
|
|
||||||
|
|
||||||
void IBlitter.Open()
|
void IBlitter.Open()
|
||||||
{
|
{
|
||||||
Renderer.Begin(GraphicsControl.Control.ClientSize.Width, GraphicsControl.Control.ClientSize.Height);
|
Renderer.Begin(GraphicsControl.Control.ClientSize.Width, GraphicsControl.Control.ClientSize.Height);
|
||||||
Renderer.SetBlendState(gl.BlendNormal);
|
Renderer.SetBlendState(GL.BlendNormal);
|
||||||
ClipBounds = new sd.Rectangle(0, 0, NativeSize.Width, NativeSize.Height);
|
ClipBounds = new sd.Rectangle(0, 0, NativeSize.Width, NativeSize.Height);
|
||||||
}
|
}
|
||||||
void IBlitter.Close() {
|
void IBlitter.Close() {
|
||||||
|
@ -109,7 +107,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
StringRenderer TheOneFont;
|
StringRenderer TheOneFont;
|
||||||
public Bizware.BizwareGL.GraphicsControl GraphicsControl;
|
public Bizware.BizwareGL.GraphicsControl GraphicsControl;
|
||||||
static Bizware.BizwareGL.IGL gl;
|
static Bizware.BizwareGL.IGL GL;
|
||||||
GuiRenderer Renderer;
|
GuiRenderer Renderer;
|
||||||
Texture2d LastSurfaceTexture;
|
Texture2d LastSurfaceTexture;
|
||||||
|
|
||||||
|
@ -170,12 +168,12 @@ 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();
|
LastSurfaceTexture.SetFilterNearest();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gl.LoadTextureData(LastSurfaceTexture, surface);
|
GL.LoadTextureData(LastSurfaceTexture, surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
sw = surface.Width;
|
sw = surface.Width;
|
||||||
|
@ -195,14 +193,14 @@ namespace BizHawk.Client.EmuHawk
|
||||||
GraphicsControl.Begin();
|
GraphicsControl.Begin();
|
||||||
if (!overlay)
|
if (!overlay)
|
||||||
{
|
{
|
||||||
gl.ClearColor(Color.Black); //TODO set from background color
|
GL.ClearColor(Color.Black); //TODO set from background color
|
||||||
gl.Clear(ClearBufferMask.ColorBufferBit);
|
GL.Clear(ClearBufferMask.ColorBufferBit);
|
||||||
}
|
}
|
||||||
|
|
||||||
Renderer.Begin(GraphicsControl.Control.ClientSize.Width, GraphicsControl.Control.ClientSize.Height);
|
Renderer.Begin(GraphicsControl.Control.ClientSize.Width, GraphicsControl.Control.ClientSize.Height);
|
||||||
if (overlay)
|
if (overlay)
|
||||||
Renderer.SetBlendState(gl.BlendNormal);
|
Renderer.SetBlendState(GL.BlendNormal);
|
||||||
else Renderer.SetBlendState(gl.BlendNone);
|
else Renderer.SetBlendState(GL.BlendNone);
|
||||||
Renderer.Modelview.Translate(dx, dy);
|
Renderer.Modelview.Translate(dx, dy);
|
||||||
Renderer.Modelview.Scale(finalScale);
|
Renderer.Modelview.Scale(finalScale);
|
||||||
Renderer.Draw(LastSurfaceTexture);
|
Renderer.Draw(LastSurfaceTexture);
|
||||||
|
|
|
@ -44,14 +44,26 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.OpenTK
|
||||||
|
|
||||||
public IGL_TK()
|
public IGL_TK()
|
||||||
{
|
{
|
||||||
|
//make an 'offscreen context' so we can at least do things without having to create a window
|
||||||
OffscreenNativeWindow = new NativeWindow();
|
OffscreenNativeWindow = new NativeWindow();
|
||||||
OffscreenNativeWindow.ClientSize = new sd.Size(8, 8);
|
OffscreenNativeWindow.ClientSize = new sd.Size(8, 8);
|
||||||
this.GraphicsContext = new GraphicsContext(GraphicsMode.Default, OffscreenNativeWindow.WindowInfo, 2, 0, GraphicsContextFlags.Default);
|
this.GraphicsContext = new GraphicsContext(GraphicsMode.Default, OffscreenNativeWindow.WindowInfo, 2, 0, GraphicsContextFlags.Default);
|
||||||
MakeDefaultCurrent();
|
MakeDefaultCurrent();
|
||||||
this.GraphicsContext.LoadAll(); //this is important for reasons unknown
|
|
||||||
|
//this is important for reasons unknown
|
||||||
|
this.GraphicsContext.LoadAll();
|
||||||
|
|
||||||
|
//misc initialization
|
||||||
CreateRenderStates();
|
CreateRenderStates();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IDisposable.Dispose()
|
||||||
|
{
|
||||||
|
//TODO - a lot of analysis here
|
||||||
|
OffscreenNativeWindow.Dispose(); OffscreenNativeWindow = null;
|
||||||
|
GraphicsContext.Dispose(); GraphicsContext = null;
|
||||||
|
}
|
||||||
|
|
||||||
void IGL.Clear(ClearBufferMask mask)
|
void IGL.Clear(ClearBufferMask mask)
|
||||||
{
|
{
|
||||||
GL.Clear((global::OpenTK.Graphics.OpenGL.ClearBufferMask)mask);
|
GL.Clear((global::OpenTK.Graphics.OpenGL.ClearBufferMask)mask);
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace BizHawk.Bizware.BizwareGL
|
||||||
/// TODO - This really needs to be split up into an internal and a user interface. so many of the functions are made to support the smart wrappers
|
/// TODO - This really needs to be split up into an internal and a user interface. so many of the functions are made to support the smart wrappers
|
||||||
/// Maybe make a method that returns an interface used for advanced methods (and IGL_TK could implement that as well and just "return this:")
|
/// Maybe make a method that returns an interface used for advanced methods (and IGL_TK could implement that as well and just "return this:")
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IGL
|
public interface IGL : IDisposable
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns an a control optimized for drawing onto the screen.
|
/// Returns an a control optimized for drawing onto the screen.
|
||||||
|
|
Loading…
Reference in New Issue