From 6f735df6565bc6db902236a0ba3fc21396c348af Mon Sep 17 00:00:00 2001 From: faiface Date: Tue, 14 Mar 2017 22:50:46 +0100 Subject: [PATCH] add Batch.Dirty --- batch.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/batch.go b/batch.go index 09c25f5..3e17680 100644 --- a/batch.go +++ b/batch.go @@ -23,8 +23,9 @@ var _ BasicTarget = (*Batch)(nil) // NewBatch creates an empty Batch with the specified Picture and container. // -// The container is where objects get accumulated. Batch will support precisely those vertex -// properties, that the supplied container supports. +// The container is where objects get accumulated. Batch will support precisely those Triangles +// properties, that the supplied container supports. If you retain access to the container and +// change it, call Dirty to notify Batch about the change. // // Note, that if the container does not support TrianglesColor, color masking will not work. func NewBatch(container Triangles, pic Picture) *Batch { @@ -35,6 +36,17 @@ func NewBatch(container Triangles, pic Picture) *Batch { } } +// Dirty notifies Batch about an external modification of it's container. If you retain access to +// the Batch's container and change it, call Dirty to notify Batch about the change. +// +// container := &pixel.TrianglesData{} +// batch := pixel.NewBatch(container, nil) +// container.SetLen(10) // changed container from outside of Batch +// batch.Dirty() // notify Batch about the change +func (b *Batch) Dirty() { + b.cont.Dirty() +} + // Clear removes all objects from the Batch. func (b *Batch) Clear() { b.cont.Triangles.SetLen(0)