From 268e1b72f5c55e526fba3c326ab043421acb1147 Mon Sep 17 00:00:00 2001 From: faiface <faiface@ksp.sk> Date: Thu, 12 Jan 2017 14:50:28 +0100 Subject: [PATCH] add Picture correctness check in Batch.SetPicture --- batch.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/batch.go b/batch.go index bd60136..0d6b000 100644 --- a/batch.go +++ b/batch.go @@ -52,9 +52,15 @@ func (b *Batch) MakeTriangles(t Triangles) Triangles { } } -// SetPicture does nothing, because the Picture of any Batch is fixed. +// SetPicture only checks, whether the supplied Picture has the same underlying Picture as the fixed +// Picture of this Batch. If that is not true, this method panics. func (b *Batch) SetPicture(p *Picture) { - // nothing, Batch has a fixed Picture + if p == nil { + return + } + if p.Texture() != b.pic.Texture() { + panic("batch: attempted to draw with a different Picture") + } } // SetTransform sets transforms used in the following draws onto the Batch. -- GitLab