mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-07-07 10:20:31 +00:00
Merge pull request #390 from SiliconStudio/egl_context_fixes
Egl context fixes
This commit is contained in:
commit
8c0026ccc0
|
@ -53,8 +53,6 @@ namespace OpenTK.Platform.Egl
|
||||||
if (window == null)
|
if (window == null)
|
||||||
throw new ArgumentNullException("window");
|
throw new ArgumentNullException("window");
|
||||||
|
|
||||||
EglContext shared = (EglContext)sharedContext;
|
|
||||||
|
|
||||||
WindowInfo = window;
|
WindowInfo = window;
|
||||||
|
|
||||||
// Select an EGLConfig that matches the desired mode. We cannot use the 'mode'
|
// Select an EGLConfig that matches the desired mode. We cannot use the 'mode'
|
||||||
|
@ -97,9 +95,7 @@ namespace OpenTK.Platform.Egl
|
||||||
window.CreateWindowSurface(config);
|
window.CreateWindowSurface(config);
|
||||||
|
|
||||||
int[] attrib_list = new int[] { Egl.CONTEXT_CLIENT_VERSION, major, Egl.NONE };
|
int[] attrib_list = new int[] { Egl.CONTEXT_CLIENT_VERSION, major, Egl.NONE };
|
||||||
HandleAsEGLContext = Egl.CreateContext(window.Display, config, shared != null ? shared.HandleAsEGLContext : IntPtr.Zero, attrib_list);
|
HandleAsEGLContext = Egl.CreateContext(window.Display, config, sharedContext != null ? (sharedContext as IGraphicsContextInternal).Context.Handle : IntPtr.Zero, attrib_list);
|
||||||
|
|
||||||
MakeCurrent(window);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public EglContext(ContextHandle handle, EglWindowInfo window, IGraphicsContext sharedContext,
|
public EglContext(ContextHandle handle, EglWindowInfo window, IGraphicsContext sharedContext,
|
||||||
|
@ -128,9 +124,16 @@ namespace OpenTK.Platform.Egl
|
||||||
// trying to make the EglContext current on a non-EGL window will do,
|
// trying to make the EglContext current on a non-EGL window will do,
|
||||||
// nothing (the EglContext will remain current on the previous EGL window
|
// nothing (the EglContext will remain current on the previous EGL window
|
||||||
// or the window it was constructed on (which may not be EGL)).
|
// or the window it was constructed on (which may not be EGL)).
|
||||||
if (window is EglWindowInfo)
|
if (window != null)
|
||||||
WindowInfo = (EglWindowInfo)window;
|
{
|
||||||
Egl.MakeCurrent(WindowInfo.Display, WindowInfo.Surface, WindowInfo.Surface, HandleAsEGLContext);
|
if (window is EglWindowInfo)
|
||||||
|
WindowInfo = (EglWindowInfo) window;
|
||||||
|
Egl.MakeCurrent(WindowInfo.Display, WindowInfo.Surface, WindowInfo.Surface, HandleAsEGLContext);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Egl.MakeCurrent(WindowInfo.Display, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool IsCurrent
|
public override bool IsCurrent
|
||||||
|
@ -199,7 +202,8 @@ namespace OpenTK.Platform.Egl
|
||||||
{
|
{
|
||||||
if (manual)
|
if (manual)
|
||||||
{
|
{
|
||||||
Egl.MakeCurrent(WindowInfo.Display, WindowInfo.Surface, WindowInfo.Surface, IntPtr.Zero);
|
if (IsCurrent)
|
||||||
|
Egl.MakeCurrent(WindowInfo.Display, WindowInfo.Surface, WindowInfo.Surface, IntPtr.Zero);
|
||||||
Egl.DestroyContext(WindowInfo.Display, HandleAsEGLContext);
|
Egl.DestroyContext(WindowInfo.Display, HandleAsEGLContext);
|
||||||
}
|
}
|
||||||
IsDisposed = true;
|
IsDisposed = true;
|
||||||
|
|
|
@ -143,7 +143,6 @@ namespace OpenTK
|
||||||
Mode = GetGraphicsMode(context);
|
Mode = GetGraphicsMode(context);
|
||||||
|
|
||||||
Update(cocoaWindow);
|
Update(cocoaWindow);
|
||||||
MakeCurrent(cocoaWindow);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private IntPtr SelectPixelFormat(GraphicsMode mode, int majorVersion, int minorVersion)
|
private IntPtr SelectPixelFormat(GraphicsMode mode, int majorVersion, int minorVersion)
|
||||||
|
@ -336,7 +335,8 @@ namespace OpenTK
|
||||||
if (!NSApplication.IsUIThread)
|
if (!NSApplication.IsUIThread)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Cocoa.SendVoid(NSOpenGLContext, Selector.Get("clearCurrentContext"));
|
if (IsCurrent)
|
||||||
|
Cocoa.SendVoid(NSOpenGLContext, Selector.Get("clearCurrentContext"));
|
||||||
Cocoa.SendVoid(Handle.Handle, Selector.Get("clearDrawable"));
|
Cocoa.SendVoid(Handle.Handle, Selector.Get("clearDrawable"));
|
||||||
Cocoa.SendVoid(Handle.Handle, Selector.Get("release"));
|
Cocoa.SendVoid(Handle.Handle, Selector.Get("release"));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue