mirror of
https://github.com/AlexMacocian/MonoGame.Extended.git
synced 2026-07-26 00:45:20 +00:00
Create Graphics library. (#316)
* Fix BoundingRect unit tests. * Create `graphics` library.
This commit is contained in:
committed by
Dylan Wilson
parent
d1ffba93f2
commit
d0c621d0dc
@@ -0,0 +1,53 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user