Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MakePicture methods always create new TargetPicture #178

Open
gwttk opened this issue Apr 13, 2019 · 3 comments
Open

MakePicture methods always create new TargetPicture #178

gwttk opened this issue Apr 13, 2019 · 3 comments

Comments

@gwttk
Copy link
Contributor

gwttk commented Apr 13, 2019

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!

@faiface
Copy link
Owner

faiface commented Apr 14, 2019

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

@gwttk
Copy link
Contributor Author

gwttk commented Apr 16, 2019

Hmmm, that makes sense.
How about... instead of creating new batchPicture everytime, just reuse it, since every Batch uses only one Picture?

@faiface
Copy link
Owner

faiface commented Apr 16, 2019

Looking at it, yeah, that could be done. Feel free to make a PR :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants