Skip to content

Commit

Permalink
背景画像の描画に対応 (#71)
Browse files Browse the repository at this point in the history
* 背景に対応した気がする

* とりあえずの実装。透過の効いた書き込みができていない

* 色々わからなくなってきたからいったんここでコミット

* fix document

* fix clippy

* rename pipeline name

* swap method position

* fix example

* 背景画像の変更。細かい挙動に謎はあるが一旦これで完成。
  • Loading branch information
mitoma authored Dec 21, 2024
1 parent 25e059c commit 910914c
Show file tree
Hide file tree
Showing 15 changed files with 570 additions and 62 deletions.
70 changes: 31 additions & 39 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions font_rasterizer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ wgpu = { workspace = true }
winit = { workspace = true }
bitflags = { workspace = true }
rand = { workspace = true }
image ={ workspace = true}

rustybuzz.workspace = true
cgmath.workspace = true
Expand Down
54 changes: 54 additions & 0 deletions font_rasterizer/src/background_bind_group.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
use crate::screen_texture::BackgroundImageTexture;

/// BackgroundImage用の BindGroup。
pub struct BackgroundImageBindGroup {
pub(crate) layout: wgpu::BindGroupLayout,
}

impl BackgroundImageBindGroup {
pub(crate) fn new(device: &wgpu::Device) -> Self {
let layout = device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
entries: &[
wgpu::BindGroupLayoutEntry {
binding: 0,
visibility: wgpu::ShaderStages::FRAGMENT,
ty: wgpu::BindingType::Texture {
multisampled: false,
view_dimension: wgpu::TextureViewDimension::D2,
sample_type: wgpu::TextureSampleType::Float { filterable: true },
},
count: None,
},
wgpu::BindGroupLayoutEntry {
binding: 1,
visibility: wgpu::ShaderStages::FRAGMENT,
ty: wgpu::BindingType::Sampler(wgpu::SamplerBindingType::Filtering),
count: None,
},
],
label: Some("Background Image Bind Group Layout"),
});
Self { layout }
}

pub fn to_bind_group(
&self,
device: &wgpu::Device,
background_image_texture: &BackgroundImageTexture,
) -> wgpu::BindGroup {
device.create_bind_group(&wgpu::BindGroupDescriptor {
layout: &self.layout,
entries: &[
wgpu::BindGroupEntry {
binding: 0,
resource: wgpu::BindingResource::TextureView(&background_image_texture.view),
},
wgpu::BindGroupEntry {
binding: 1,
resource: wgpu::BindingResource::Sampler(&background_image_texture.sampler),
},
],
label: Some("Background Image Bind Group"),
})
}
}
1 change: 1 addition & 0 deletions font_rasterizer/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
mod background_bind_group;
pub mod char_width_calcurator;
pub mod color_theme;
pub mod context;
Expand Down
Loading

0 comments on commit 910914c

Please sign in to comment.