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

Unexpected SDL_BLENDMODE differences in SDL_CreateTextureFromSurface() and SDL_CreateTexture() #9941

Closed
Green-Sky opened this issue Jun 1, 2024 · 2 comments · Fixed by #10297
Assignees
Milestone

Comments

@Green-Sky
Copy link
Contributor

Green-Sky commented Jun 1, 2024

When creating a surface using SDL_CreateSurfaceFrom() with SDL_PIXELFORMAT_RGBA32, blend mode is set to SDL_BLENDMODE_BLEND. SDL_CreateTextureFromSurface() then goes in and copies the blend mode from the surface to the texture. Due to limitations on setting properties (static/streaming) I went with SDL_CreateTexture(), which obv does not copy the blend mode.

This whole behavoir difference is a bit unintuitive, and I propose to make the behavoir the same for surfaces and textures.

edit: just found out its actually worse, the blend mode is always set to BLEND if the source surface has alpha, and copied otherwise:

SDL/src/render/SDL_render.c

Lines 1619 to 1625 in fd2b9c0

if (SDL_SurfaceHasColorKey(surface)) {
/* We converted to a texture with alpha format */
SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND);
} else {
SDL_GetSurfaceBlendMode(surface, &blendMode);
SDL_SetTextureBlendMode(texture, blendMode);
}

@slouken slouken added this to the 3.0 ABI milestone Jun 1, 2024
@1bsyl
Copy link
Contributor

1bsyl commented Jun 3, 2024

there was this PR related: #4690

@slouken
Copy link
Collaborator

slouken commented Jul 17, 2024

Fixed, thanks!

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 a pull request may close this issue.

3 participants