Make new function take both a HasRawWindowHandle and a HasRawDisplayHandle object
This commit is contained in:
parent
e781cd8cab
commit
9b8641fc07
6 changed files with 10 additions and 10 deletions
|
|
@ -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;
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
|
||||||
10
src/lib.rs
10
src/lib.rs
|
|
@ -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
|
||||||
///
|
///
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue