Make new function take both a HasRawWindowHandle and a HasRawDisplayHandle object

This commit is contained in:
Jeremy Soller 2022-12-20 10:10:52 -07:00
parent e781cd8cab
commit 9b8641fc07
6 changed files with 10 additions and 10 deletions

View file

@ -63,7 +63,7 @@ use winit::window::WindowBuilder;
fn main() { fn main() {
let event_loop = EventLoop::new(); let event_loop = EventLoop::new();
let window = WindowBuilder::new().build(&event_loop).unwrap(); let window = WindowBuilder::new().build(&event_loop).unwrap();
let mut graphics_context = unsafe { GraphicsContext::new(&window) }.unwrap(); let mut graphics_context = unsafe { GraphicsContext::new(&window, &window) }.unwrap();
event_loop.run(move |event, _, control_flow| { event_loop.run(move |event, _, control_flow| {
*control_flow = ControlFlow::Wait; *control_flow = ControlFlow::Wait;

View file

@ -25,7 +25,7 @@ fn main() {
.unwrap(); .unwrap();
} }
let mut graphics_context = unsafe { GraphicsContext::new(&window) }.unwrap(); let mut graphics_context = unsafe { GraphicsContext::new(&window, &window) }.unwrap();
let mut old_size = (0, 0); let mut old_size = (0, 0);
let mut frames = pre_render_frames(0, 0); let mut frames = pre_render_frames(0, 0);

View file

@ -32,7 +32,7 @@ fn main() {
.unwrap(); .unwrap();
} }
let mut graphics_context = unsafe { GraphicsContext::new(&window) }.unwrap(); let mut graphics_context = unsafe { GraphicsContext::new(&window, &window) }.unwrap();
event_loop.run(move |event, _, control_flow| { event_loop.run(move |event, _, control_flow| {
*control_flow = ControlFlow::Wait; *control_flow = ControlFlow::Wait;

View file

@ -21,7 +21,7 @@ fn main() {
.unwrap(); .unwrap();
} }
let mut graphics_context = unsafe { GraphicsContext::new(&window) }.unwrap(); let mut graphics_context = unsafe { GraphicsContext::new(&window, &window) }.unwrap();
event_loop.run(move |event, _, control_flow| { event_loop.run(move |event, _, control_flow| {
*control_flow = ControlFlow::Wait; *control_flow = ControlFlow::Wait;

View file

@ -24,7 +24,7 @@ fn main() {
.unwrap(); .unwrap();
} }
let mut graphics_context = unsafe { GraphicsContext::new(&window) }.unwrap(); let mut graphics_context = unsafe { GraphicsContext::new(&window, &window) }.unwrap();
event_loop.run(move |event, _, control_flow| { event_loop.run(move |event, _, control_flow| {
*control_flow = ControlFlow::Wait; *control_flow = ControlFlow::Wait;

View file

@ -33,17 +33,17 @@ pub struct GraphicsContext {
} }
impl GraphicsContext { impl GraphicsContext {
/// Creates a new instance of this struct, using the provided window. /// Creates a new instance of this struct, using the provided window and display.
/// ///
/// # Safety /// # Safety
/// ///
/// - Ensure that the provided window is valid to draw a 2D buffer to, and is valid for the /// - Ensure that the provided objects are valid to draw a 2D buffer to, and are valid for the
/// lifetime of the GraphicsContext /// lifetime of the GraphicsContext
pub unsafe fn new<W: HasRawWindowHandle + HasRawDisplayHandle>(window: &W) -> Result<Self, SwBufError> { pub unsafe fn new<W: HasRawWindowHandle, D: HasRawDisplayHandle>(window: &W, display: &D) -> Result<Self, SwBufError> {
Self::from_raw(window.raw_window_handle(), window.raw_display_handle()) Self::from_raw(window.raw_window_handle(), display.raw_display_handle())
} }
/// Creates a new instance of this struct, using the provided raw handles /// Creates a new instance of this struct, using the provided raw window and display handles
/// ///
/// # Safety /// # Safety
/// ///