SDL icon indicating copy to clipboard operation
SDL copied to clipboard

Unexpected `SDL_BLENDMODE` differences in `SDL_CreateTextureFromSurface()` and `SDL_CreateTexture()`

Open Green-Sky opened this issue 1 year ago • 1 comments

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: https://github.com/libsdl-org/SDL/blob/fd2b9c060291af8ba3388f18b3b0000e81e41643/src/render/SDL_render.c#L1619-L1625

Green-Sky avatar Jun 01 '24 10:06 Green-Sky

there was this PR related: https://github.com/libsdl-org/SDL/pull/4690

1bsyl avatar Jun 03 '24 11:06 1bsyl

Fixed, thanks!

slouken avatar Jul 17 '24 01:07 slouken