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"
|
lru = "0.11"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
winit = "0.28.7"
|
winit = { version = "0.29.10", features = ["rwh_05"] }
|
||||||
pollster = "0.3.0"
|
pollster = "0.3.0"
|
||||||
|
|
|
@ -11,7 +11,7 @@ use wgpu::{
|
||||||
use winit::{
|
use winit::{
|
||||||
dpi::LogicalSize,
|
dpi::LogicalSize,
|
||||||
event::{Event, WindowEvent},
|
event::{Event, WindowEvent},
|
||||||
event_loop::{ControlFlow, EventLoop},
|
event_loop::EventLoop,
|
||||||
window::WindowBuilder,
|
window::WindowBuilder,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ fn main() {
|
||||||
async fn run() {
|
async fn run() {
|
||||||
// Set up window
|
// Set up window
|
||||||
let (width, height) = (800, 600);
|
let (width, height) = (800, 600);
|
||||||
let event_loop = EventLoop::new();
|
let event_loop = EventLoop::new().unwrap();
|
||||||
let window = WindowBuilder::new()
|
let window = WindowBuilder::new()
|
||||||
.with_inner_size(LogicalSize::new(width as f64, height as f64))
|
.with_inner_size(LogicalSize::new(width as f64, height as f64))
|
||||||
.with_title("glyphon hello world")
|
.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.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);
|
buffer.shape_until_scroll(&mut font_system);
|
||||||
|
|
||||||
event_loop.run(move |event, _, control_flow| {
|
event_loop
|
||||||
let _ = (&instance, &adapter);
|
.run(move |event, target| {
|
||||||
|
if let Event::WindowEvent {
|
||||||
*control_flow = ControlFlow::Poll;
|
window_id: _,
|
||||||
|
event,
|
||||||
|
} = event
|
||||||
|
{
|
||||||
match event {
|
match event {
|
||||||
Event::WindowEvent {
|
WindowEvent::Resized(size) => {
|
||||||
event: WindowEvent::Resized(size),
|
|
||||||
..
|
|
||||||
} => {
|
|
||||||
config.width = size.width;
|
config.width = size.width;
|
||||||
config.height = size.height;
|
config.height = size.height;
|
||||||
surface.configure(&device, &config);
|
surface.configure(&device, &config);
|
||||||
window.request_redraw();
|
window.request_redraw();
|
||||||
}
|
}
|
||||||
Event::RedrawRequested(_) => {
|
WindowEvent::RedrawRequested => {
|
||||||
text_renderer
|
text_renderer
|
||||||
.prepare(
|
.prepare(
|
||||||
&device,
|
&device,
|
||||||
|
@ -120,8 +120,8 @@ async fn run() {
|
||||||
|
|
||||||
let frame = surface.get_current_texture().unwrap();
|
let frame = surface.get_current_texture().unwrap();
|
||||||
let view = frame.texture.create_view(&TextureViewDescriptor::default());
|
let view = frame.texture.create_view(&TextureViewDescriptor::default());
|
||||||
let mut encoder =
|
let mut encoder = device
|
||||||
device.create_command_encoder(&CommandEncoderDescriptor { label: None });
|
.create_command_encoder(&CommandEncoderDescriptor { label: None });
|
||||||
{
|
{
|
||||||
let mut pass = encoder.begin_render_pass(&RenderPassDescriptor {
|
let mut pass = encoder.begin_render_pass(&RenderPassDescriptor {
|
||||||
label: None,
|
label: None,
|
||||||
|
@ -146,14 +146,10 @@ async fn run() {
|
||||||
|
|
||||||
atlas.trim();
|
atlas.trim();
|
||||||
}
|
}
|
||||||
Event::WindowEvent {
|
WindowEvent::CloseRequested => target.exit(),
|
||||||
event: WindowEvent::CloseRequested,
|
|
||||||
..
|
|
||||||
} => *control_flow = ControlFlow::Exit,
|
|
||||||
Event::MainEventsCleared => {
|
|
||||||
window.request_redraw();
|
|
||||||
}
|
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
})
|
||||||
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue