MeshBatchRenderer is now more strict about state.

This commit is contained in:
Harrison Deng 2020-07-12 12:08:35 -05:00
parent 2a007cfb70
commit e4da7901bd

View File

@ -136,6 +136,7 @@ namespace SlatedGameToolkit.Framework.Graphics.Render
/// </summary> /// </summary>
/// <param name="mesh">Draws the given mesh.</param> /// <param name="mesh">Draws the given mesh.</param>
public virtual void Draw(IMesh mesh) { public virtual void Draw(IMesh mesh) {
if (!Batching) throw new InvalidOperationException("This batch has not been begun.");
IPositionInterpolable moveable = mesh as IPositionInterpolable; IPositionInterpolable moveable = mesh as IPositionInterpolable;
if (moveable != null) { if (moveable != null) {
moveable.InterpolatePosition(batchDelta); moveable.InterpolatePosition(batchDelta);
@ -188,11 +189,12 @@ namespace SlatedGameToolkit.Framework.Graphics.Render
public virtual void End() { public virtual void End() {
if (!Batching) throw new InvalidOperationException("This batch was never started."); if (!Batching) throw new InvalidOperationException("This batch was never started.");
this.Batching = false;
Flush(); Flush();
this.Batching = false;
} }
public virtual void Flush() { public virtual void Flush() {
if (!Batching) throw new InvalidOperationException("This batch has not been begun.");
if (offsetIndex == 0) return; if (offsetIndex == 0) return;
if (texture != null) { if (texture != null) {
GLContext.BindTexture(TextureTarget.Texture2D, texture.Handle); GLContext.BindTexture(TextureTarget.Texture2D, texture.Handle);