-
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 3fe5cb2
Showing
1 changed file
with
19 additions
and
19 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,47 @@ | ||
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(); | ||
|
||
window.set_inner_size(PhysicalSize::new(100, 100)); | ||
window.set_visible(true); | ||
|
||
for pixel in pixels.frame_mut().chunks_exact_mut(4) { | ||
pixel.copy_from_slice(&[0x00, 0x00, 0x00, 0x80]); | ||
} | ||
// window.request_redraw(); | ||
|
||
event_loop.run(move |event, _, control_flow| { | ||
event_loop.run_return(move |event, _, control_flow| { | ||
*control_flow = ControlFlow::Wait; | ||
|
||
println!("{:?}", event); | ||
|
||
if let Event::RedrawRequested(_) = event { | ||
pixels.render().unwrap(); | ||
} | ||
|
||
window.set_inner_size(size); | ||
window.set_visible(true); | ||
|
||
window.request_redraw(); | ||
window | ||
.set_cursor_position(PhysicalPosition::new(50, 50)) | ||
.unwrap(); | ||
// *control_flow = ControlFlow::Exit; | ||
}); | ||
} |