Skip to content

Commit

Permalink
Fix windows
Browse files Browse the repository at this point in the history
  • Loading branch information
notgull committed Mar 29, 2023
1 parent e65ded1 commit ab86b25
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions glutin-winit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,24 +106,29 @@ impl DisplayBuilder {
None
};

#[cfg(wgl_backend)]
let raw_window_handle = window.as_ref().map(|window| window.window_handle()).transpose()?;
#[cfg(not(wgl_backend))]
let raw_window_handle = None;

let gl_display = create_display(window_target, self.preference, raw_window_handle.clone())?;

// XXX the native window must be passed to config picker when WGL is used
// otherwise very limited OpenGL features will be supported.
#[cfg(wgl_backend)]
let template_builder = if let Some(raw_window_handle) = raw_window_handle {
template_builder.compatible_with_native_window(raw_window_handle)
} else {
template_builder
let (gl_display, template) = {
#[cfg(wgl_backend)]
let raw_window_handle =
window.as_ref().map(|window| window.window_handle()).transpose()?;
#[cfg(not(wgl_backend))]
let raw_window_handle = None;

let gl_display =
create_display(window_target, self.preference, raw_window_handle.clone())?;

// XXX the native window must be passed to config picker when WGL is used
// otherwise very limited OpenGL features will be supported.
#[cfg(wgl_backend)]
let template_builder = if let Some(raw_window_handle) = raw_window_handle {
template_builder.compatible_with_native_window(raw_window_handle)
} else {
template_builder
};

let template = template_builder.build();
(gl_display, template)
};

let template = template_builder.build();

let gl_config = {
let configs = gl_display.find_configs(template)?;
config_picker(configs)
Expand All @@ -136,8 +141,6 @@ impl DisplayBuilder {
None
};

drop(raw_window_handle);

Ok((window, gl_config))
}
}
Expand Down

0 comments on commit ab86b25

Please sign in to comment.