diff --git a/graphics.go b/graphics.go index 3807964cdfaf2ae65f2b1078b9e38589d197d4b6..c328976683c356462bb5f99b68b38e122db9ed1a 100644 --- a/graphics.go +++ b/graphics.go @@ -10,7 +10,7 @@ import ( // Drawer is anything that can be drawn. It's by no means a drawer inside your table. // -// Drawer consists of a single method: Draw. Draw methods takes any number of Transform arguments. It applies these +// Drawer consists of a single methods: Draw. Draw methods takes any number of Transform arguments. It applies these // transforms in the reverse order and finally draws something transformed by these transforms. // // Example: @@ -23,6 +23,19 @@ type Drawer interface { Draw(t ...Transform) } +// Deleter is anything that can be deleted. All graphics objects that have some associated video memory +// are deleters. It is necessary to call Delete when you're done with an object, otherwise you're going +// to have video memory leaks. +type Deleter interface { + Delete() +} + +// DrawDeleter combines Drawer and Deleter interfaces. +type DrawDeleter interface { + Drawer + Deleter +} + // PolygonColor is a polygon shape filled with a single color. type PolygonColor struct { parent pixelgl.Doer @@ -108,3 +121,8 @@ func (pc *PolygonColor) Draw(t ...Transform) { pc.va.Draw() } + +// Delete destroys a polygon shape and releases it's video memory. Do not use this shape after calling Delete. +func (pc *PolygonColor) Delete() { + pc.va.Delete() +}