Skip to content

Commit ec9a862

Browse files
committed
patch transparency
1 parent 7f9eea7 commit ec9a862

2 files changed

Lines changed: 22 additions & 19 deletions

File tree

frontend/src/app.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,21 @@ impl App {
1616
// all images must be 1920 x 1080, .resize_exact(nwidth, nheight, filter)
1717
background: ui::Element {
1818
shape: ui::Trapezoid::default(),
19-
image: image::load_from_memory(include_bytes!("assets/background.png"))
20-
.unwrap()
21-
.into_rgba8(),
19+
image: image::load_from_memory_with_format(
20+
include_bytes!("assets/background.png"),
21+
image::ImageFormat::Png,
22+
)
23+
.unwrap()
24+
.into_rgba8(),
2225
},
2326
trackedit: ui::Element {
24-
shape: ui::Trapezoid::from_square(0., 0., 0.5),
25-
image: image::load_from_memory(include_bytes!("assets/track.png"))
26-
.unwrap()
27-
.into_rgba8(),
27+
shape: ui::Trapezoid::default(),
28+
image: image::load_from_memory_with_format(
29+
include_bytes!("assets/track.png"),
30+
image::ImageFormat::Png,
31+
)
32+
.unwrap()
33+
.into_rgba8(),
2834
},
2935
tracks: Arc::new(RwLock::new(Vec::new())),
3036
};

frontend/src/boilerplate/render.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,22 +69,21 @@ impl RenderState {
6969
.unwrap();
7070

7171
// Obtain the Configuration
72-
let surface_caps = surface.get_capabilities(&adapter);
73-
let surface_format = surface_caps
74-
.formats
72+
let surface_formats = surface.get_capabilities(&adapter).formats;
73+
let surface_format = surface_formats
7574
.iter()
7675
.find(|f| f.is_srgb())
77-
.unwrap_or(&surface_caps.formats[0])
76+
.unwrap_or(&surface_formats[0])
7877
.clone();
7978
let size = window.inner_size();
8079
let config = SurfaceConfiguration {
8180
usage: TextureUsages::RENDER_ATTACHMENT,
8281
format: surface_format,
8382
width: size.width,
8483
height: size.height,
85-
present_mode: surface_caps.present_modes[0],
86-
alpha_mode: surface_caps.alpha_modes[0],
87-
view_formats: vec![],
84+
present_mode: PresentMode::AutoVsync,
85+
alpha_mode: CompositeAlphaMode::PreMultiplied,
86+
view_formats: Vec::new(),
8887
desired_maximum_frame_latency: 2,
8988
};
9089

@@ -133,7 +132,7 @@ impl RenderState {
133132
entry_point: Some("fs_main"),
134133
targets: &[Some(ColorTargetState {
135134
format: surface_format,
136-
blend: Some(BlendState::REPLACE),
135+
blend: Some(BlendState::ALPHA_BLENDING),
137136
write_mask: ColorWrites::ALL,
138137
})],
139138
compilation_options: Default::default(),
@@ -276,7 +275,7 @@ impl RenderState {
276275
mip_level_count: 1,
277276
sample_count: 1,
278277
dimension: TextureDimension::D2,
279-
format: TextureFormat::Rgba8UnormSrgb,
278+
format: TextureFormat::Rgba8Unorm,
280279
usage: TextureUsages::TEXTURE_BINDING | TextureUsages::COPY_DST,
281280
view_formats: &[],
282281
},
@@ -312,17 +311,15 @@ impl RenderState {
312311
});
313312

314313
let mut render_pass = encoder.begin_render_pass(&RenderPassDescriptor {
315-
label: Some("Render Pass"),
316314
color_attachments: &[Some(RenderPassColorAttachment {
317315
view: &view,
318316
ops: Operations {
319-
load: LoadOp::Clear(Color::BLACK),
317+
load: unsafe { LoadOp::DontCare(LoadOpDontCare::enabled()) },
320318
store: StoreOp::Store,
321319
},
322320
resolve_target: None,
323321
depth_slice: None,
324322
})],
325-
depth_stencil_attachment: None,
326323
..Default::default()
327324
});
328325

0 commit comments

Comments
 (0)