Files
MonoGame.Extended/Source/MonoGame.Extended.Graphics/Batching/BatchCommandQueue.cs
T
Lucas Girouard-StranksandDylan Wilson d0c621d0dc Create Graphics library. (#316)
* Fix BoundingRect unit tests.

* Create `graphics` library.
2016-11-27 22:51:59 +10:00

53 lines
1.6 KiB
C#

using System;
using Microsoft.Xna.Framework.Graphics;
namespace MonoGame.Extended.Graphics.Batching
{
internal abstract class BatchCommandQueue<TVertexType, TCommandData> : IDisposable
where TVertexType : struct, IVertexType where TCommandData : struct, IBatchDrawCommandData<TCommandData>
{
internal BatchCommandDrawer<TVertexType, TCommandData> CommandDrawer;
internal GraphicsDevice GraphicsDevice;
internal PrimitiveType PrimitiveType;
protected BatchCommandQueue(GraphicsDevice graphicsDevice,
BatchCommandDrawer<TVertexType, TCommandData> commandDrawer)
{
GraphicsDevice = graphicsDevice;
CommandDrawer = commandDrawer;
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
internal virtual void Begin(Effect effect, PrimitiveType primitiveType)
{
CommandDrawer.Effect = effect;
CommandDrawer.PrimitiveType = primitiveType;
PrimitiveType = primitiveType;
}
protected internal abstract void Flush();
internal void End()
{
Flush();
CommandDrawer.Effect = null;
}
internal abstract void EnqueueDrawCommand(ushort startIndex, ushort primitiveCount, float sortKey,
ref TCommandData data);
protected virtual void Dispose(bool isDisposing)
{
if (!isDisposing)
return;
// don't dispose the batch drawer here; it is a shared reference
CommandDrawer = null;
}
}
}