Explorar o código

Merge pull request #1756 from ftphikari/master

sys/windows: add a couple of procedures and types
Jeroen van Rijn %!s(int64=3) %!d(string=hai) anos
pai
achega
7cc759a855
Modificáronse 3 ficheiros con 11 adicións e 1 borrados
  1. 1 1
      core/image/common.odin
  2. 8 0
      core/sys/windows/gdi32.odin
  3. 2 0
      core/sys/windows/types.odin

+ 1 - 1
core/image/common.odin

@@ -1131,4 +1131,4 @@ write_bytes :: proc(buf: ^bytes.Buffer, data: []u8) -> (err: compress.General_Er
 		return compress.General_Error.Resize_Failed
 	}
 	return nil
-}
+}

+ 8 - 0
core/sys/windows/gdi32.odin

@@ -62,5 +62,13 @@ foreign gdi32 {
 	ChoosePixelFormat :: proc(hdc: HDC, ppfd: ^PIXELFORMATDESCRIPTOR) -> c_int ---
 	SwapBuffers :: proc(HDC) -> BOOL ---
 
+	SetDCBrushColor :: proc(hdc: HDC, color: COLORREF) -> COLORREF ---
+	GetDCBrushColor :: proc(hdc: HDC) -> COLORREF ---
 	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
+}

+ 2 - 0
core/sys/windows/types.odin

@@ -55,6 +55,8 @@ UINT_PTR :: uintptr
 ULONG :: c_ulong
 UCHAR :: BYTE
 NTSTATUS :: c.long
+COLORREF :: DWORD // Windows colors are packed as ABGR
+LPCOLORREF :: ^COLORREF
 LPARAM :: LONG_PTR
 WPARAM :: UINT_PTR
 LRESULT :: LONG_PTR