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

fix init #1459

Merged
merged 3 commits into from
Mar 4, 2025
Merged

fix init #1459

merged 3 commits into from
Mar 4, 2025

Conversation

jagprog5
Copy link
Contributor

The SDL image library can initialize the codecs up front for whatever formats. this is done by calling IMG_Init.

However, it is not necessary. All of the image format that sdl2 support have the same pattern, like here for png, or here for jpg. Before loading the image it will try to load the codec if it is not already loaded.

So a pattern that can be used is:

  1. init with no flags
  2. then on load_texture it will link the codecs as needed, whenever an image of that format is loaded

of note: this is explicitly valid in the docs.

it's legal to call this with zero (no flags set)

Right now via rust bindings, calling

sdl2::image::init(sdl2::image::InitFlag::empty())

gives the cryptic error: "Could not init: ", which is... interesting.

and also, current logic uses, intersects, but this gives success if any of the libs init correctly (but even if one fail then it's not propagated to the caller!), when it should instead give fail only if any of them fail.

@jagprog5 jagprog5 changed the title fix init flags fix init Feb 10, 2025
@Cobrand
Copy link
Member

Cobrand commented Feb 18, 2025

Looks good, but add this to the changelog since there is probably someone out there who will have their code break because of this change.

@jagprog5 jagprog5 merged commit d6de6b2 into Rust-SDL2:master Mar 4, 2025
16 of 17 checks passed
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

Successfully merging this pull request may close these issues.

2 participants