mirror of
https://github.com/italicsjenga/rust_minifb.git
synced 2025-01-26 02:36:32 +11:00
Ran rustfmt
This commit is contained in:
parent
15ec55aae2
commit
860f8b4f3d
1 changed files with 54 additions and 33 deletions
|
@ -24,10 +24,11 @@ struct BitmapInfo {
|
|||
pub bmi_colors: [RGBQUAD; 3],
|
||||
}
|
||||
|
||||
unsafe extern "system" fn wnd_proc(window: winapi::HWND, msg: winapi::UINT,
|
||||
wparam: winapi::WPARAM, lparam: winapi::LPARAM)
|
||||
-> winapi::LRESULT
|
||||
{
|
||||
unsafe extern "system" fn wnd_proc(window: winapi::HWND,
|
||||
msg: winapi::UINT,
|
||||
wparam: winapi::WPARAM,
|
||||
lparam: winapi::LPARAM)
|
||||
-> winapi::LRESULT {
|
||||
match msg {
|
||||
winapi::winuser::WM_KEYDOWN => {
|
||||
if (wparam & 0xff) == 27 {
|
||||
|
@ -57,7 +58,15 @@ unsafe extern "system" fn wnd_proc(window: winapi::HWND, msg: winapi::UINT,
|
|||
|
||||
let dc = user32::GetDC(window);
|
||||
|
||||
gdi32::StretchDIBits(dc, 0, 0, width, height, 0, 0, width, height,
|
||||
gdi32::StretchDIBits(dc,
|
||||
0,
|
||||
0,
|
||||
width,
|
||||
height,
|
||||
0,
|
||||
0,
|
||||
width,
|
||||
height,
|
||||
mem::transmute(buffer),
|
||||
mem::transmute(&bitmap_info),
|
||||
winapi::wingdi::DIB_RGB_COLORS,
|
||||
|
@ -109,21 +118,33 @@ impl Minifb {
|
|||
user32::RegisterClassW(&class);
|
||||
|
||||
let mut rect = winapi::RECT {
|
||||
left: 0, right: width as winapi::LONG,
|
||||
top: 0, bottom: height as winapi::LONG,
|
||||
left: 0,
|
||||
right: width as winapi::LONG,
|
||||
top: 0,
|
||||
bottom: height as winapi::LONG,
|
||||
};
|
||||
|
||||
user32::AdjustWindowRect(&mut rect, winapi::WS_POPUP | winapi::WS_SYSMENU | winapi::WS_CAPTION, 0);
|
||||
user32::AdjustWindowRect(&mut rect,
|
||||
winapi::WS_POPUP | winapi::WS_SYSMENU | winapi::WS_CAPTION,
|
||||
0);
|
||||
|
||||
rect.right -= rect.left;
|
||||
rect.bottom -= rect.top;
|
||||
|
||||
let handle = user32::CreateWindowExA(0,
|
||||
"minifb_window".as_ptr() as *mut _, s.as_ptr(),
|
||||
winapi::WS_OVERLAPPEDWINDOW & !winapi::WS_MAXIMIZEBOX & !winapi::WS_THICKFRAME,
|
||||
winapi::CW_USEDEFAULT, winapi::CW_USEDEFAULT,
|
||||
rect.right, rect.bottom,
|
||||
ptr::null_mut(), ptr::null_mut(), ptr::null_mut(), ptr::null_mut());
|
||||
"minifb_window".as_ptr() as *mut _,
|
||||
s.as_ptr(),
|
||||
winapi::WS_OVERLAPPEDWINDOW &
|
||||
!winapi::WS_MAXIMIZEBOX &
|
||||
!winapi::WS_THICKFRAME,
|
||||
winapi::CW_USEDEFAULT,
|
||||
winapi::CW_USEDEFAULT,
|
||||
rect.right,
|
||||
rect.bottom,
|
||||
ptr::null_mut(),
|
||||
ptr::null_mut(),
|
||||
ptr::null_mut(),
|
||||
ptr::null_mut());
|
||||
|
||||
if !handle.is_null() {
|
||||
user32::ShowWindow(handle, winapi::SW_NORMAL);
|
||||
|
@ -146,10 +167,13 @@ impl Minifb {
|
|||
unsafe {
|
||||
let mut msg = mem::uninitialized();
|
||||
|
||||
user32::SetWindowLongPtrW(self.window, winapi::winuser::GWLP_USERDATA, buffer.as_ptr() as i64);
|
||||
user32::SetWindowLongPtrW(self.window,
|
||||
winapi::winuser::GWLP_USERDATA,
|
||||
buffer.as_ptr() as i64);
|
||||
user32::InvalidateRect(self.window, ptr::null_mut(), winapi::TRUE);
|
||||
|
||||
while user32::PeekMessageW(&mut msg, self.window, 0, 0, winapi::winuser::PM_REMOVE) != 0 {
|
||||
while user32::PeekMessageW(&mut msg, self.window, 0, 0, winapi::winuser::PM_REMOVE) !=
|
||||
0 {
|
||||
user32::TranslateMessage(&mut msg);
|
||||
user32::DispatchMessageW(&mut msg);
|
||||
}
|
||||
|
@ -160,6 +184,3 @@ impl Minifb {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue