Fix ordering of structs when array type appears, add more windows stuff
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
DWORD :: U32
|
||||
LPCSTR :: *char
|
||||
LPCWSTR :: *U16
|
||||
HWND :: *void
|
||||
HMENU :: *void
|
||||
HINSTANCE :: *void
|
||||
@@ -10,52 +11,18 @@ SIZE_T :: U64
|
||||
BOOL :: int
|
||||
HANDLE :: *void
|
||||
VOID :: void
|
||||
HICON :: HANDLE
|
||||
HCURSOR :: HANDLE
|
||||
HBRUSH :: HANDLE
|
||||
LPDWORD :: *DWORD
|
||||
LRESULT :: S64
|
||||
WPARAM :: U64
|
||||
LPARAM :: S64
|
||||
BYTE :: U8 // @todo? unsigned char
|
||||
WORD :: S16 // short
|
||||
LONG :: S32 // @todo long
|
||||
UINT :: U32 // @todo uint
|
||||
|
||||
RBGQUAD :: struct
|
||||
rgbBlue: BYTE
|
||||
rgbGreen: BYTE
|
||||
rgbRed: BYTE
|
||||
rgbReserved: BYTE
|
||||
|
||||
BITMAPINFOHEADER :: struct
|
||||
biSize: DWORD
|
||||
biWidth: LONG
|
||||
biHeight: LONG
|
||||
biPlanes: WORD
|
||||
biBitCount: WORD
|
||||
biCompression: DWORD
|
||||
biSizeImage: DWORD
|
||||
biXPelsPerMeter: LONG
|
||||
biYPelsPerMeter: LONG
|
||||
biClrUsed: DWORD
|
||||
biClrImportant: DWORD
|
||||
|
||||
BI_RGB :: 0x0000
|
||||
BI_RLE8 :: 0x0001
|
||||
BI_RLE4 :: 0x0002
|
||||
BI_BITFIELDS :: 0x0003
|
||||
BI_JPEG :: 0x0004
|
||||
BI_PNG :: 0x0005
|
||||
BI_CMYK :: 0x000B
|
||||
BI_CMYKRLE8 :: 0x000C
|
||||
BI_CMYKRLE4 :: 0x000
|
||||
DIB_RGB_COLORS :: 0x00
|
||||
|
||||
BITMAPINFO :: struct
|
||||
bmiHeader :: BITMAPINFOHEADER
|
||||
bmiColors :: [1]RBGQUAD
|
||||
|
||||
// #import #foreign "gdi32.lib" @todo
|
||||
CreateWindowA :: #foreign (dwExStyle: DWORD, lpClassName: *char, lpWindowName: *char, dwStyle: DWORD, X: int, Y: int, nWidth: int, nHeight: int, hWndParent: HWND, hMenu: HMENU, hInstance: HINSTANCE, lpParam: *void): HWND
|
||||
GetDC :: #foreign (hWnd: HWND): HDC
|
||||
CreateDIBSection :: #foreign (hdc: HDC, pbmi: *BITMAPINFO, usage: UINT, ppvBits: **VOID, hSection: HANDLE, offset: DWORD): HBITMAP
|
||||
CreateCompatibleDC :: #foreign (hdc: HDC): HDC
|
||||
|
||||
MEM_COMMIT :: 0x00001000
|
||||
MEM_RESERVE :: 0x00002000
|
||||
MEM_RESET :: 0x00080000
|
||||
|
||||
20
programs/gdi32.kl
Normal file
20
programs/gdi32.kl
Normal file
@@ -0,0 +1,20 @@
|
||||
#load "Windows.kl"
|
||||
RBGQUAD :: struct;; rgbBlue: BYTE; rgbGreen: BYTE; rgbRed: BYTE; rgbReserved: BYTE
|
||||
BITMAPINFOHEADER :: struct;; biSize: DWORD; biWidth: LONG; biHeight: LONG; biPlanes: WORD; biBitCount: WORD; biCompression: DWORD; biSizeImage: DWORD; biXPelsPerMeter: LONG; biYPelsPerMeter: LONG; biClrUsed: DWORD; biClrImportant: DWORD
|
||||
BITMAPINFO :: struct;; bmiHeader: BITMAPINFOHEADER; bmiColors: [1]RBGQUAD
|
||||
|
||||
BI_RGB :: 0x0000
|
||||
BI_RLE8 :: 0x0001
|
||||
BI_RLE4 :: 0x0002
|
||||
BI_BITFIELDS :: 0x0003
|
||||
BI_JPEG :: 0x0004
|
||||
BI_PNG :: 0x0005
|
||||
BI_CMYK :: 0x000B
|
||||
BI_CMYKRLE8 :: 0x000C
|
||||
BI_CMYKRLE4 :: 0x000
|
||||
DIB_RGB_COLORS :: 0x00
|
||||
|
||||
|
||||
// #import #foreign "gdi32.lib" @todo
|
||||
CreateDIBSection :: #foreign (hdc: HDC, pbmi: *BITMAPINFO, usage: UINT, ppvBits: **VOID, hSection: HANDLE, offset: DWORD): HBITMAP
|
||||
CreateCompatibleDC :: #foreign (hdc: HDC): HDC
|
||||
@@ -1,5 +1,6 @@
|
||||
// #import "base.kl"
|
||||
#load "Windows.kl"
|
||||
#load "gdi32.kl"
|
||||
#load "user32.kl"
|
||||
|
||||
Vec2I :: struct;; x: S32; y: S32
|
||||
Vec2 :: struct;; x: F32; y: F32
|
||||
@@ -34,8 +35,13 @@ create_bitmap :: (size: Vec2I, bottom_up: Bool = true): Windows_Bitmap
|
||||
return result
|
||||
|
||||
|
||||
window_procedure :: (hwnd: HWND, msg: UINT, wparam: WPARAM, lparam: LPARAM): LRESULT
|
||||
if msg == WM_DESTROY
|
||||
pass
|
||||
|
||||
main :: (argc: int, argv: **char): int
|
||||
bitmap := create_bitmap({1280, 720})
|
||||
WNDCLASS
|
||||
// memory := os.reserve(size = 10000)
|
||||
// os.commit(&memory, 1000)
|
||||
// os.release(&memory)
|
||||
|
||||
13
programs/user32.kl
Normal file
13
programs/user32.kl
Normal file
@@ -0,0 +1,13 @@
|
||||
#load "Windows.kl"
|
||||
WNDPROC :: (hwnd: HWND, uMsg: UINT, wParam: WPARAM, lParam: LPARAM): LRESULT
|
||||
WNDCLASSW :: struct;; style: UINT; lpfnWndProc: WNDPROC; cbClsExtra: int; cbWndExtra: int; hInstance: HINSTANCE; hIcon: HICON; hCursor: HCURSOR; hbrBackground: HBRUSH; lpszMenuName: LPCWSTR; lpszClassName: LPCWSTR
|
||||
|
||||
PostQuitMessage :: #foreign(nExitCode: int)
|
||||
DefWindowProc :: #foreign (hwnd: HWND, uMsg: UINT, wParam: WPARAM, lParam: LPARAM): LRESULT
|
||||
GetDC :: #foreign (hWnd: HWND): HDC
|
||||
CreateWindowA :: #foreign (dwExStyle: DWORD, lpClassName: *char, lpWindowName: *char, dwStyle: DWORD, X: int, Y: int, nWidth: int, nHeight: int, hWndParent: HWND, hMenu: HMENU, hInstance: HINSTANCE, lpParam: *void): HWND
|
||||
CreateWindowExW :: #foreign (dwExStyle: DWORD, lpClassName: LPCWSTR, lpWindowName: LPCWSTR, dwStyle: DWORD, X: int, Y: int, nWidth: int, nHeight: int, hWndParent: HWND, hMenu: HMENU, hInstance: HINSTANCE, lpPara: LPVOID): HWND
|
||||
|
||||
WM_NULL :: 0x0000;; WM_CREATE :: 0x0001; WM_DESTROY :: 0x0002; WM_MOVE :: 0x0003; WM_SIZE :: 0x0005
|
||||
WM_ACTIVATE :: 0x0006;; WA_INACTIVE :: 0; WA_ACTIVE :: 1; WA_CLICKACTIVE :: 2
|
||||
WM_SETFOCUS :: 0x0007;; WM_KILLFOCUS :: 0x0008; WM_ENABLE :: 0x000A; WM_SETREDRAW :: 0x000B; WM_SETTEXT :: 0x000C; WM_GETTEXT :: 0x000D; WM_GETTEXTLENGTH :: 0x000E; WM_PAINT :: 0x000F; WM_CLOSE :: 0x0010
|
||||
Reference in New Issue
Block a user