From 4b289f904c4b981b87fc55b8d8c73f785d23266a Mon Sep 17 00:00:00 2001 From: hikari Date: Fri, 6 May 2022 13:58:00 +0300 Subject: [PATCH 1/2] sys/win32: fix RGB macro --- core/sys/windows/gdi32.odin | 4 +--- core/sys/windows/types.odin | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/core/sys/windows/gdi32.odin b/core/sys/windows/gdi32.odin index e728503d2..551d42417 100644 --- a/core/sys/windows/gdi32.odin +++ b/core/sys/windows/gdi32.odin @@ -67,8 +67,6 @@ foreign gdi32 { PatBlt :: proc(hdc: HDC, x, y, w, h: c_int, rop: DWORD) -> BOOL --- } -// Windows colors are packed as ABGR RGB :: #force_inline proc "contextless" (r, g, b: u8) -> COLORREF { - res: [4]u8 = {0, b, g, r} - return transmute(COLORREF)res + return COLORREF(r) | COLORREF(WORD(g) << 8) | COLORREF(DWORD(b) << 16) } diff --git a/core/sys/windows/types.odin b/core/sys/windows/types.odin index c3e461ba0..4093fd3f9 100644 --- a/core/sys/windows/types.odin +++ b/core/sys/windows/types.odin @@ -55,7 +55,7 @@ UINT_PTR :: uintptr ULONG :: c_ulong UCHAR :: BYTE NTSTATUS :: c.long -COLORREF :: DWORD // Windows colors are packed as ABGR +COLORREF :: DWORD LPCOLORREF :: ^COLORREF LPARAM :: LONG_PTR WPARAM :: UINT_PTR From 4cdc55af91f006999637fc786e6e3df5ea913164 Mon Sep 17 00:00:00 2001 From: hikari Date: Fri, 6 May 2022 18:23:52 +0300 Subject: [PATCH 2/2] sys/windows: fix RGB macro again --- core/sys/windows/gdi32.odin | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/sys/windows/gdi32.odin b/core/sys/windows/gdi32.odin index 551d42417..898766361 100644 --- a/core/sys/windows/gdi32.odin +++ b/core/sys/windows/gdi32.odin @@ -68,5 +68,5 @@ foreign gdi32 { } RGB :: #force_inline proc "contextless" (r, g, b: u8) -> COLORREF { - return COLORREF(r) | COLORREF(WORD(g) << 8) | COLORREF(DWORD(b) << 16) + return transmute(COLORREF)[4]u8{r, g, b, 0} }