Small projects to perform tests and help with fixes.

This commit is contained in:
2019-02-14 00:48:30 -06:00
parent 68345ada3c
commit c8e8bbf2be
18 changed files with 730 additions and 12 deletions

View File

@@ -13,7 +13,6 @@ namespace RecrownedAthenaeum.Render
{
VertexPositionColor[] vertices;
int bufferPosition;
VertexBuffer vertexBuffer;
BasicEffect basicEffect;
PrimitiveType primitiveType;
@@ -25,7 +24,6 @@ namespace RecrownedAthenaeum.Render
GraphicsDevice graphicsDevice;
bool began;
bool disposed;
bool changed;
Camera3D camera;
/// <summary>
@@ -40,8 +38,7 @@ namespace RecrownedAthenaeum.Render
this.camera = camera ?? (Configuration.Camera2D);
basicEffect = new BasicEffect(this.graphicsDevice);
basicEffect.VertexColorEnabled = true;
vertices = new VertexPositionColor[verticesPerBatch];
vertexBuffer = new VertexBuffer(this.graphicsDevice, typeof(VertexPositionColor), verticesPerBatch, BufferUsage.WriteOnly);
vertices = new VertexPositionColor[verticesPerBatch + 1];
}
/// <summary>
@@ -84,7 +81,6 @@ namespace RecrownedAthenaeum.Render
/// <param name="color">The color of that vertex.</param>
public void AddVertex(Vector2 vertex, Color color)
{
changed = true;
if (!began) throw new InvalidOperationException("Begin needs to be called before adding vertex.");
if (disposed) throw new ObjectDisposedException(this.GetType().Name);
if (primitiveType != PrimitiveType.LineStrip && primitiveType != PrimitiveType.TriangleStrip)
@@ -115,19 +111,13 @@ namespace RecrownedAthenaeum.Render
/// </summary>
public void Flush()
{
if (changed)
{
changed = false;
vertexBuffer.SetData(vertices);
}
graphicsDevice.SetVertexBuffer(vertexBuffer);
if (!began) throw new InvalidOperationException("Begin needs to be called before flushing.");
if (disposed) throw new ObjectDisposedException(this.GetType().Name);
if (bufferPosition == 0) return;
foreach (EffectPass effectPass in basicEffect.CurrentTechnique.Passes)
{
effectPass.Apply();
graphicsDevice.DrawPrimitives(primitiveType, 0, bufferPosition/verticesPerPrimitive);
graphicsDevice.DrawUserPrimitives(primitiveType, vertices, 0, bufferPosition/verticesPerPrimitive);
}
bufferPosition = 0;
}