using System; using System.Collections.Generic; using Microsoft.Xna.Framework.Graphics; namespace SharpGLTF.Runtime.Pipeline { /// /// tracks all the disposable objects of a model during loading. /// /// /// During the process of loading a model, resources like textures, effects and device buffers
/// are gathered as a collection of disposables, so when the whole model is disposed, we can also /// dispose of the device resources. ///
public class GraphicsResourceTracker { #region data private readonly List _Disposables = new List(); #endregion #region properties public IReadOnlyList Disposables => _Disposables; #endregion #region API public void AddDisposable(GraphicsResource resource) { ArgumentNullException.ThrowIfNull(resource); if (_Disposables.Contains(resource)) throw new ArgumentException($"resource used more than once {resource}"); _Disposables.Add(resource); } #endregion } }