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

Inconsistent Emscripten behavior when rendering from non-alpha PNG to RGBA texture with SDL_BLENDMODE_BLEND #497

Open
pshaughn opened this issue Jan 2, 2025 · 3 comments

Comments

@pshaughn
Copy link

pshaughn commented Jan 2, 2025

I'm not really sure whether this is an SDL renderer issue or an SDL_image one, but it's only manifested for me as the result of a sequence of steps involving loading a PNG from a file.

I used IMG_LoadTyped_IO to load a PNG that had no alpha channel into a surface, then SDL_CreateTextureFromSurface to make a texture.

My rendering target is a SDL_PIXELFORMAT_RGBA32 texture, and I'm in SDL_BLENDMODE_BLEND. When I call SDL_RenderTexture to draw that texture that I'd loaded, the result varies: it draws at full opacity in a Windows executable, and in an Emscripten webapp if I'm running it in Firefox, but it draws nothing if I'm running the same Emscripten webapp in Chromium.

For my own current purposes, I can easily work around this by just only using PNGs that have an alpha channel in the first place.

@slouken
Copy link
Collaborator

slouken commented Jan 2, 2025

What version of SDL? What version of SDL_image?

@pshaughn
Copy link
Author

pshaughn commented Jan 2, 2025

SDL f8f8d87bfaf3d8557a5c13e0072964a537569b6c and SDL_image 979f017

@pshaughn
Copy link
Author

I'm sorry, but I haven't been able to come up with a reproducer for this inconsistency (I'd observed it in the course of quite a large program). For reference, the Chromium in question was "Version 128.0.6613.113 (Official Build, ungoogled-chromium) (64-bit)" and the Firefox was "132.0.1 (64-bit)", both on Linux.

I am observing one anomaly: SDL_SetRenderTarget(renderer, rgba32texture); SDL_RenderTexture(renderer, rgb24texture,NULL); sets the target RGBA texture's alpha channel to 0 as opposed to 255 or unchanged, which is a behavior that seems counterintuitive to me and worth documenting, but that's happening consistently without a cross-browser divergence (matching the Chromium, not Firefox, observation from before.)

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