Skip to content

Commit

Permalink
bugfix: Fix CI errors
Browse files Browse the repository at this point in the history
- Remove the default features of the image crate.
- Remove needless doctest from README.md

Signed-off-by: John Nunley <[email protected]>
  • Loading branch information
notgull committed Jun 22, 2024
1 parent d80ef86 commit bafb07a
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 52 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ features = ["jpeg"]

[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
# Turn rayon back on everywhere else; creating the separate entry resets the features to default.
image = "0.25.0"
rayon = "1.5.1"

[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
Expand Down
100 changes: 49 additions & 51 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,60 +71,58 @@ use winit::window::Window;
include!("../examples/utils/winit_app.rs");
fn main() {
let event_loop = EventLoop::new().unwrap();
let mut app = winit_app::WinitAppBuilder::with_init(|elwt| {
let window = {
let window = elwt.create_window(Window::default_attributes());
Rc::new(window.unwrap())
};
let context = softbuffer::Context::new(window.clone()).unwrap();
let surface = softbuffer::Surface::new(&context, window.clone()).unwrap();
(window, surface)
}).with_event_handler(|state, event, elwt| {
let (window, surface) = state;
elwt.set_control_flow(ControlFlow::Wait);
match event {
Event::WindowEvent { window_id, event: WindowEvent::RedrawRequested } if window_id == window.id() => {
let (width, height) = {
let size = window.inner_size();
(size.width, size.height)
};
surface
.resize(
NonZeroU32::new(width).unwrap(),
NonZeroU32::new(height).unwrap(),
)
.unwrap();
let mut buffer = surface.buffer_mut().unwrap();
for index in 0..(width * height) {
let y = index / width;
let x = index % width;
let red = x % 255;
let green = y % 255;
let blue = (x * y) % 255;
buffer[index as usize] = blue | (green << 8) | (red << 16);
}
buffer.present().unwrap();
let event_loop = EventLoop::new().unwrap();
let mut app = winit_app::WinitAppBuilder::with_init(|elwt| {
let window = {
let window = elwt.create_window(Window::default_attributes());
Rc::new(window.unwrap())
};
let context = softbuffer::Context::new(window.clone()).unwrap();
let surface = softbuffer::Surface::new(&context, window.clone()).unwrap();
(window, surface)
}).with_event_handler(|state, event, elwt| {
let (window, surface) = state;
elwt.set_control_flow(ControlFlow::Wait);
match event {
Event::WindowEvent { window_id, event: WindowEvent::RedrawRequested } if window_id == window.id() => {
let (width, height) = {
let size = window.inner_size();
(size.width, size.height)
};
surface
.resize(
NonZeroU32::new(width).unwrap(),
NonZeroU32::new(height).unwrap(),
)
.unwrap();
let mut buffer = surface.buffer_mut().unwrap();
for index in 0..(width * height) {
let y = index / width;
let x = index % width;
let red = x % 255;
let green = y % 255;
let blue = (x * y) % 255;
buffer[index as usize] = blue | (green << 8) | (red << 16);
}
Event::WindowEvent {
event: WindowEvent::CloseRequested,
window_id,
} if window_id == window.id() => {
elwt.exit();
}
_ => {}
buffer.present().unwrap();
}
Event::WindowEvent {
event: WindowEvent::CloseRequested,
window_id,
} if window_id == window.id() => {
elwt.exit();
}
});
_ => {}
}
});
event_loop.run_app(&mut app).unwrap();
}
event_loop.run_app(&mut app).unwrap();
```

Changelog
Expand Down

0 comments on commit bafb07a

Please sign in to comment.