fix multihawk opengl window mixup and change GLManager to a singleton to stop that from happening again

This commit is contained in:
zeromus 2015-03-06 03:05:46 +00:00
parent 67802eca8f
commit 4d89558301
3 changed files with 17 additions and 5 deletions

View File

@ -1,18 +1,27 @@
using System;
using BizHawk.Bizware.BizwareGL;
namespace BizHawk.Client.Common
{
/// <summary>
/// This class manages OpenGL contexts, in an effort to minimize context changes.
/// This singleton class manages OpenGL contexts, in an effort to minimize context changes.
/// </summary>
public class GLManager
{
public GLManager()
private GLManager()
{
}
public static GLManager Instance { get; private set; }
public static void CreateInstance()
{
if (Instance != null) throw new InvalidOperationException("Attempt to create more than one GLManager");
Instance = new GLManager();
}
public ContextRef CreateGLContext()
{
var ret = new ContextRef
@ -56,7 +65,7 @@ namespace BizHawk.Client.Common
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
cr.gc.Begin();
cr.gc.Begin();
}
if (cr.gl != null)
{

View File

@ -80,7 +80,8 @@ namespace BizHawk.Client.EmuHawk
GlobalWin.IGL_GL = new Bizware.BizwareGL.Drivers.OpenTK.IGL_TK();
//setup the GL context manager, needed for coping with multiple opengl cores vs opengl display method
GlobalWin.GLManager = new GLManager();
GLManager.CreateInstance();
GlobalWin.GLManager = GLManager.Instance;
GlobalWin.CR_GL = GlobalWin.GLManager.GetContextForIGL(GlobalWin.GL);
//now create the "GL" context for the display method. we can reuse the IGL_TK context if opengl display method is chosen

View File

@ -32,6 +32,8 @@ namespace BizHawk.Client.MultiHawk
public Mainform(string[] args)
{
BizHawk.Client.Common.GLManager.CreateInstance();
InitializeComponent();
_throttle = new Throttle();
_inputManager = new InputManager(this);
@ -317,7 +319,7 @@ namespace BizHawk.Client.MultiHawk
Emulator = loader.LoadedEmulator,
GL = new Bizware.BizwareGL.Drivers.OpenTK.IGL_TK(),
GLManager = new GLManager(),
GLManager = BizHawk.Client.Common.GLManager.Instance,
Game = loader.Game,
CurrentRomPath = loader.CanonicalFullPath
};