// ----------------------------------------------------------------------------- // file="BufferObjectBase" // Project: StgSharp // Copyright (c) Nitload. // SPDX-License-Identifier: MIT // ----------------------------------------------------------------------------- using StgSharp.Graphics; using StgSharp.Graphics.OpenGL; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace StgSharp.Graphics { /// /// Interface of all kinds OpenGL BufferHandle objects /// public abstract class BufferObjectBase : IDisposable { protected GlHandle[] _bufferHandle; protected RenderStream binding; /// /// Get the only handle to one of the Object instance /// /// /// /// /// /// /// public GlHandle this[ int index ] => _bufferHandle[index]; /// /// Bind a BufferHandle instance to OpenGL /// /// /// Index of handle of the object in this instance to be bind /// public abstract void Bind( int index ); public void Dispose() { Dispose(disposing:true); GC.SuppressFinalize(this); } /// public override string ToString() { return $"This is a {GetType().FullName}, containing {_bufferHandle.Length} buffer handles: {_bufferHandle.ToString()}."; } protected abstract void Dispose( bool disposing ); ~BufferObjectBase() { Dispose(disposing:false); } } }