diff --git a/BizHawk.Client.EmuHawk/GLManager.cs b/BizHawk.Client.EmuHawk/GLManager.cs
index f22433bc54..547496936f 100644
--- a/BizHawk.Client.EmuHawk/GLManager.cs
+++ b/BizHawk.Client.EmuHawk/GLManager.cs
@@ -1,6 +1,7 @@
using System;
using BizHawk.Bizware.BizwareGL;
-
+using BizHawk.Bizware.BizwareGL.Drivers.OpenTK;
+using BizHawk.Bizware.BizwareGL.Drivers.SlimDX;
namespace BizHawk.Client.EmuHawk
{
@@ -11,7 +12,6 @@ namespace BizHawk.Client.EmuHawk
{
private GLManager()
{
-
}
public void Dispose()
@@ -20,28 +20,26 @@ namespace BizHawk.Client.EmuHawk
public static GLManager Instance { get; private set; }
- Bizware.BizwareGL.Drivers.OpenTK.IGL_TK MainContext;
-
- public static void CreateInstance(Bizware.BizwareGL.Drivers.OpenTK.IGL_TK mainContext)
+ public static void CreateInstance()
{
- if (Instance != null) throw new InvalidOperationException($"Attempted to create more than one {nameof(GLManager)}");
+ if (Instance != null)
+ {
+ throw new InvalidOperationException($"Attempted to create more than one {nameof(GLManager)}");
+ }
+
Instance = new GLManager();
- Instance.MainContext = mainContext;
}
public void ReleaseGLContext(object o)
{
- ContextRef cr = (ContextRef)o;
- cr.gl.Dispose();
+ var cr = (ContextRef)o;
+ cr.GL.Dispose();
}
- //[System.Runtime.InteropServices.DllImport("opengl32.dll")]
- //bool wglShareLists(IntPtr hglrc1, IntPtr hglrc2);
-
- public ContextRef CreateGLContext(int major_version, int minor_version, bool forward_compatible)
+ public ContextRef CreateGLContext(int majorVersion, int minorVersion, bool forwardCompatible)
{
- var gl = new Bizware.BizwareGL.Drivers.OpenTK.IGL_TK(major_version, minor_version, forward_compatible);
- var ret = new ContextRef { gl = gl };
+ var gl = new IGL_TK(majorVersion, minorVersion, forwardCompatible);
+ var ret = new ContextRef { GL = gl };
return ret;
}
@@ -49,27 +47,16 @@ namespace BizHawk.Client.EmuHawk
{
return new ContextRef
{
- gc = gc,
- gl = gc.IGL
+ Gc = gc,
+ GL = gc.IGL
};
}
- ///
- /// This might not be a GL implementation. If it isnt GL, then setting it as active context is just NOP
- ///
- public ContextRef GetContextForIGL(IGL gl)
- {
- return new ContextRef
- {
- gl = gl
- };
- }
-
- ContextRef ActiveContext;
+ private ContextRef _activeContext;
public void Invalidate()
{
- ActiveContext = null;
+ _activeContext = null;
}
public void Activate(ContextRef cr)
@@ -77,26 +64,32 @@ namespace BizHawk.Client.EmuHawk
bool begun = false;
//this needs a begin signal to set the swap chain to the next backbuffer
- if (cr.gl is BizHawk.Bizware.BizwareGL.Drivers.SlimDX.IGL_SlimDX9)
+ if (cr.GL is IGL_SlimDX9)
{
- cr.gc.Begin();
+ cr.Gc.Begin();
begun = true;
}
- if (cr == ActiveContext)
+ if (cr == _activeContext)
+ {
return;
+ }
- ActiveContext = cr;
- if (cr.gc != null)
+ _activeContext = cr;
+ if (cr.Gc != null)
{
//TODO - this is checking the current context inside to avoid an extra NOP context change. make this optional or remove it, since we're tracking it here
- if(!begun)
- cr.gc.Begin();
+ if (!begun)
+ {
+ cr.Gc.Begin();
+ }
}
- else if (cr.gl != null)
+ else
{
- if(cr.gl is BizHawk.Bizware.BizwareGL.Drivers.OpenTK.IGL_TK)
- ((BizHawk.Bizware.BizwareGL.Drivers.OpenTK.IGL_TK)cr.gl).MakeDefaultCurrent();
+ if (cr.GL is IGL_TK tk)
+ {
+ tk.MakeDefaultCurrent();
+ }
}
}
@@ -107,8 +100,8 @@ namespace BizHawk.Client.EmuHawk
public class ContextRef
{
- public IGL gl;
- public GraphicsControl gc;
+ public IGL GL { get; set; }
+ public GraphicsControl Gc { get; set; }
}
}
}
\ No newline at end of file
diff --git a/BizHawk.Client.EmuHawk/Program.cs b/BizHawk.Client.EmuHawk/Program.cs
index 7e438dad45..8afe2c5578 100644
--- a/BizHawk.Client.EmuHawk/Program.cs
+++ b/BizHawk.Client.EmuHawk/Program.cs
@@ -146,13 +146,15 @@ namespace BizHawk.Client.EmuHawk
GlobalWin.IGL_GL = new Bizware.BizwareGL.Drivers.OpenTK.IGL_TK(2, 0, false);
// setup the GL context manager, needed for coping with multiple opengl cores vs opengl display method
- GLManager.CreateInstance(GlobalWin.IGL_GL);
+ GLManager.CreateInstance();
GlobalWin.GLManager = GLManager.Instance;
//now create the "GL" context for the display method. we can reuse the IGL_TK context if opengl display method is chosen
REDO_DISPMETHOD:
if (Global.Config.DispMethod == Config.EDispMethod.GdiPlus)
+ {
GlobalWin.GL = new Bizware.BizwareGL.Drivers.GdiPlus.IGL_GdiPlus();
+ }
else if (Global.Config.DispMethod == Config.EDispMethod.SlimDX9)
{
try
@@ -172,7 +174,7 @@ namespace BizHawk.Client.EmuHawk
{
GlobalWin.GL = GlobalWin.IGL_GL;
- // check the opengl version and dont even try to boot this crap up if its too old
+ // check the opengl version and don't even try to boot this crap up if its too old
if (GlobalWin.IGL_GL.Version < 200)
{
// fallback
diff --git a/BizHawk.sln.DotSettings b/BizHawk.sln.DotSettings
index 74cfaee202..e5d1bf14ed 100644
--- a/BizHawk.sln.DotSettings
+++ b/BizHawk.sln.DotSettings
@@ -190,6 +190,7 @@
True
True
True
+ True
True
True
True