add Picture correctness check in Batch.SetPicture

This commit is contained in:
faiface 2017-01-12 14:50:28 +01:00
parent b610760f1c
commit 268e1b72f5
1 changed files with 8 additions and 2 deletions

View File

@ -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.