Archived
1
0
Fork 0
forked from Mirror/Ryujinx
This repository has been archived on 2024-10-11. You can view files and clone it, but cannot push or open issues or pull requests.
jinx/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);
}
}
}