SDL2 library in emscripten swaps red and blue channels which makes it false color.
//C:\dm\bin\dmc colortest.cpp -o -I C:\dm\stlport\stlport -I C:\Users\Admin\Downloads\SDL2-devel-2.0.22-VC\SDL2-2.0.22\include C:\Users\Admin\Downloads\SDL2-devel-2.0.22-VC\SDL2-2.0.22\lib\x86\sdl.lib -L/exet:nt/su:windows:4.0
//emcc colortest.cpp -O3 -sUSE_SDL=2 -sASYNCIFY -sALLOW_MEMORY_GROWTH -o colortest.html
#define SDL_MAIN_HANDLED
#include <SDL.h>
int main(int argc, char *argv[]){
const int width=128; const int height=64;
SDL_Window* window = SDL_CreateWindow("color test", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, 0);
SDL_Surface* screenSurface = SDL_GetWindowSurface(window);
unsigned* bitmapdata = (unsigned*)screenSurface->pixels;
for(int i=0;i<width*height;i++)bitmapdata[i]=(i>>5&1?0xFF0000:0)|(i>>6&1?0x00FF00:0)|(i>>12&1?0x0000FF:0);
while (1){
SDL_Event event_;
while (SDL_PollEvent(&event_)) if(event_.type==SDL_QUIT)exit(0);
SDL_UpdateWindowSurface(window); SDL_Delay(1);
}
return 0;
}
https://i.imgur.com/EMQhoF5.pngHow do I ensure the video image is always drawn correctly when represented in 0x00RRGGBB (note: little endian byte order is BGR)?