Skip to content

Commit

Permalink
use general Renderer type in integration example so the rest of the i…
Browse files Browse the repository at this point in the history
…ced code can use it including third party libraries
  • Loading branch information
Davidster committed Sep 2, 2023
1 parent c9bd487 commit 0b572db
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
2 changes: 1 addition & 1 deletion examples/integration/src/controls.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use iced_wgpu::Renderer;
use iced_renderer::Renderer;
use iced_widget::{slider, text_input, Column, Row, Text};
use iced_winit::core::{Alignment, Color, Element, Length};
use iced_winit::runtime::{Command, Program};
Expand Down
34 changes: 20 additions & 14 deletions examples/integration/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use controls::Controls;
use scene::Scene;

use iced_wgpu::graphics::Viewport;
use iced_wgpu::{wgpu, Backend, Renderer, Settings};
use iced_wgpu::{wgpu, Backend, Settings};
use iced_winit::core::mouse;
use iced_winit::core::renderer;
use iced_winit::core::{Color, Size};
Expand Down Expand Up @@ -143,13 +143,15 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {

// Initialize iced
let mut debug = Debug::new();
let mut renderer = Renderer::new(Backend::new(
let wgpu_renderer = iced_wgpu::Renderer::new(Backend::new(
&device,
&queue,
Settings::default(),
format,
));

let mut renderer = iced_renderer::Renderer::Wgpu(wgpu_renderer);

let mut state = program::State::new(
controls,
viewport.logical_size(),
Expand Down Expand Up @@ -267,18 +269,22 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
}

// And then iced on top
renderer.with_primitives(|backend, primitive| {
backend.present(
&device,
&queue,
&mut encoder,
None,
&view,
primitive,
&viewport,
&debug.overlay(),
);
});
if let iced_renderer::Renderer::Wgpu(renderer) =
&mut renderer
{
renderer.with_primitives(|backend, primitive| {
backend.present(
&device,
&queue,
&mut encoder,
None,
&view,
primitive,
&viewport,
&debug.overlay(),
);
});
}

// Then we submit the work
queue.submit(Some(encoder.finish()));
Expand Down

0 comments on commit 0b572db

Please sign in to comment.