summaryrefslogtreecommitdiffstats
path: root/examples/integration_wgpu/src/scene.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-01-06 23:29:38 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-02-24 13:17:58 +0100
commitb9a9576207ddfc7afd89da30b7cfc7ca0d7e335c (patch)
treec0b4489f1e547fc335e6b82025891cefdc671274 /examples/integration_wgpu/src/scene.rs
parent573d27eb52bbfacf1b06983b4282f00eb5265bdc (diff)
downloadiced-b9a9576207ddfc7afd89da30b7cfc7ca0d7e335c.tar.gz
iced-b9a9576207ddfc7afd89da30b7cfc7ca0d7e335c.tar.bz2
iced-b9a9576207ddfc7afd89da30b7cfc7ca0d7e335c.zip
Remove `iced_glow`, `glyph-brush`, and `wgpu_glyph` dependencies
Diffstat (limited to 'examples/integration_wgpu/src/scene.rs')
-rw-r--r--examples/integration_wgpu/src/scene.rs102
1 files changed, 0 insertions, 102 deletions
diff --git a/examples/integration_wgpu/src/scene.rs b/examples/integration_wgpu/src/scene.rs
deleted file mode 100644
index 3e41fbda..00000000
--- a/examples/integration_wgpu/src/scene.rs
+++ /dev/null
@@ -1,102 +0,0 @@
-use iced_wgpu::wgpu;
-use iced_winit::Color;
-
-pub struct Scene {
- pipeline: wgpu::RenderPipeline,
-}
-
-impl Scene {
- pub fn new(
- device: &wgpu::Device,
- texture_format: wgpu::TextureFormat,
- ) -> Scene {
- let pipeline = build_pipeline(device, texture_format);
-
- Scene { pipeline }
- }
-
- pub fn clear<'a>(
- &self,
- target: &'a wgpu::TextureView,
- encoder: &'a mut wgpu::CommandEncoder,
- background_color: Color,
- ) -> wgpu::RenderPass<'a> {
- encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
- label: None,
- color_attachments: &[Some(wgpu::RenderPassColorAttachment {
- view: target,
- resolve_target: None,
- ops: wgpu::Operations {
- load: wgpu::LoadOp::Clear({
- let [r, g, b, a] = background_color.into_linear();
-
- wgpu::Color {
- r: r as f64,
- g: g as f64,
- b: b as f64,
- a: a as f64,
- }
- }),
- store: true,
- },
- })],
- depth_stencil_attachment: None,
- })
- }
-
- pub fn draw<'a>(&'a self, render_pass: &mut wgpu::RenderPass<'a>) {
- render_pass.set_pipeline(&self.pipeline);
- render_pass.draw(0..3, 0..1);
- }
-}
-
-fn build_pipeline(
- device: &wgpu::Device,
- texture_format: wgpu::TextureFormat,
-) -> wgpu::RenderPipeline {
- let (vs_module, fs_module) = (
- device.create_shader_module(wgpu::include_wgsl!("shader/vert.wgsl")),
- device.create_shader_module(wgpu::include_wgsl!("shader/frag.wgsl")),
- );
-
- let pipeline_layout =
- device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
- label: None,
- push_constant_ranges: &[],
- bind_group_layouts: &[],
- });
-
- device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
- label: None,
- layout: Some(&pipeline_layout),
- vertex: wgpu::VertexState {
- module: &vs_module,
- entry_point: "main",
- buffers: &[],
- },
- fragment: Some(wgpu::FragmentState {
- module: &fs_module,
- entry_point: "main",
- targets: &[Some(wgpu::ColorTargetState {
- format: texture_format,
- blend: Some(wgpu::BlendState {
- color: wgpu::BlendComponent::REPLACE,
- alpha: wgpu::BlendComponent::REPLACE,
- }),
- write_mask: wgpu::ColorWrites::ALL,
- })],
- }),
- primitive: wgpu::PrimitiveState {
- topology: wgpu::PrimitiveTopology::TriangleList,
- front_face: wgpu::FrontFace::Ccw,
- ..Default::default()
- },
- depth_stencil: None,
- multisample: wgpu::MultisampleState {
- count: 1,
- mask: !0,
- alpha_to_coverage_enabled: false,
- },
- multiview: None,
- })
-}