Skip to content

Commit

Permalink
this is a stumper
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-r-thomas committed May 18, 2024
1 parent 802981f commit d7ca863
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 65 deletions.
86 changes: 29 additions & 57 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ members = ["xtask"]
crate-type = ["cdylib"]

[dependencies]
bytemuck = "1.16.0"
bytemuck = { version = "1.16.0", features = ["derive"] }
# Remove the `assert_process_allocs` feature to allow allocations on the audio
# thread in debug builds.
nih_plug = { git = "https://github.com/robbert-vdh/nih-plug.git", features = ["assert_process_allocs"] }
wgpu = { version = "0.18" }
baseview = {git = "https://github.com/RustAudio/baseview.git"}
baseview = { git = "https://github.com/RustAudio/baseview.git", rev = "2c1b1a7b0fef1a29a5150a6a8f6fef6a0cbab8c4" }
pollster = "0.3.0"
# Uncomment the below line to disable the on-by-default VST3 feature to remove
# the GPL compatibility requirement
Expand Down
20 changes: 20 additions & 0 deletions src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,24 @@ impl Editor for WgpuEditor {
let renderer = WgpuRenderer::start(parent);
Box::new(renderer)
}

fn size(&self) -> (u32, u32) {
todo!()
}

fn set_scale_factor(&self, factor: f32) -> bool {
todo!()
}

fn param_value_changed(&self, id: &str, normalized_value: f32) {
todo!()
}

fn param_modulation_changed(&self, id: &str, modulation_offset: f32) {
todo!()
}

fn param_values_changed(&self) {
todo!()
}
}
17 changes: 11 additions & 6 deletions src/render.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::sync::Arc;

use baseview::MouseEvent;
use baseview::Size;
use baseview::Window;
Expand Down Expand Up @@ -26,7 +28,7 @@ pub struct WgpuRenderer {
impl<'a> WgpuRenderer {
pub async fn new(window: &mut Window<'a>) -> Self {
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor::default());
let surface = unsafe { instance.create_surface(&window) }.unwrap();
let surface = unsafe { instance.create_surface(&*window) }.unwrap();
let adapter = instance
.request_adapter(&wgpu::RequestAdapterOptions {
power_preference: wgpu::PowerPreference::default(),
Expand Down Expand Up @@ -161,15 +163,18 @@ impl<'a> WgpuRenderer {
title: "wgpu on baseview".into(),
size: Size::new(WINDOW_SIZE as f64, WINDOW_SIZE as f64),
scale: baseview::WindowScalePolicy::SystemScaleFactor,
gl_config: None,
// gl_config: None,
};

Window::open_parented(&parent, window_open_options, |window| {
pollster::block_on(WgpuRenderer::new(window))
})
Window::open_parented(
&parent,
window_open_options,
move |window: &mut Window<'_>| -> WgpuRenderer {
pollster::block_on(WgpuRenderer::new(window))
},
)
}
}

impl WindowHandler for WgpuRenderer {
fn on_frame(&mut self, _window: &mut baseview::Window) {
let output = self.surface.get_current_texture().unwrap();
Expand Down

0 comments on commit d7ca863

Please sign in to comment.