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

Save and Load Texture Atlas. #1233

Open
DragonMoffon opened this issue Jun 4, 2022 · 6 comments
Open

Save and Load Texture Atlas. #1233

DragonMoffon opened this issue Jun 4, 2022 · 6 comments
Milestone

Comments

@DragonMoffon
Copy link
Collaborator

Save and Load Texture Atlas.

Offer a way to save a generated Texture atlas or part of one and have it be loadable later.

What should be added/changed?

A TextureAtlas.save() and TextureAtlas.load().

What would it help with?

Exporting games, and run speed since no texture writing needs to be done at run time.

A bonus benefit is sprites that are only ever on the GPU and their textures never need to be loaded.

Could be two parts. A png file and a Json file that could look like

{
"Source": ".../atlas.png",
"Size": [100, 100],
"Textures": {
    "light.png<params>": {
        "pos": [120, 145],
        "size": [100, 100]
        },
    ...
    } 
}
@pushfoo
Copy link
Member

pushfoo commented Jun 5, 2022

To my understanding, this would also be useful for caching loaded or pre-generated textures on disk. Providing functionality around that would be very helpful for projects like Brett's or the ambitious terraria clone a user was discussing on discord.

@einarf
Copy link
Member

einarf commented Jun 13, 2022

One challenge is: If you need the hit boxes for these textures that information will be lost.

@Cleptomania
Copy link
Member

I'm pretty sure this is done now, I remember @einarf showing it working but I'm not sure exactly if it was fully added in or not.

@DragonMoffon
Copy link
Collaborator Author

@einarf, do you have an update on this? I know you've been doing a lot of work on atlases, so if there are any other relevant issues, maybe link this in?

@einarf einarf added this to the Future milestone Jan 16, 2024
@einarf
Copy link
Member

einarf commented Jan 16, 2024

There is a load/save_atlas in texture_atlas/helers.py that is currently not exposed. It's a very experimental feature. There's also a script in experimental using it. There are probably many issues, but it's a start.

@einarf
Copy link
Member

einarf commented Feb 18, 2024

This code needs updating. I commented it out due to the pressure to get 3.0 out. It can be enabled and tweaked later.

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

5 participants