glcontexts can specify versions and clean themselves up
This commit is contained in:
parent
c9387221a0
commit
0eb6e83384
|
@ -24,13 +24,19 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
if (Instance != null) throw new InvalidOperationException("Attempt to create more than one GLManager");
|
||||
Instance = new GLManager();
|
||||
}
|
||||
|
||||
public ContextRef CreateGLContext()
|
||||
}
|
||||
|
||||
public void ReleaseGLContext(object o)
|
||||
{
|
||||
ContextRef cr = (ContextRef)o;
|
||||
cr.gl.Dispose();
|
||||
}
|
||||
|
||||
public ContextRef CreateGLContext(int major_version, int minor_version, bool forward_compatible)
|
||||
{
|
||||
var ret = new ContextRef
|
||||
{
|
||||
gl = new Bizware.BizwareGL.Drivers.OpenTK.IGL_TK()
|
||||
gl = new Bizware.BizwareGL.Drivers.OpenTK.IGL_TK(major_version, minor_version, forward_compatible)
|
||||
};
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -84,7 +84,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
CoreComm CreateCoreComm()
|
||||
{
|
||||
CoreComm ret = new CoreComm(ShowMessageCoreComm, NotifyCoreComm);
|
||||
ret.RequestGLContext = () => GlobalWin.GLManager.CreateGLContext();
|
||||
ret.ReleaseGLContext = (o) => GlobalWin.GLManager.ReleaseGLContext(o);
|
||||
ret.RequestGLContext = (major,minor,forward) => GlobalWin.GLManager.CreateGLContext(major,minor,forward);
|
||||
ret.ActivateGLContext = (gl) => GlobalWin.GLManager.Activate((GLManager.ContextRef)gl);
|
||||
ret.DeactivateGLContext = () => GlobalWin.GLManager.Deactivate();
|
||||
return ret;
|
||||
|
|
|
@ -124,7 +124,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
//create IGL context. we do this whether or not the user has selected OpenGL, so that we can run opengl-based emulator cores
|
||||
GlobalWin.IGL_GL = new Bizware.BizwareGL.Drivers.OpenTK.IGL_TK();
|
||||
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();
|
||||
|
|
|
@ -51,7 +51,8 @@ namespace BizHawk.Emulation.Common
|
|||
/// </summary>
|
||||
public Action<string> Notify { get; private set; }
|
||||
|
||||
public Func<object> RequestGLContext;
|
||||
public Func<int,int,bool,object> RequestGLContext;
|
||||
public Action<object> ReleaseGLContext;
|
||||
public Action<object> ActivateGLContext;
|
||||
public Action DeactivateGLContext; //this shouldnt be necessary.. frontend should be changing context before it does anything.. but for now..
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn
|
|||
|
||||
if (this.SyncSettings.UseGL && glContext == null)
|
||||
{
|
||||
glContext = CoreComm.RequestGLContext();
|
||||
glContext = CoreComm.RequestGLContext(2,0,false);
|
||||
}
|
||||
|
||||
ResetCounters();
|
||||
|
@ -322,6 +322,7 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn
|
|||
CD.Dispose();
|
||||
Disposed = true;
|
||||
DeactivateGL();
|
||||
CoreComm.ReleaseGLContext(glContext);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -67,12 +67,12 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.OpenTK
|
|||
}
|
||||
}
|
||||
|
||||
public IGL_TK()
|
||||
public IGL_TK(int major_version, int minor_version, bool forward_compatible)
|
||||
{
|
||||
//make an 'offscreen context' so we can at least do things without having to create a window
|
||||
OffscreenNativeWindow = new NativeWindow();
|
||||
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, major_version, minor_version, forward_compatible ? GraphicsContextFlags.ForwardCompatible : GraphicsContextFlags.Default);
|
||||
MakeDefaultCurrent();
|
||||
|
||||
//this is important for reasons unknown
|
||||
|
|
Loading…
Reference in New Issue