From d091323b22e2b8521a74273821d45a7a4ae08b2a Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Sun, 1 Mar 2015 14:07:50 +0100 Subject: Minor changes in documentation --- README.md | 1 - src/win32/init.rs | 26 ++++++++++++-------------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 7596402..9dab387 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,6 @@ fn main() { ### Win32 - You must call `glFlush` before `swap_buffers`, or else on Windows 8 nothing will be visible on the window - - Pixel formats are not implemented - Changing the cursor (set_cursor) is not implemented ### X11 diff --git a/src/win32/init.rs b/src/win32/init.rs index 09d5878..b458d95 100644 --- a/src/win32/init.rs +++ b/src/win32/init.rs @@ -37,16 +37,15 @@ pub fn new_window(builder: BuilderAttribs<'static>, builder_sharelists: Option>(); // title to utf16 - //let hints = hints.clone(); + .chain(Some(0).into_iter()).collect::>(); // title to utf16 + let (tx, rx) = channel(); - // GetMessage must be called in the same thread as CreateWindow, - // so we create a new thread dedicated to this window. - // This is the only safe method. Using `nosend` wouldn't work for non-native runtime. + // `GetMessage` must be called in the same thread as CreateWindow, so we create a new thread + // dedicated to this window. thread::spawn(move || { unsafe { - // sending + // creating and sending the `Window` match init(title, builder, builder_sharelists) { Ok(w) => tx.send(Ok(w)).ok(), Err(e) => { @@ -65,7 +64,7 @@ pub fn new_window(builder: BuilderAttribs<'static>, builder_sharelists: Option, builder: BuilderAttribs<'static>, // adjusting the window coordinates using the style user32::AdjustWindowRectEx(&mut rect, style, 0, ex_style); - // getting the address of wglCreateContextAttribsARB + // the first step is to create a dummy window and a dummy context which we will use + // to load the pointers to some functions in the OpenGL driver in `extra_functions` let extra_functions = { - // creating a dummy invisible window for GL initialization + // creating a dummy invisible window let dummy_window = { let handle = user32::CreateWindowExW(ex_style, class_name.as_ptr(), title.as_ptr() as winapi::LPCWSTR, @@ -140,10 +140,8 @@ unsafe fn init(title: Vec, builder: BuilderAttribs<'static>, try!(set_pixel_format(&dummy_window, id)); } - // creating the dummy OpenGL context + // creating the dummy OpenGL context and making it current let dummy_context = try!(create_context(None, &dummy_window, None)); - - // making context current let current_context = try!(CurrentContextGuard::make_current(&dummy_window, &dummy_context)); @@ -158,7 +156,7 @@ unsafe fn init(title: Vec, builder: BuilderAttribs<'static>, }) }; - // creating the real window this time + // creating the real window this time, by using the functions in `extra_functions` let real_window = { let (width, height) = if builder.monitor.is_some() || builder.dimensions.is_some() { (Some(rect.right - rect.left), Some(rect.bottom - rect.top)) @@ -216,7 +214,7 @@ unsafe fn init(title: Vec, builder: BuilderAttribs<'static>, user32::SetForegroundWindow(real_window.0); } - // filling the WINDOW task-local storage + // filling the WINDOW task-local storage so that we can start receiving events let events_receiver = { let (tx, rx) = channel(); let mut tx = Some(tx); -- cgit v1.2.3