Swizzle bits of a window correctly for mingw builds (#3521)

This commit is contained in:
janisozaur 2016-05-07 23:44:46 +02:00 committed by Ted John
parent de02bbc922
commit 2c3a832970

View file

@ -806,7 +806,11 @@ HWND windows_get_window_handle()
HWND handle = wmInfo.info.win.window;
#ifdef __MINGW32__
assert(sizeof(HWND) == sizeof(uint32));
HWND result = (((uint32)handle & 0xff000000) >> 8) | (((uint32)handle & 0xff0000) << 8) | (((uint32)handle & 0xff00) >> 8) | (((uint32)handle & 0xff) << 8);
uint8 A = (uint32)handle & 0xff000000 >> 24;
uint8 B = (uint32)handle & 0xff0000 >> 16;
uint8 C = (uint32)handle & 0xff00 >> 8;
uint8 D = (uint32)handle & 0xff;
HWND result = (HWND)(D << 24 | A << 16 | B << 8 | C);
log_warning("twisting bits of handle, a workaround for mingw/sdl bug");
#else
HWND result = handle;