summaryrefslogtreecommitdiffstats
path: root/examples/integration
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2023-11-29 22:28:31 +0100
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2023-11-29 22:28:31 +0100
commite09b4e24dda51b8212d8ece52431dacaa3922a7b (patch)
tree7005e181528134ebdde5bbbe5909273db9f30174 /examples/integration
parent83c7870c569a2976923ee6243a19813094d44673 (diff)
parent7f8b17604a31e00becc43130ec516c1a53552c88 (diff)
downloadiced-e09b4e24dda51b8212d8ece52431dacaa3922a7b.tar.gz
iced-e09b4e24dda51b8212d8ece52431dacaa3922a7b.tar.bz2
iced-e09b4e24dda51b8212d8ece52431dacaa3922a7b.zip
Merge branch 'master' into feat/multi-window-support
Diffstat (limited to 'examples/integration')
-rw-r--r--examples/integration/Cargo.toml23
-rw-r--r--examples/integration/README.md4
-rw-r--r--examples/integration/src/controls.rs2
-rw-r--r--examples/integration/src/main.rs29
-rw-r--r--examples/integration/src/scene.rs5
5 files changed, 32 insertions, 31 deletions
diff --git a/examples/integration/Cargo.toml b/examples/integration/Cargo.toml
index 22914742..a4a961f8 100644
--- a/examples/integration/Cargo.toml
+++ b/examples/integration/Cargo.toml
@@ -6,19 +6,18 @@ edition = "2021"
publish = false
[dependencies]
-iced_winit = { path = "../../winit" }
-iced_wgpu = { path = "../../wgpu" }
-iced_widget = { path = "../../widget" }
-iced_renderer = { path = "../../renderer", features = ["wgpu"] }
-env_logger = "0.10"
+iced_winit.workspace = true
+iced_wgpu.workspace = true
+iced_widget.workspace = true
+
+[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
+tracing-subscriber = "0.3"
[target.'cfg(target_arch = "wasm32")'.dependencies]
-console_error_panic_hook = "0.1.7"
-console_log = "0.2.0"
-log = "0.4"
+iced_wgpu.workspace = true
+iced_wgpu.features = ["webgl"]
+
+console_error_panic_hook = "0.1"
+console_log = "1.0"
wasm-bindgen = "0.2"
web-sys = { version = "0.3", features = ["Element", "HtmlCanvasElement", "Window", "Document"] }
-# This dependency a little bit quirky, it is deep in the tree and without `js` feature it
-# refuses to work with `wasm32-unknown-unknown target`. Unfortunately, we need this patch
-# to make it work
-getrandom = { version = "0.2", features = ["js"] }
diff --git a/examples/integration/README.md b/examples/integration/README.md
index ece9ba1e..996cdc17 100644
--- a/examples/integration/README.md
+++ b/examples/integration/README.md
@@ -5,9 +5,7 @@ A demonstration of how to integrate Iced in an existing [`wgpu`] application.
The __[`main`]__ file contains all the code of the example.
<div align="center">
- <a href="https://gfycat.com/nicemediocrekodiakbear">
- <img src="https://thumbs.gfycat.com/NiceMediocreKodiakbear-small.gif">
- </a>
+ <img src="https://iced.rs/examples/integration.gif">
</div>
You can run it with `cargo run`:
diff --git a/examples/integration/src/controls.rs b/examples/integration/src/controls.rs
index 14e53ede..4714c397 100644
--- a/examples/integration/src/controls.rs
+++ b/examples/integration/src/controls.rs
@@ -19,7 +19,7 @@ impl Controls {
pub fn new() -> Controls {
Controls {
background_color: Color::BLACK,
- text: Default::default(),
+ text: String::default(),
}
}
diff --git a/examples/integration/src/main.rs b/examples/integration/src/main.rs
index 90beb097..276794c8 100644
--- a/examples/integration/src/main.rs
+++ b/examples/integration/src/main.rs
@@ -6,13 +6,17 @@ use scene::Scene;
use iced_wgpu::graphics::Viewport;
use iced_wgpu::{wgpu, Backend, Renderer, Settings};
+use iced_winit::conversion;
+use iced_winit::core::mouse;
use iced_winit::core::renderer;
-use iced_winit::core::{mouse, window};
-use iced_winit::core::{Color, Size};
+use iced_winit::core::window;
+use iced_winit::core::{Color, Font, Pixels, Size};
+use iced_winit::futures;
use iced_winit::runtime::program;
use iced_winit::runtime::Debug;
use iced_winit::style::Theme;
-use iced_winit::{conversion, futures, winit, Clipboard};
+use iced_winit::winit;
+use iced_winit::Clipboard;
use winit::{
event::{Event, ModifiersState, WindowEvent},
@@ -29,7 +33,7 @@ use winit::platform::web::WindowBuilderExtWebSys;
pub fn main() -> Result<(), Box<dyn std::error::Error>> {
#[cfg(target_arch = "wasm32")]
let canvas_element = {
- console_log::init_with_level(log::Level::Debug)?;
+ console_log::init().expect("Initialize logger");
std::panic::set_hook(Box::new(console_error_panic_hook::hook));
@@ -41,7 +45,7 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
};
#[cfg(not(target_arch = "wasm32"))]
- env_logger::init();
+ tracing_subscriber::fmt::init();
// Initialize winit
let event_loop = EventLoop::new();
@@ -82,7 +86,6 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
futures::futures::executor::block_on(async {
let adapter = wgpu::util::initialize_adapter_from_env_or_default(
&instance,
- backend,
Some(&surface),
)
.await
@@ -143,12 +146,11 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
// Initialize iced
let mut debug = Debug::new();
- let mut renderer = Renderer::new(Backend::new(
- &device,
- &queue,
- Settings::default(),
- format,
- ));
+ let mut renderer = Renderer::new(
+ Backend::new(&device, &queue, Settings::default(), format),
+ Font::default(),
+ Pixels(16.0),
+ );
let mut state = program::State::new(
controls,
@@ -257,7 +259,7 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
{
// We clear the frame
- let mut render_pass = scene.clear(
+ let mut render_pass = Scene::clear(
&view,
&mut encoder,
program.background_color(),
@@ -274,6 +276,7 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
&queue,
&mut encoder,
None,
+ frame.texture.format(),
&view,
primitive,
&viewport,
diff --git a/examples/integration/src/scene.rs b/examples/integration/src/scene.rs
index 90c7efbf..e29558bf 100644
--- a/examples/integration/src/scene.rs
+++ b/examples/integration/src/scene.rs
@@ -16,7 +16,6 @@ impl Scene {
}
pub fn clear<'a>(
- &self,
target: &'a wgpu::TextureView,
encoder: &'a mut wgpu::CommandEncoder,
background_color: Color,
@@ -37,10 +36,12 @@ impl Scene {
a: a as f64,
}
}),
- store: true,
+ store: wgpu::StoreOp::Store,
},
})],
depth_stencil_attachment: None,
+ timestamp_writes: None,
+ occlusion_query_set: None,
})
}