Open gwttk opened 5 years ago
Yep, means exactly that! This can be efficient or inefficient based on what target you're using. If you're drawing directly to the window, then yes, this will be rather inefficient, because a new OpenGL texture will be allocated for each picture. However, if you use Batch, it will be very efficient because TargetPicture for Batch is just a struct of two pointers and the Batch only makes one TargetPicture from its own target (e.g. window).
Hmmm, that makes sense. How about... instead of creating new batchPicture everytime, just reuse it, since every Batch uses only one Picture?
Looking at it, yeah, that could be done. Feel free to make a PR :)
Look at batch.go#L82 and canvas.go#L73 All MakePicture methods return new TargetPicture instances. Also every Sprite caches a TargetPicture. So, does that means, for 10k Sprites created from a single Picture, pixel creates 10k TargetPictures? That sounds very inefficient!