public IDisposable MakeCurrent(EglSurface surface) { Monitor.Enter(_lock); var success = false; try { var old = new RestoreContext(_egl, _disp.Handle, _lock); var surf = surface ?? OffscreenSurface; _egl.MakeCurrent(_disp.Handle, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero); if (!_egl.MakeCurrent(_disp.Handle, surf?.DangerousGetHandle() ?? IntPtr.Zero, surf?.DangerousGetHandle() ?? IntPtr.Zero, Context)) { throw OpenGlException.GetFormattedException("eglMakeCurrent", _egl); } success = true; return(old); } finally { if (!success) { Monitor.Enter(_lock); } } }
public void Dispose() { _egl.MakeCurrent(_display, _draw, _read, _context); Monitor.Exit(_l); }