-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9424dea
commit 5cbdb89
Showing
1 changed file
with
20 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,44 @@ | ||
use winit::{ | ||
dpi::PhysicalSize, | ||
event::{Event, WindowEvent}, | ||
dpi::{PhysicalPosition, PhysicalSize}, | ||
event::Event, | ||
event_loop::{ControlFlow, EventLoop}, | ||
window::{Window, WindowBuilder}, | ||
platform::run_return::EventLoopExtRunReturn, | ||
window::WindowBuilder, | ||
}; | ||
|
||
use pixels::{Pixels, SurfaceTexture}; | ||
|
||
fn main() { | ||
let size_i = PhysicalSize::new(1, 1); | ||
let size = PhysicalSize::new(100, 100); | ||
|
||
let event_loop = EventLoop::new(); | ||
let mut event_loop = EventLoop::new(); | ||
let window = WindowBuilder::new() | ||
.with_transparent(true) | ||
.with_decorations(false) | ||
.with_inner_size(size_i) | ||
.with_inner_size(PhysicalSize::new(1, 1)) | ||
.with_position(PhysicalPosition::new(0, 0)) | ||
.with_visible(false) | ||
.build(&event_loop) | ||
.unwrap(); | ||
window.set_cursor_visible(false); | ||
|
||
let mut pixels = Pixels::new( | ||
size_i.width, | ||
size_i.height, | ||
SurfaceTexture::new(size_i.width, size_i.height, &window), | ||
) | ||
.unwrap(); | ||
let mut pixels = Pixels::new(1, 1, SurfaceTexture::new(1, 1, &window)).unwrap(); | ||
|
||
for pixel in pixels.frame_mut().chunks_exact_mut(4) { | ||
pixel.copy_from_slice(&[0x00, 0x00, 0x00, 0x80]); | ||
} | ||
|
||
event_loop.run(move |event, _, control_flow| { | ||
*control_flow = ControlFlow::Wait; | ||
window.set_inner_size(PhysicalSize::new(100, 100)); | ||
window.set_cursor_visible(false); | ||
window.set_visible(true); | ||
|
||
pixels.render().unwrap(); | ||
|
||
if let Event::RedrawRequested(_) = event { | ||
pixels.render().unwrap(); | ||
} | ||
event_loop.run_return(move |event, _, control_flow| { | ||
*control_flow = ControlFlow::Wait; | ||
|
||
window.set_inner_size(size); | ||
window.set_visible(true); | ||
println!("{:?}", event); | ||
|
||
window.request_redraw(); | ||
window | ||
.set_cursor_position(PhysicalPosition::new(50, 50)) | ||
.unwrap(); | ||
// *control_flow = ControlFlow::Exit; | ||
}); | ||
} |