scale bounds by viewport, set scissor: fixes #21
This commit is contained in:
parent
d5e28bf017
commit
f2aa4de527
2 changed files with 13 additions and 17 deletions
|
@ -346,15 +346,13 @@ impl VideoPipeline {
|
|||
|
||||
pass.set_pipeline(&self.pipeline);
|
||||
pass.set_bind_group(0, &video.bg0, &[]);
|
||||
pass.set_viewport(
|
||||
pass.set_scissor_rect(
|
||||
viewport.x as _,
|
||||
viewport.y as _,
|
||||
viewport.width as _,
|
||||
viewport.height as _,
|
||||
0.0,
|
||||
1.0,
|
||||
);
|
||||
pass.draw(0..4, 0..1);
|
||||
pass.draw(0..6, 0..1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -394,7 +392,7 @@ impl Primitive for VideoPrimitive {
|
|||
format: wgpu::TextureFormat,
|
||||
storage: &mut iced_wgpu::primitive::Storage,
|
||||
bounds: &iced::Rectangle,
|
||||
_viewport: &iced_wgpu::graphics::Viewport,
|
||||
viewport: &iced_wgpu::graphics::Viewport,
|
||||
) {
|
||||
if !storage.has::<VideoPipeline>() {
|
||||
storage.store(VideoPipeline::new(device, format));
|
||||
|
@ -413,7 +411,7 @@ impl Primitive for VideoPrimitive {
|
|||
);
|
||||
}
|
||||
|
||||
pipeline.prepare(queue, self.video_id, bounds);
|
||||
pipeline.prepare(queue, self.video_id, &(*bounds * viewport.projection()));
|
||||
}
|
||||
|
||||
fn render(
|
||||
|
|
|
@ -21,20 +21,18 @@ var<uniform> uniforms: Uniforms;
|
|||
|
||||
@vertex
|
||||
fn vs_main(@builtin(vertex_index) in_vertex_index: u32) -> VertexOutput {
|
||||
let quad = array<vec2<f32>, 6>(
|
||||
uniforms.rect.xy,
|
||||
uniforms.rect.zy,
|
||||
uniforms.rect.xw,
|
||||
uniforms.rect.zy,
|
||||
uniforms.rect.zw,
|
||||
uniforms.rect.xw,
|
||||
var quad = array<vec4<f32>, 6>(
|
||||
vec4<f32>(uniforms.rect.xy, 0.0, 0.0),
|
||||
vec4<f32>(uniforms.rect.zy, 1.0, 0.0),
|
||||
vec4<f32>(uniforms.rect.xw, 0.0, 1.0),
|
||||
vec4<f32>(uniforms.rect.zy, 1.0, 0.0),
|
||||
vec4<f32>(uniforms.rect.zw, 1.0, 1.0),
|
||||
vec4<f32>(uniforms.rect.xw, 0.0, 1.0),
|
||||
);
|
||||
|
||||
var out: VertexOutput;
|
||||
out.uv = vec2<f32>(0.0);
|
||||
out.uv.x = select(0.0, 2.0, in_vertex_index == 1u);
|
||||
out.uv.y = select(0.0, 2.0, in_vertex_index == 2u);
|
||||
out.position = vec4<f32>(out.uv * vec2<f32>(2.0, -2.0) + vec2<f32>(-1.0, 1.0), 1.0, 1.0);
|
||||
out.uv = quad[in_vertex_index].zw;
|
||||
out.position = vec4<f32>(quad[in_vertex_index].xy, 1.0, 1.0);
|
||||
return out;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue