0
0
Fork 0
mirror of https://github.com/ryujinx-mirror/ryujinx.git synced 2024-10-19 05:21:41 +00:00
ryujinx-fork/Ryujinx/Ui/ScopedGlContext.cs

36 lines
757 B
C#
Raw Normal View History

using OpenTK.Graphics;
using OpenTK.Platform;
using System;
using System.Threading;
namespace Ryujinx.Ui
{
class ScopedGlContext : IDisposable
{
private IGraphicsContext _graphicsContext;
private static readonly object _lock = new object();
public ScopedGlContext(IWindowInfo windowInfo, IGraphicsContext graphicsContext)
{
_graphicsContext = graphicsContext;
Monitor.Enter(_lock);
MakeCurrent(windowInfo);
}
private void MakeCurrent(IWindowInfo windowInfo)
{
_graphicsContext.MakeCurrent(windowInfo);
}
public void Dispose()
{
MakeCurrent(null);
Monitor.Exit(_lock);
}
}
}