Skip to content

Commit

Permalink
Update dependencies (#230)
Browse files Browse the repository at this point in the history
* Move to Edition 2021
* Update `wgpu`, `raw-window-handle`, and all dependencies for the examples
* Update MSRV
* Closes #244
  • Loading branch information
parasyte committed Dec 31, 2021
1 parent 32e14da commit c1962ae
Show file tree
Hide file tree
Showing 23 changed files with 109 additions and 111 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Expand Up @@ -13,7 +13,7 @@ jobs:
rust:
- stable
- beta
- 1.54.0
- 1.57.0
steps:
- name: Checkout sources
uses: actions/checkout@v2
Expand Down Expand Up @@ -73,7 +73,7 @@ jobs:
rust:
- stable
- beta
- 1.54.0
- 1.57.0
steps:
- name: Checkout sources
uses: actions/checkout@v2
Expand Down
8 changes: 4 additions & 4 deletions Cargo.toml
Expand Up @@ -3,7 +3,7 @@ name = "pixels"
description = "A tiny library providing a GPU-powered pixel frame buffer."
version = "0.8.0"
authors = ["Jay Oster <jay@kodewerx.org>"]
edition = "2018"
edition = "2021"
repository = "https://github.com/parasyte/pixels"
readme = "README.md"
keywords = ["pixels", "2D", "GPU", "framebuffer"]
Expand All @@ -20,17 +20,17 @@ include = [

[dependencies]
bytemuck = "1.7"
raw-window-handle = "0.3"
raw-window-handle = "0.4"
thiserror = "1.0"
ultraviolet = "0.8"
wgpu = "0.11"
wgpu = "0.12"

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
pollster = "0.2"

[dev-dependencies]
pixels-mocks = { path = "internals/pixels-mocks" }
winit = "0.25"
winit = "0.26"

[workspace]
resolver = "2"
Expand Down
2 changes: 1 addition & 1 deletion MSRV.md
Expand Up @@ -2,7 +2,7 @@

| `pixels` version | `rustc` version |
|------------------|-----------------|
| `0.9.0` | `1.54.0` |
| `0.9.0` | `1.57.0` |
| `0.8.0` | `1.52.0` |
| `0.7.0` | `1.52.0` |
| `0.6.0` | `1.52.0` |
Expand Down
7 changes: 3 additions & 4 deletions examples/conway/Cargo.toml
Expand Up @@ -2,8 +2,7 @@
name = "conway"
version = "0.1.0"
authors = ["Jay Oster <jay@kodewerx.org>"]
edition = "2018"
resolver = "2"
edition = "2021"
publish = false

[features]
Expand All @@ -18,5 +17,5 @@ line_drawing = "1.0"
log = "0.4"
pixels = { path = "../.." }
randomize = "3.0"
winit = "0.25"
winit_input_helper = "0.10"
winit = "0.26"
winit_input_helper = "0.11"
7 changes: 3 additions & 4 deletions examples/custom-shader/Cargo.toml
Expand Up @@ -2,8 +2,7 @@
name = "custom-shader"
version = "0.1.0"
authors = ["Jay Oster <jay@kodewerx.org>"]
edition = "2018"
resolver = "2"
edition = "2021"
publish = false

[features]
Expand All @@ -15,5 +14,5 @@ bytemuck = "1.7"
env_logger = "0.9"
log = "0.4"
pixels = { path = "../.." }
winit = "0.25"
winit_input_helper = "0.10"
winit = "0.26"
winit_input_helper = "0.11"
2 changes: 1 addition & 1 deletion examples/custom-shader/shaders/noise.wgsl
Expand Up @@ -19,7 +19,7 @@ fn vs_main(

[[group(0), binding(0)]] var r_tex_color: texture_2d<f32>;
[[group(0), binding(1)]] var r_tex_sampler: sampler;
[[block]] struct Locals {
struct Locals {
time: f32;
};
[[group(0), binding(2)]] var<uniform> r_locals: Locals;
Expand Down
6 changes: 2 additions & 4 deletions examples/custom-shader/src/renderers.rs
Expand Up @@ -84,10 +84,7 @@ impl NoiseRenderer {
wgpu::BindGroupLayoutEntry {
binding: 1,
visibility: wgpu::ShaderStages::FRAGMENT,
ty: wgpu::BindingType::Sampler {
filtering: true,
comparison: false,
},
ty: wgpu::BindingType::Sampler(wgpu::SamplerBindingType::Filtering),
count: None,
},
wgpu::BindGroupLayoutEntry {
Expand Down Expand Up @@ -139,6 +136,7 @@ impl NoiseRenderer {
write_mask: wgpu::ColorWrites::ALL,
}],
}),
multiview: None,
});

Self {
Expand Down
11 changes: 5 additions & 6 deletions examples/imgui-winit/Cargo.toml
Expand Up @@ -2,8 +2,7 @@
name = "imgui-winit"
version = "0.1.0"
authors = ["Jay Oster <jay@kodewerx.org>"]
edition = "2018"
resolver = "2"
edition = "2021"
publish = false

[features]
Expand All @@ -13,9 +12,9 @@ default = ["optimize"]
[dependencies]
env_logger = "0.9"
imgui = "0.8"
imgui-wgpu = "0.18"
imgui-winit-support = { version = "0.8", default-features = false, features = ["winit-25"] }
imgui-wgpu = "0.19"
imgui-winit-support = { version = "0.8", default-features = false, features = ["winit-26"] }
log = "0.4"
pixels = { path = "../.." }
winit = "0.25"
winit_input_helper = "0.10"
winit = "0.26"
winit_input_helper = "0.11"
7 changes: 3 additions & 4 deletions examples/invaders/Cargo.toml
Expand Up @@ -2,8 +2,7 @@
name = "invaders"
version = "0.1.0"
authors = ["Jay Oster <jay@kodewerx.org>"]
edition = "2018"
resolver = "2"
edition = "2021"
publish = false

[features]
Expand All @@ -19,5 +18,5 @@ log = "0.4"
pixels = { path = "../.." }
randomize = "3.0"
simple-invaders = { path = "simple-invaders" }
winit = "0.25"
winit_input_helper = "0.10"
winit = "0.26"
winit_input_helper = "0.11"
13 changes: 6 additions & 7 deletions examples/minimal-egui/Cargo.toml
Expand Up @@ -2,20 +2,19 @@
name = "minimal-egui"
version = "0.1.0"
authors = ["Jay Oster <jay@kodewerx.org>"]
edition = "2018"
resolver = "2"
edition = "2021"
publish = false

[features]
optimize = ["log/release_max_level_warn"]
default = ["optimize"]

[dependencies]
egui = "0.15"
egui_wgpu_backend = "0.14"
egui-winit = { version = "0.15", default-features = false, features = ["links"] }
egui = "0.16"
egui_wgpu_backend = "0.16"
egui-winit = { version = "0.16", default-features = false, features = ["links"] }
env_logger = "0.9"
log = "0.4"
pixels = { path = "../.." }
winit = "0.25"
winit_input_helper = "0.10"
winit = "0.26"
winit_input_helper = "0.11"
17 changes: 8 additions & 9 deletions examples/minimal-egui/src/gui.rs
Expand Up @@ -65,15 +65,13 @@ impl Framework {

/// Prepare egui.
pub(crate) fn prepare(&mut self, window: &Window) {
// Begin the egui frame.
// Run the egui frame and create all paint jobs to prepare for rendering.
let raw_input = self.egui_state.take_egui_input(window);
self.egui_ctx.begin_frame(raw_input);

// Draw the demo application.
self.gui.ui(&self.egui_ctx);
let (output, paint_commands) = self.egui_ctx.run(raw_input, |egui_ctx| {
// Draw the demo application.
self.gui.ui(egui_ctx);
});

// End the egui frame and create all paint jobs to prepare for rendering.
let (output, paint_commands) = self.egui_ctx.end_frame();
self.egui_state
.handle_output(window, &self.egui_ctx, output);
self.paint_jobs = self.egui_ctx.tessellate(paint_commands);
Expand All @@ -88,7 +86,7 @@ impl Framework {
) -> Result<(), BackendError> {
// Upload all resources to the GPU.
self.rpass
.update_texture(&context.device, &context.queue, &self.egui_ctx.texture());
.update_texture(&context.device, &context.queue, &self.egui_ctx.font_image());
self.rpass
.update_user_textures(&context.device, &context.queue);
self.rpass.update_buffers(
Expand Down Expand Up @@ -119,9 +117,10 @@ impl Gui {
fn ui(&mut self, ctx: &CtxRef) {
egui::TopBottomPanel::top("menubar_container").show(ctx, |ui| {
egui::menu::bar(ui, |ui| {
egui::menu::menu(ui, "File", |ui| {
ui.menu_button("File", |ui| {
if ui.button("About...").clicked() {
self.window_open = true;
ui.close_menu();
}
})
});
Expand Down
3 changes: 1 addition & 2 deletions examples/minimal-fltk/Cargo.toml
Expand Up @@ -2,8 +2,7 @@
name = "minimal-fltk"
version = "0.1.0"
authors = ["Jay Oster <jay@kodewerx.org>"]
edition = "2018"
resolver = "2"
edition = "2021"
publish = false

[features]
Expand Down
1 change: 0 additions & 1 deletion examples/minimal-fltk/src/main.rs
Expand Up @@ -26,7 +26,6 @@ fn main() -> Result<(), Error> {
let mut win = Window::default()
.with_size(WIDTH as i32, HEIGHT as i32)
.with_label("Hello Pixels");
win.make_resizable(true);
win.end();
win.show();

Expand Down
7 changes: 4 additions & 3 deletions examples/minimal-sdl2/Cargo.toml
Expand Up @@ -2,16 +2,17 @@
name = "minimal-sdl2"
version = "0.1.0"
authors = ["Jay Oster <jay@kodewerx.org>"]
edition = "2018"
resolver = "2"
edition = "2021"
publish = false

[features]
optimize = ["log/release_max_level_warn"]
default = ["optimize"]

[dependencies]
beryllium = { version = "0.3", features = ["extern_crate_raw_window_handle"] }
beryllium = { version = "0.7", features = ["use-raw-window-handle"] }
env_logger = "0.9"
fermium = { version = "20016.1.1", default-features = false }
log = "0.4"
pixels = { path = "../.." }
zstring = "0.1"
48 changes: 28 additions & 20 deletions examples/minimal-sdl2/src/main.rs
Expand Up @@ -2,8 +2,14 @@
#![forbid(unsafe_code)]
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]

use beryllium::*;
use beryllium::{
event::Event,
init::{InitFlags, Sdl},
window::WindowFlags,
};
use fermium::keycode;
use pixels::{Pixels, SurfaceTexture};
use zstring::zstr;

const WIDTH: u32 = 320;
const HEIGHT: u32 = 240;
Expand All @@ -19,34 +25,36 @@ struct World {

fn main() -> Result<(), Box<dyn std::error::Error>> {
env_logger::init();
let sdl = SDL::init(InitFlags::default())?;
let window =
sdl.create_raw_window("Hello Pixels", WindowPosition::Centered, WIDTH, HEIGHT, 0)?;
let sdl = Sdl::init(InitFlags::EVERYTHING)?;
let window = sdl.create_vk_window(
zstr!("Hello Pixels"),
None,
(WIDTH as i32, HEIGHT as i32),
WindowFlags::ALLOW_HIGHDPI,
)?;

let mut pixels = {
// TODO: Beryllium does not expose the SDL2 `GetDrawableSize` APIs, so choosing the correct
// surface texture size is not possible.
let surface_texture = SurfaceTexture::new(WIDTH, HEIGHT, &window);
let surface_texture = SurfaceTexture::new(WIDTH, HEIGHT, &*window);
Pixels::new(WIDTH, HEIGHT, surface_texture)?
};
let mut world = World::new();

'game_loop: loop {
match sdl.poll_events().and_then(Result::ok) {
// Close events
Some(Event::Quit { .. }) => break 'game_loop,
Some(Event::Keyboard(KeyboardEvent {
key: KeyInfo { keycode: key, .. },
..
})) if key == Keycode::ESCAPE => break 'game_loop,

// Resize the window
Some(Event::Window(WindowEvent {
event: WindowEventEnum::Resized { w, h },
..
})) => pixels.resize_surface(w as u32, h as u32),

_ => (),
while let Some(event) = sdl.poll_event() {
match event {
// Close events
Event::Quit { .. } => break 'game_loop,
Event::Keyboard { keycode: key, .. } if key == keycode::SDLK_ESCAPE => {
break 'game_loop
}

// Resize the window
Event::WindowResized { width, height, .. } => pixels.resize_surface(width, height),

_ => (),
}
}

// Update internal state
Expand Down
11 changes: 5 additions & 6 deletions examples/minimal-web/Cargo.toml
Expand Up @@ -2,21 +2,20 @@
name = "minimal-web"
version = "0.1.0"
authors = ["Jay Oster <jay@kodewerx.org>"]
edition = "2018"
resolver = "2"
edition = "2021"
publish = false

[features]
optimize = ["log/release_max_level_warn"]
web = ["wgpu/webgl", "winit/web-sys"]
web = ["wgpu/webgl"]
default = ["optimize"]

[dependencies]
log = "0.4"
pixels = { path = "../.." }
wgpu = "0.11"
winit = "0.25"
winit_input_helper = "0.10"
wgpu = "0.12"
winit = "0.26"
winit_input_helper = "0.11"

[target.'cfg(target_arch = "wasm32")'.dependencies]
console_error_panic_hook = "0.1"
Expand Down
7 changes: 3 additions & 4 deletions examples/minimal-winit/Cargo.toml
Expand Up @@ -2,8 +2,7 @@
name = "minimal-winit"
version = "0.1.0"
authors = ["Jay Oster <jay@kodewerx.org>"]
edition = "2018"
resolver = "2"
edition = "2021"
publish = false

[features]
Expand All @@ -14,5 +13,5 @@ default = ["optimize"]
env_logger = "0.9"
log = "0.4"
pixels = { path = "../.." }
winit = "0.25"
winit_input_helper = "0.10"
winit = "0.26"
winit_input_helper = "0.11"

0 comments on commit c1962ae

Please sign in to comment.