Skip to content

Commit

Permalink
Make all imports direct.
Browse files Browse the repository at this point in the history
  • Loading branch information
kaphula committed Mar 15, 2024
1 parent 2d08936 commit 359b01b
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions examples/src/multiple_render_targets/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
use glam::Vec2;
use std::borrow::Cow;
use winit::event::WindowEvent;

const EXAMPLE_NAME: &str = "multiple_render_targets";

/// Renderer that draws its outputs to two output texture targets at the same time.
Expand All @@ -13,11 +9,11 @@ struct MultiTargetRenderer {
fn create_ball_texture_data(width: usize, height: usize) -> Vec<u8> {
// Creates black and white pixel data for the texture to sample.
let mut img_data = Vec::with_capacity(width * height);
let center: Vec2 = Vec2::new(width as f32 * 0.5, height as f32 * 0.5);
let center: glam::Vec2 = glam::Vec2::new(width as f32 * 0.5, height as f32 * 0.5);
let half_distance = width as f32 * 0.5;
for y in 0..width {
for x in 0..height {
let cur_pos = Vec2::new(x as f32, y as f32);
let cur_pos = glam::Vec2::new(x as f32, y as f32);
let distance_to_center_normalized = 1.0 - (cur_pos - center).length() / half_distance;
let val: u8 = (u8::MAX as f32 * distance_to_center_normalized) as u8;
img_data.push(val)
Expand Down Expand Up @@ -439,7 +435,9 @@ impl crate::framework::Example for Example {
) -> Self {
let shader = device.create_shader_module(wgpu::ShaderModuleDescriptor {
label: None,
source: wgpu::ShaderSource::Wgsl(Cow::Borrowed(include_str!("shader.wgsl"))),
source: wgpu::ShaderSource::Wgsl(std::borrow::Cow::Borrowed(include_str!(
"shader.wgsl"
))),
});
// Renderer that draws to 2 textures at the same time:
let multi_target_renderer = MultiTargetRenderer::init(
Expand Down Expand Up @@ -491,7 +489,7 @@ impl crate::framework::Example for Example {
self.drawer.rebuild_resources(device, &self.texture_targets);
}

fn update(&mut self, _event: WindowEvent) {}
fn update(&mut self, _event: winit::event::WindowEvent) {}

fn render(&mut self, view: &wgpu::TextureView, device: &wgpu::Device, queue: &wgpu::Queue) {
let mut encoder =
Expand Down

0 comments on commit 359b01b

Please sign in to comment.