mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-23 10:15:31 +00:00
[OpenTK] Add allocated resource registry
This commit is contained in:
parent
864cc84019
commit
77a44b2c8e
|
@ -28,6 +28,7 @@
|
|||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using OpenTK.Graphics;
|
||||
using OpenTK.Input;
|
||||
|
@ -42,12 +43,27 @@ namespace OpenTK.Platform
|
|||
/// </summary>
|
||||
abstract class PlatformFactoryBase : IPlatformFactory
|
||||
{
|
||||
static readonly object sync = new object();
|
||||
readonly List<IDisposable> Resources = new List<IDisposable>();
|
||||
|
||||
protected bool IsDisposed;
|
||||
|
||||
public PlatformFactoryBase()
|
||||
{
|
||||
}
|
||||
|
||||
#region Protected Members
|
||||
|
||||
protected void RegisterResource(IDisposable resource)
|
||||
{
|
||||
lock (sync)
|
||||
{
|
||||
Resources.Add(resource);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IPlatformFactory Members
|
||||
|
||||
public abstract INativeWindow CreateNativeWindow(int x, int y, int width, int height, string title, GraphicsMode mode, GameWindowFlags options, DisplayDevice device);
|
||||
|
@ -96,6 +112,13 @@ namespace OpenTK.Platform
|
|||
{
|
||||
if (manual)
|
||||
{
|
||||
lock (sync)
|
||||
{
|
||||
foreach (var resource in Resources)
|
||||
{
|
||||
resource.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue