emscripten-core / emscripten-core/emscripten

SDL1: Pixel format is always ABGR

Open
#19,303 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 1h
Merged PRs (30d)
105

Description

**Version of emscripten/emsdk:**
```
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.37-git (d02c29f95e9e68f2f50c2b0432c56a671814d5c8)
clang version 17.0.0 (/startdir/llvm-project 86339ef088e9aac6cf52cf9022d7a5bd144d4c42)
```

**The issue**

When explicitly requesting `SDL_PIXELFORMAT_ARGB8888`, or any pixel format really from `SDL_SetVideoMode()`, the returned `SDL_Surface*` has a `SDL_PIXELFORMAT_ABGR8888` anyways.

This breaks some applications that really need the ARGB format, since it is ubiquitous on other SDL targets (Like, any modern OS really). Doing a software format conversion ain't efficient, either (And should be done inside SDL if anything, according to the documentation).

**Expected result**

Actually being able to create working & performant ARGB surfaces and/or do the conversion under the hood, which might be more efficient than doing it from C code, and not require to work around it violating SDL guarantees.

**Examples**

RVVM in Emscripten is working around by passing the pixel format down to the guest, which it may (Or may not) support. Haiku OS doesn't, for example, so it looks like pixel conversion is needed at least.
However, I do not see the reason for ABGR being forced documented anywhere, and it seems weird to work around that.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.