Update winit
This commit is contained in:
parent
ce394f9d53
commit
c2469de817
2 changed files with 74 additions and 78 deletions
|
@ -14,5 +14,5 @@ cosmic-text = "0.10"
|
|||
lru = "0.11"
|
||||
|
||||
[dev-dependencies]
|
||||
winit = "0.28.7"
|
||||
winit = { version = "0.29.10", features = ["rwh_05"] }
|
||||
pollster = "0.3.0"
|
||||
|
|
|
@ -11,7 +11,7 @@ use wgpu::{
|
|||
use winit::{
|
||||
dpi::LogicalSize,
|
||||
event::{Event, WindowEvent},
|
||||
event_loop::{ControlFlow, EventLoop},
|
||||
event_loop::EventLoop,
|
||||
window::WindowBuilder,
|
||||
};
|
||||
|
||||
|
@ -22,7 +22,7 @@ fn main() {
|
|||
async fn run() {
|
||||
// Set up window
|
||||
let (width, height) = (800, 600);
|
||||
let event_loop = EventLoop::new();
|
||||
let event_loop = EventLoop::new().unwrap();
|
||||
let window = WindowBuilder::new()
|
||||
.with_inner_size(LogicalSize::new(width as f64, height as f64))
|
||||
.with_title("glyphon hello world")
|
||||
|
@ -76,21 +76,21 @@ async fn run() {
|
|||
buffer.set_text(&mut font_system, "Hello world! 👋\nThis is rendered with 🦅 glyphon 🦁\nThe text below should be partially clipped.\na b c d e f g h i j k l m n o p q r s t u v w x y z", Attrs::new().family(Family::SansSerif), Shaping::Advanced);
|
||||
buffer.shape_until_scroll(&mut font_system);
|
||||
|
||||
event_loop.run(move |event, _, control_flow| {
|
||||
let _ = (&instance, &adapter);
|
||||
|
||||
*control_flow = ControlFlow::Poll;
|
||||
event_loop
|
||||
.run(move |event, target| {
|
||||
if let Event::WindowEvent {
|
||||
window_id: _,
|
||||
event,
|
||||
} = event
|
||||
{
|
||||
match event {
|
||||
Event::WindowEvent {
|
||||
event: WindowEvent::Resized(size),
|
||||
..
|
||||
} => {
|
||||
WindowEvent::Resized(size) => {
|
||||
config.width = size.width;
|
||||
config.height = size.height;
|
||||
surface.configure(&device, &config);
|
||||
window.request_redraw();
|
||||
}
|
||||
Event::RedrawRequested(_) => {
|
||||
WindowEvent::RedrawRequested => {
|
||||
text_renderer
|
||||
.prepare(
|
||||
&device,
|
||||
|
@ -120,8 +120,8 @@ async fn run() {
|
|||
|
||||
let frame = surface.get_current_texture().unwrap();
|
||||
let view = frame.texture.create_view(&TextureViewDescriptor::default());
|
||||
let mut encoder =
|
||||
device.create_command_encoder(&CommandEncoderDescriptor { label: None });
|
||||
let mut encoder = device
|
||||
.create_command_encoder(&CommandEncoderDescriptor { label: None });
|
||||
{
|
||||
let mut pass = encoder.begin_render_pass(&RenderPassDescriptor {
|
||||
label: None,
|
||||
|
@ -146,14 +146,10 @@ async fn run() {
|
|||
|
||||
atlas.trim();
|
||||
}
|
||||
Event::WindowEvent {
|
||||
event: WindowEvent::CloseRequested,
|
||||
..
|
||||
} => *control_flow = ControlFlow::Exit,
|
||||
Event::MainEventsCleared => {
|
||||
window.request_redraw();
|
||||
}
|
||||
WindowEvent::CloseRequested => target.exit(),
|
||||
_ => {}
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
.unwrap();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue