Window painting is working!
This commit is contained in:
@@ -100,7 +100,7 @@ string_to_string16 :: (in: String): String16
|
||||
result.str[result.len] = 0
|
||||
return result
|
||||
|
||||
Vec2I :: struct;; x: S32; y: S32
|
||||
Vec2I :: struct;; x: S64; y: S64
|
||||
Vec2 :: struct;; x: F32; y: F32
|
||||
Windows_Bitmap :: struct
|
||||
size: Vec2I
|
||||
@@ -115,7 +115,7 @@ create_bitmap :: (size: Vec2I, bottom_up: Bool = true): Windows_Bitmap
|
||||
|
||||
bminfo := BITMAPINFO{
|
||||
BITMAPINFOHEADER{
|
||||
biSize = size_of(BITMAPINFOHEADER),
|
||||
biSize = 40, // @todo!!! size_of(BITMAPINFOHEADER),
|
||||
biWidth = size.x->LONG,
|
||||
biHeight = size.y->LONG,
|
||||
biPlanes = 1,
|
||||
@@ -128,6 +128,7 @@ create_bitmap :: (size: Vec2I, bottom_up: Bool = true): Windows_Bitmap
|
||||
|
||||
hdc := GetDC(0)
|
||||
result.dib = CreateDIBSection(hdc, &bminfo, DIB_RGB_COLORS, (&result.data)->**void, 0, 0)
|
||||
error := GetLastError()
|
||||
result.hdc = CreateCompatibleDC(hdc)
|
||||
return result
|
||||
|
||||
@@ -135,6 +136,7 @@ app_is_running := true
|
||||
window_procedure :: (hwnd: HWND, msg: UINT, wparam: WPARAM, lparam: LPARAM): LRESULT
|
||||
if msg == WM_DESTROY
|
||||
PostQuitMessage(0)
|
||||
app_is_running = false
|
||||
return 0
|
||||
else;; return DefWindowProcW(hwnd, msg, wparam, lparam)
|
||||
|
||||
@@ -153,9 +155,7 @@ test_unicode :: ()
|
||||
assert(result.out_str == 0xF3, "Invalid decode")
|
||||
|
||||
WinMain :: (hInstance: HINSTANCE, hPrevInstance: HINSTANCE, lpCmdLine: LPSTR, nShowCmd: int): int
|
||||
bitmap := create_bitmap({1280, 720})
|
||||
|
||||
window_name := string_to_string16("Have a wonderful day!")
|
||||
window_name := string_to_string16("Have a wonderful day! 豈 更 車 賈 滑 串 句 龜 ")
|
||||
w := WNDCLASSW{
|
||||
lpfnWndProc = window_procedure,
|
||||
hInstance = hInstance,
|
||||
@@ -165,7 +165,7 @@ WinMain :: (hInstance: HINSTANCE, hPrevInstance: HINSTANCE, lpCmdLine: LPSTR, nS
|
||||
|
||||
window := CreateWindowExW(
|
||||
dwExStyle = 0, hWndParent = 0, hMenu = 0, lpParam = 0,
|
||||
X = CW_USEDEFAULT, Y = CW_USEDEFAULT, nWidth = CW_USEDEFAULT, nHeight = CW_USEDEFAULT,
|
||||
X = CW_USEDEFAULT, Y = CW_USEDEFAULT, nWidth = 1280, nHeight = 720,
|
||||
lpClassName = window_name.str,
|
||||
lpWindowName = window_name.str,
|
||||
dwStyle = WS_OVERLAPPEDWINDOW,
|
||||
@@ -174,9 +174,18 @@ WinMain :: (hInstance: HINSTANCE, hPrevInstance: HINSTANCE, lpCmdLine: LPSTR, nS
|
||||
assert(window != 0)
|
||||
ShowWindow(window, nShowCmd)
|
||||
|
||||
window_dc := GetDC(window)
|
||||
bitmap := create_bitmap({1280, 720})
|
||||
for app_is_running
|
||||
msg: MSG
|
||||
for PeekMessageW(&msg, window, 0, 0, PM_REMOVE) > 0
|
||||
TranslateMessage(&msg)
|
||||
DispatchMessageW(&msg)
|
||||
|
||||
for y := 0, y < bitmap.size.y, y+=1
|
||||
for x := 0, x < bitmap.size.x, x+=1
|
||||
bitmap.data[x + y*bitmap.size.x] = 0xFFFF0000
|
||||
|
||||
SelectObject(bitmap.hdc, bitmap.dib)
|
||||
BitBlt(window_dc, 0, 0, (bitmap.size.x)->int, (bitmap.size.y)->int, bitmap.hdc, 0, 0, SRCCOPY)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user