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

Lift the atlas restriction on create_text_sprite #1883

Open
bunny-therapist opened this issue Aug 15, 2023 · 1 comment
Open

Lift the atlas restriction on create_text_sprite #1883

bunny-therapist opened this issue Aug 15, 2023 · 1 comment

Comments

@bunny-therapist
Copy link

Enhancement request:

What should be added/changed?

The function create_text_sprite (and, if #1410 is resolved, create_text_texture) requires a TextureAtlas since the text texture is created by rendering into it. This adds the restriction (as explained in the docstring) that the Sprite/Texture can only be used with that one TextureAtlas. Normally, one does not need an atlas to create a texture nor a sprite, and a texture can be put in multiple texture atlases, and a sprite in multiple spritelists. Therefore, this restriction imposed by the function(s) stands out and breaks common use cases.

What would it help with?

Users can create text textures and text sprites without needing a texture atlas first. They can then be used with multiple atlases/spritelists.

@bunny-therapist
Copy link
Author

bunny-therapist commented Aug 15, 2023

I tried something really simple, just create a new image from a texture atlas and then a new texture from that image, and it seems to work. Not sure about performance/elegance etc, but as a proof of concept it definitely works:

    texture = arcade.Texture.create_empty(text, size)
    texture_atlas = arcade.TextureAtlas.create_from_texture_sequence([texture])
    with texture_atlas.render_into(texture) as fbo:
        fbo.clear((0, 0, 0, 0))
        _draw_pyglet_label(_label)
    return arcade.Texture(image=texture_atlas.get_texture_image(texture))

@einarf einarf added this to the Future milestone Jan 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants