Make code more idiomatic
This commit is contained in:
parent
09fc541055
commit
abd64adb16
1 changed files with 11 additions and 12 deletions
|
@ -4,10 +4,10 @@ use std::ffi::CString;
|
||||||
use std::ptr::null_mut;
|
use std::ptr::null_mut;
|
||||||
|
|
||||||
use self::winapi::shared::guiddef::GUID;
|
use self::winapi::shared::guiddef::GUID;
|
||||||
use self::winapi::shared::minwindef::{LPARAM, LPVOID, LRESULT, UINT, WPARAM};
|
use self::winapi::shared::minwindef::{LPARAM, LRESULT, UINT, WPARAM};
|
||||||
use self::winapi::shared::windef::{HBRUSH, HGLRC, HICON, HMENU, HWND};
|
use self::winapi::shared::windef::{HGLRC, HWND};
|
||||||
use self::winapi::um::combaseapi::CoCreateGuid;
|
use self::winapi::um::combaseapi::CoCreateGuid;
|
||||||
use self::winapi::um::libloaderapi::{GetModuleHandleA, GetProcAddress, LoadLibraryA};
|
use self::winapi::um::libloaderapi::{GetProcAddress, LoadLibraryA};
|
||||||
use self::winapi::um::wingdi::{
|
use self::winapi::um::wingdi::{
|
||||||
wglCreateContext, wglMakeCurrent, ChoosePixelFormat, SetPixelFormat, SwapBuffers,
|
wglCreateContext, wglMakeCurrent, ChoosePixelFormat, SetPixelFormat, SwapBuffers,
|
||||||
PFD_DOUBLEBUFFER, PFD_DRAW_TO_WINDOW, PFD_MAIN_PLANE, PFD_SUPPORT_OPENGL, PFD_TYPE_RGBA,
|
PFD_DOUBLEBUFFER, PFD_DRAW_TO_WINDOW, PFD_MAIN_PLANE, PFD_SUPPORT_OPENGL, PFD_TYPE_RGBA,
|
||||||
|
@ -45,18 +45,17 @@ impl Window {
|
||||||
guid.Data4[7]
|
guid.Data4[7]
|
||||||
);
|
);
|
||||||
|
|
||||||
let hinstance = GetModuleHandleA(std::ptr::null::<i8>());
|
|
||||||
let wnd_class = WNDCLASSA {
|
let wnd_class = WNDCLASSA {
|
||||||
// todo: for OpenGL, will use it later
|
// todo: for OpenGL, will use it later
|
||||||
style: CS_OWNDC | CS_HREDRAW | CS_VREDRAW,
|
style: CS_OWNDC | CS_HREDRAW | CS_VREDRAW,
|
||||||
lpfnWndProc: Some(wnd_proc),
|
lpfnWndProc: Some(wnd_proc),
|
||||||
hInstance: hinstance,
|
hInstance: null_mut(),
|
||||||
lpszClassName: class_name.as_ptr() as *const i8,
|
lpszClassName: class_name.as_ptr() as *const i8,
|
||||||
cbClsExtra: 0,
|
cbClsExtra: 0,
|
||||||
cbWndExtra: 0,
|
cbWndExtra: 0,
|
||||||
hIcon: 0 as HICON,
|
hIcon: null_mut(),
|
||||||
hCursor: 0 as HICON,
|
hCursor: null_mut(),
|
||||||
hbrBackground: 0 as HBRUSH,
|
hbrBackground: null_mut(),
|
||||||
lpszMenuName: std::ptr::null::<i8>(),
|
lpszMenuName: std::ptr::null::<i8>(),
|
||||||
};
|
};
|
||||||
RegisterClassA(&wnd_class);
|
RegisterClassA(&wnd_class);
|
||||||
|
@ -72,10 +71,10 @@ impl Window {
|
||||||
// todo: check if usize fits into i32
|
// todo: check if usize fits into i32
|
||||||
options.width as i32,
|
options.width as i32,
|
||||||
options.height as i32,
|
options.height as i32,
|
||||||
0 as HWND,
|
null_mut(),
|
||||||
0 as HMENU,
|
null_mut(),
|
||||||
hinstance,
|
null_mut(),
|
||||||
0 as LPVOID,
|
null_mut(),
|
||||||
);
|
);
|
||||||
|
|
||||||
let hdc = GetDC(hwnd);
|
let hdc = GetDC(hwnd);
|
||||||
|
|
Loading…
Add table
Reference in a new issue