Skip to content

Implement custom blend modes #1439

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Hominilupoid
Copy link

@Hominilupoid Hominilupoid commented Oct 11, 2024

Implements the possibility to compose custom blend modes through a builder type. Additionally removes some transmutes and unnecessary try_froms from conversions from u32 to BlendMode and cleans out some bindgen-generated related code in sdl2-sys.

enum BlendMode now has one additional variant for representing custom blend modes, which technically constitutes a breaking change, even though likely quite a marginal one in real-world use.

Addresses issue #878.

@@ -9,6 +9,8 @@ when upgrading from a version of rust-sdl2 to another.

[PR #1407](https://github.com/Rust-SDL2/rust-sdl2/pull/1407) Add new use_ios_framework for linking to SDL2.framework on iOS

[PR #1439](https://github.com/Rust-SDL2/rust-sdl2/pull/1439) **BREAKING CHANGE** Implement custom blend modes
Copy link
Author

@Hominilupoid Hominilupoid Oct 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be marked Maybe breaking change by the same criteria as #1156 in v0.35.0?

@Cobrand
Copy link
Member

Cobrand commented Feb 18, 2025

I don't know how you changed the sdl_bindings, but it feels like you changed them manually. At the very top of the file it says /* automatically generated by rust-bindgen 0.69.4 */. Ideally you compile using the use-bindgen feature, then copy the sdl_bindings.rs from your target directory to this repo, and see the diff.

Just in case I am right and you changed the sdl_bindings.rs file manually, never change this file manually, it will always be overwritten by the automatically generated one. If you want to add enums, impl, etc, you are perfectly free to do it in sdl2, but not sdl2-sys.

@antonilol
Copy link
Contributor

Is this PR inactive? I really want a Rust equivalent of the SDL_ComposeCustomBlendMode C function

@Hominilupoid
Copy link
Author

Hominilupoid commented Apr 8, 2025

Sorry for the very slow reply.

@Cobrand, you are correct, I manually edited sdl_bindings.rs. I was aware from the comment that (most of) the existing code had been automatically generated. However, I am honestly not so familiar with C FFI, so I did not know the entire file would constantly be re-generated. My mistake.

@antonilol, technically yes. However, as is clear from this correspondence above, this PR is (at least currently) not suitable for merging.

As said, I am that inexperienced with C FFI that I have to first familiarize myself better with bindgen directives to see if it is possible to have it automatically, safely perform these conversions that I have done manually. I will be update this PR if and when I get to it, but I must admit it is currently not high among my priorities.

That said, should anyone else feel like stepping up to finish this all up, feel free!

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.

3 participants