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