Rectangle renderers work.
This commit is contained in:
@@ -15,17 +15,18 @@ namespace RecrownedAthenaeum.Render
|
||||
int bufferPosition;
|
||||
BasicEffect basicEffect;
|
||||
PrimitiveType primitiveType;
|
||||
private int verticesPerPrimitive;
|
||||
|
||||
/// <summary>
|
||||
/// Sets the vertices per primitive. Default is dependent on the primitive type. Lists will generally satisfy the amount of vertices they need, while strips should be set or it will all be interconnected.
|
||||
/// Amount of primitives.
|
||||
/// </summary>
|
||||
public int verticesPerPrimitive;
|
||||
public int primitiveCount;
|
||||
|
||||
GraphicsDevice graphicsDevice;
|
||||
bool began;
|
||||
bool disposed;
|
||||
Camera3D camera;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Creates a batch used to draw primitives.
|
||||
/// </summary>
|
||||
@@ -55,7 +56,8 @@ namespace RecrownedAthenaeum.Render
|
||||
{
|
||||
case PrimitiveType.LineList: verticesPerPrimitive = 2; break;
|
||||
case PrimitiveType.TriangleList: verticesPerPrimitive = 3; break;
|
||||
default: verticesPerPrimitive = 1; break;
|
||||
case PrimitiveType.LineStrip: verticesPerPrimitive = 1; break;
|
||||
case PrimitiveType.TriangleStrip: verticesPerPrimitive = 3; break;
|
||||
}
|
||||
basicEffect.World = camera.worldMatrix;
|
||||
basicEffect.View = camera.ViewMatrix;
|
||||
@@ -108,18 +110,21 @@ namespace RecrownedAthenaeum.Render
|
||||
|
||||
/// <summary>
|
||||
/// Flushes the batch. Automatically called if required if using <see cref="PrimitiveType.LineList"/> or <see cref="PrimitiveType.TriangleList"/>. Otherwise, manual flushing is required.
|
||||
/// <see cref="primitiveCount"/> is used if not zero. Is reset to zero every flush.
|
||||
/// </summary>
|
||||
public void Flush()
|
||||
{
|
||||
if (!began) throw new InvalidOperationException("Begin needs to be called before flushing.");
|
||||
if (disposed) throw new ObjectDisposedException(this.GetType().Name);
|
||||
if (bufferPosition == 0) return;
|
||||
if (primitiveCount == 0) primitiveCount = bufferPosition / verticesPerPrimitive;
|
||||
foreach (EffectPass effectPass in basicEffect.CurrentTechnique.Passes)
|
||||
{
|
||||
effectPass.Apply();
|
||||
graphicsDevice.DrawUserPrimitives(primitiveType, vertices, 0, bufferPosition/verticesPerPrimitive);
|
||||
graphicsDevice.DrawUserPrimitives(primitiveType, vertices, 0, primitiveCount);
|
||||
}
|
||||
bufferPosition = 0;
|
||||
primitiveCount = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user